Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-10

Syncro-Edit with Code Templates?

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

I've setup a Code Templates 'lsi' (Logging with SendInteger(...)). When I press Ctrl+J I would like the following to appear with the cursor inside the first parameter of the SendInteger() call. Now the tricky part. I would ideally also like to have something like Syncro-Edit automatically enabled for the inserted code, so that when I change the first parameter, the second parameter is changed too.

eg of initial result after Ctrl+J:

  SendInteger('data', data);

eg of end result:

  SendInteger('Form1.Name', Form1.Name);

Is something like this possible with Lazarus 0.9.30.x and Code Templates and maybe some of the Code Template Macros?

I looked at the $Param() and $PrevWord() code template macros, but can't figure out how to use them, so I don't know if they might be a solution.

The end result is that SendInteger() will then log the following to the debug server:
Form1.Name = 'MyFirstForm'

... but I didn't have to type 'Form1.Name' twice in my code.

Regards,
- Graeme -

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

Reply by email

Alexander Shishkin
to Graeme Geldenhuys

21.10.2011 10:47, Graeme Geldenhuys ?????:

Show quoted text 35 lines
Hi, I've setup a Code Templates 'lsi' (Logging with SendInteger(...)). When I press Ctrl+J I would like the following to appear with the cursor inside the first parameter of the SendInteger() call. Now the tricky part. I would ideally also like to have something like Syncro-Edit automatically enabled for the inserted code, so that when I change the first parameter, the second parameter is changed too. eg of initial result after Ctrl+J: SendInteger('data', data); eg of end result: SendInteger('Form1.Name', Form1.Name); Is something like this possible with Lazarus 0.9.30.x and Code Templates and maybe some of the Code Template Macros? I looked at the $Param() and $PrevWord() code template macros, but can't figure out how to use them, so I don't know if they might be a solution. The end result is that SendInteger() will then log the following to the debug server: Form1.Name = 'MyFirstForm' ... but I didn't have to type 'Form1.Name' twice in my code. Regards, - Graeme -

For 0.9.31:

SendInteger('$Param(data,Sync=1)|', $Param(data,Sync=1));

Reply by email

Sven Barth
to Graeme Geldenhuys
Graeme Geldenhuys wrote 5 lines
On 2011-10-21 09:04, Alexander Shishkin wrote: > SendInteger('$Param(data,Sync=1)|', $Param(data,Sync=1)); Awesome, thanks! That works perfectly under 0.9.30.x too. :-)

AFAIK you don't need the "Sync=1" in the first parameter (if it is indeed the first).

Regards,
Sven

Reply by email