Re: [Lazarus] Format code on Save

2017-02-23 Thread Graeme Geldenhuys via Lazarus
On 2017-02-23 09:08, Mattias Gaertner via Lazarus wrote:
>> Also, what does the AddHandlerOnSaveEditorFile()'s "AtLast" parameter
>> mean and do?
> 
> Prepend or append to the list of handlers.

Ah, thank. That would come in handy if the IDE Options ever have a GUI
to manage such actions. eg: Eclipse has that, and that is also where I
saw this feature (format code on save).



> You set a non var parameter? Think again.

Ah, too many late nights. Thanks for that pointer.

Adding the following to the beginning of my event handler solves the
problem.

  if SaveStep = sefsAfterWrite then
Exit;


Thanks for all your help.

Regards,
  Graeme

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Format code on Save

2017-02-23 Thread Mattias Gaertner via Lazarus
On Thu, 23 Feb 2017 00:40:13 +
Graeme Geldenhuys via Lazarus  wrote:

> On 2017-01-27 14:37, Mattias Gaertner via Lazarus wrote:
>[...]
> > LazarusIDE.AddHandlerOnSaveEditorFile(@YourEvent);  
> 
> 
> A bit late, but thank you for adding that functionality. I've now
> managed to create my IDE add-on and it works.
> 
> But I noticed that with every save (Ctrl+S), the YourEvent gets called
> twice?  Any idea why that is, and if it was by design or a bug?

Check parameter SaveStep.

Mattias
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


[Lazarus] Feature Request: IDE user defined recorded macros

2017-02-23 Thread Graeme Geldenhuys via Lazarus
Hi,

Are there any plans to add user recorded macros support to Lazarus IDE?

Many text editors have this built-in, and allows for a huge amount of
“extending the editor’s features” without modify the underlying
program's source code. We can simply record a sequence of actions, give
it a name, assign it a keyboard shortcut and play it back when we need
that functionality.

I was quite surprised to see Lazarus IDE doesn’t have that. Maybe I’m
simply overlooking the feature (very possible), or it’s enabled via an
external IDE package add-on?

See attached screenshot of a commercial text editor called EditPad Pro
7. It has extensive support for user recorded macros. You can even
export the macro to a INI file, edit the macro and then import it again.

Here is an example of an exported "join lines" macro.

==
[EditPadProMacro]
Caption=Join Lines
ShortCut=16458
CommandCount=6
C0=Editor.CaretDown
C1=Editor.CaretHome
C2=Editor.CaretEnd
C3=Actions.ActionExtraTrimLeading
C4=Editor.CaretUp
C5=Editor.Backspace

[EditPadProMacroC2]
ExpandSel=1
==

Regards,
  Graeme

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Format code on Save

2017-02-23 Thread Mattias Gaertner via Lazarus
On Thu, 23 Feb 2017 08:41:06 +
Graeme Geldenhuys via Lazarus  wrote:

>[...]
> > Check parameter SaveStep.  
> 
> I tried both sefsBeforeWrite and sefsAfterWrite - it made no difference
> to the issue of the method being called twice.
> 
> Also, what does the AddHandlerOnSaveEditorFile()'s "AtLast" parameter
> mean and do?

Prepend or append to the list of handlers.

 
> I also set the Return result to mrOK.

Good.


> Here is the whole implementation of the event handler and Register call.
> 
> 
> ==
> procedure Register;
> begin
>   LazarusIDE.AddHandlerOnSaveEditorFile(@uJCFHandler.BeforeSaveCallJCF,
> False);
> end;
> 
> function TJCFHandler.BeforeSaveCallJCF(Sender: TObject;
>aFile: TLazProjectFile; SaveStep: TSaveEditorFileStep;
>TargetFilename: string): TModalResult;
> var
>   cmd: TIDECommand;
> begin
>   SaveStep := sefsBeforeWrite;

You set a non var parameter? Think again.

Mattias
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Feature Request: IDE user defined recorded macros

2017-02-23 Thread Graeme Geldenhuys via Lazarus
Scratch that! I should have done better searching before I posted. I
apparently asked a similar question back in 2015 and found my answer here...


  http://wiki.freepascal.org/IDE_Window:_Editor_Macros


Sorry for the noise. :-/


Regards,
  Graeme

-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
http://lists.lazarus-ide.org/listinfo/lazarus