Sign in Join

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

Mailing lists / lazarus / 2009-05

Live Templates

8 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

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

Lee Jenkins

Graeme's recent post made me wonder if there is been work or talk of work on implementing Live Templates like Delphi has?

I imagine that that kind of behavior is a bit of work to implement.

Warm Regards, Lee

Reply by email

Mattias Gärtner
to Lee Jenkins

Zitat von Lee Jenkins :

Graeme's recent post made me wonder if there is been work or talk of work on implementing Live Templates like Delphi has?

Yes.

1. Lazarus will not support the Delphi syntax, because Lazarus already supports code macros. There are already some code macros using the codetools.

2. auto complete without pressing a short cut already works for return, space and word end.
Some code macros are needed to fine tune adding text if parts of the template already exists (for example auto complete 'begin' after pressing return). But this is stuff for another thread.

3. templates with parameters: editing the parameters directly in the source editor (synedit) without a dialog. synedit needs a further edit mode for marking and editing several places in parallel. Martin has already implemented marking several places. I guess he can also create a plugin/extension/mechanism for the needed edit mode. When this is done, I will be glad to implement the rest.
This edit mode is also needed for in situ rename.

I imagine that that kind of behavior is a bit of work to implement.

Yes, but I bet Martin has already some ideas for synedit.

Mattias

Powered by NetMail

Reply by email

Martin Friebe
to Mattias Gärtner
Mattias G?rtner wrote 25 lines
Zitat von Lee Jenkins : > Graeme's recent post made me wonder if there is been work or talk of work on > implementing Live Templates like Delphi has? > Yes. 1. Lazarus will not support the Delphi syntax, because Lazarus already supports code macros. There are already some code macros using the codetools. 2. auto complete without pressing a short cut already works for return, space and word end. Some code macros are needed to fine tune adding text if parts of the template already exists (for example auto complete 'begin' after pressing return). But this is stuff for another thread. 3. templates with parameters: editing the parameters directly in the source editor (synedit) without a dialog. synedit needs a further edit mode for marking and editing several places in parallel. Martin has already implemented marking several places. I guess he can also create a plugin/extension/mechanism for the needed edit mode. When this is done, I will be glad to implement the rest. This edit mode is also needed for in situ rename.

Yep, it's on the list, but not yet sure when.
For code Template there a 2 main targets:
1) "Form mode"
- The code template defines several places (form-fields) where input is needed "for [] := [] to [] do"
- the Editor the allows to navigate them using tab (or a user defined key shortcut

2) Sync Edit
Actually this is a feature off it's own, but should work specially with templates: the form-fields from above could be linked, editing the content off 1, would update the other too.

Example: check a variable is in range: (while you type in field 1, the same appears in field 2:
"if ([] >= 10) and ([] < 20) then "

Show quoted text 6 lines
> I imagine that that kind of behavior is a bit of work to implement. > Yes, but I bet Martin has already some ideas for synedit.

Not exactly related to templates, but one feature, I like to add for myself.

Motivated by commenting code.
If you type "(*", this will comment all of the remaining code, temporarily disabling all highlighting, and unfolding everything.....

A magic "add cloisng bracket".

If you type "(*" SynEdit inserts a >virtual< "*)". (Could be shown like a hint...) the closing "*)" follow sthe caret movement. So you can move the caret to the desired location and hit enter. It could be cancelled bey "esc", it would also detect manually typing the "*)" sequence....

It could work for any other pair-construct, including begin/end

Reply by email

Graeme Geldenhuys
to Mattias Gärtner: Zitat von Lee Jenkins : Yes. 1. Lazarus will not support the Delphi syntax, because…

2009/5/13 Mattias G?rtner :

2. auto complete without pressing a short cut already works for return, space and word end.

And boy do those come in handy! I already have my own collection of marco code templates. Some even create complete classes using text in the clipboard. :-)

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Hans-Peter Diettrich
to Lee Jenkins: Graeme's recent post made me wonder if there is been work or talk of work on implementing…
Graeme's recent post made me wonder if there is been work or talk of work on implementing Live Templates like Delphi has?

My experience with Live Templates: they are nice to use, but so hard to write properly, that no user will ever try to write a template himself.

Then it does not make a difference, whether the templates are implemented in code (codetools), or as scripts.

DoDi

Reply by email

Graeme Geldenhuys
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote
My experience with Live Templates: they are nice to use, but so hard to write properly, that no user will ever try to write a template himself.

I don't know about that. The tiOPF has quite a few Live Templates for Delphi's newer IDEs. All contributed by tiOPF users. I once found a tutorial on live templates and they explain how to write them. It looked rather self explanatory if you know the syntax.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Lee Jenkins
to Graeme Geldenhuys: On Wed, May 13, 2009 at 7:54 PM, Hans-Peter Diettrich I don't know about that. The tiOPF…
Graeme Geldenhuys wrote 10 lines
On Wed, May 13, 2009 at 7:54 PM, Hans-Peter Diettrich wrote: > My experience with Live Templates: they are nice to use, but so hard to > write properly, that no user will ever try to write a template himself. I don't know about that. The tiOPF has quite a few Live Templates for Delphi's newer IDEs. All contributed by tiOPF users. I once found a tutorial on live templates and they explain how to write them. It looked rather self explanatory if you know the syntax.

They are invaluable in using tiOPF and other frameworks where you're doing a lot of inheritance and overriding methods. I have a couple live templates that create whole units which saves a lot of time.

Warm Regards, Lee

Reply by email