Recent

Author Topic: Lazarus Feature suggestion  (Read 1293 times)

440bx

  • Hero Member
  • *****
  • Posts: 3946
Lazarus Feature suggestion
« on: February 18, 2020, 10:29:33 am »
Hello,

I am using an older version of Lazarus (see signature) so maybe this feature has already been implemented, in that case, never mind ;)

The menu Run->Run Parameters shows a dialog box, one of the fields there is "Command line parameters (without application name)", since quite often the parameter is a filename, it would be very nice if it were possible to drag and drop a file from Windows Explorer (or whatever equivalent is in another O/S) and have the file name appear in the box.  It would be particularly nice if the drop handler inspected the filename for spaces and added the necessary quotes at the beginning and end of it.

Another possibility would be to add a "..." button, like the ones for "Host application" and "Working directory" to the "Command line parameter etc" to select a filename.

Either one can occasionally be quite a time saver.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

JernejL

  • Jr. Member
  • **
  • Posts: 92
Re: Lazarus Feature suggestion
« Reply #1 on: February 18, 2020, 10:36:40 am »
I like this idea, and to extend it - a similar - quick "pick file" entry could be added to run dropdown menu.

balazsszekely

  • Guest
Re: Lazarus Feature suggestion
« Reply #2 on: February 18, 2020, 01:04:56 pm »
@440bx

1. Open unit $(LazarusDir)\IDE\RunParamsOpts.pas
2. Set AllowDropFiles property to True(form property)
3. Create an OnDropFiles event:
Code: Pascal  [Select][+][-]
  1. procedure TRunParamsOptsDlg.FormDropFiles(Sender: TObject;
  2.   const FileNames: array of string);
  3. var
  4.   I: Integer;
  5.   P: TPoint;
  6. begin
  7.   P := CmdLineParametersComboBox.ScreenToClient(Mouse.CursorPos);
  8.   if PtInRect(CmdLineParametersComboBox.ClientRect, P) then
  9.   begin
  10.     for I := High(FileNames) downto Low(FileNames) do
  11.     begin
  12.       if not IsCmdLineParamAlreadyExists(FileNames[I]) then
  13.       begin
  14.         CmdLineParametersComboBox.Items.Insert(0, FileNames[I]);
  15.         CmdLineParametersComboBox.ItemIndex := 0;
  16.       end;
  17.     end;
  18.   end;
  19. end;

4. Add function IsCmdLineParamAlreadyExists to the private section of the form
Code: Pascal  [Select][+][-]
  1. function TRunParamsOptsDlg.IsCmdLineParamAlreadyExists(const ACmdLineParam: String): boolean;
  2. var
  3.   I: Integer;
  4. begin
  5.   Result := False;
  6.   for I := 0 to CmdLineParametersComboBox.Items.Count - 1 do
  7.   begin
  8.     if CmdLineParametersComboBox.Items[I] = ACmdLineParam then
  9.     begin
  10.       Result := True;
  11.       Exit;
  12.     end;
  13.   end;
  14. end;

5. Add types to the uses clauses
6. Rebuild the IDE



440bx

  • Hero Member
  • *****
  • Posts: 3946
Re: Lazarus Feature suggestion
« Reply #3 on: February 18, 2020, 03:11:08 pm »
@GetMem

Thank you GetMem!... you definitely exceeded my expectations...   :) I didn't even dream of getting it shortly after suggesting it.

I'll be following those steps _very_ soon... right now, I'm in the middle of some convoluted testing and I don't want to lose track of what I've done so far.  I'll post an update once done.  Thank you again.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

balazsszekely

  • Guest
Re: Lazarus Feature suggestion
« Reply #4 on: February 18, 2020, 08:17:28 pm »
@440bx

You're welcome. :)

 

TinyPortal © 2005-2018