Recent

Author Topic: Can Lazarus support Auto-closing quota or parentheses?  (Read 1555 times)

blackangel

  • Newbie
  • Posts: 4
Can Lazarus support Auto-closing quota or parentheses?
« on: June 26, 2025, 03:55:33 am »
I can not found where the place set auto-closing quota or parentheses, does is it support?
if not ,I hope it will be implemented in the next version.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12143
  • Debugger - SynEdit - and more
    • wiki
Re: Can Lazarus support Auto-closing quota or parentheses?
« Reply #1 on: June 26, 2025, 08:11:12 am »
Unfortunately it can't.
It is a todo, but not yet clear if it will be done in time for the next version.

You can however continue 'quote' text on the next line => I.e. when pressing return inside a string, then closing and opening quote for the newline can be added. See Tools > Options > Editor > Tab and Indent.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12143
  • Debugger - SynEdit - and more
    • wiki
Re: Can Lazarus support Auto-closing quota or parentheses?
« Reply #2 on: June 26, 2025, 08:15:13 am »
Actually you can create an editor macro, and bind it to the "(" key.

Simplest form is to record the  the "()" (and caret one back) sequence, and replay it.

But you can use PascalScript to customize it.

https://wiki.freepascal.org/IDE_Window:_Editor_Macros
https://wiki.freepascal.org/Editor_Macros_PascalScript

Aruna

  • Hero Member
  • *****
  • Posts: 787
Re: Can Lazarus support Auto-closing quota or parentheses?
« Reply #3 on: June 26, 2025, 12:36:33 pm »
I can not found where the place set auto-closing quota or parentheses, does is it support?
if not ,I hope it will be implemented in the next version.
Hello @blackangel I've attached a ZIP file that demonstrates the functionality you want, though it's not integrated directly into the Lazarus IDE source editor.
If this approach works for you, you can simply copy or cut from the demo and paste it into the IDE editor as needed.

@Martin_fr what if we hook into the ide source editor then create a package as design-time only? I tried this but it is telling me stuff I do not yet fully understand.
Last two screenshots attached will show you what I am looking at and  how do I fix please?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12143
  • Debugger - SynEdit - and more
    • wiki
Re: Can Lazarus support Auto-closing quota or parentheses?
« Reply #4 on: June 26, 2025, 01:01:35 pm »
@Martin_fr what if we hook into the ide source editor then create a package as design-time only?

Hooking it into the editor is a bit more work.

1) It needs config for the user
 - properties in SynEdit for the form designer
 - Options in the IDE
 
2) What is a bracket? Depends on the HL. E.g. XML has <>

3) Should have (some basic) detection if the closing element already exist?

4) Make sure its one undo? Or should it be a separate undo, so if you did a closing bracket that you did not want. (Some word processors do that, e.g if the format certain text automatically)

5) Given the amount of options, in needs to be some form of add-on/plugin. So there could be alternative handlers, if users want that for their own code.


Some points could be deferred, added over time. (5) however must be part of the initial implementation.



Still, its overall not too complicated.

But its sums up to take some time...

Aruna

  • Hero Member
  • *****
  • Posts: 787
Re: Can Lazarus support Auto-closing quota or parentheses?
« Reply #5 on: June 26, 2025, 02:10:35 pm »
@Martin_fr what if we hook into the ide source editor then create a package as design-time only?

Hooking it into the editor is a bit more work.

1) It needs config for the user
 - properties in SynEdit for the form designer
 - Options in the IDE
Hmm...
 
2) What is a bracket? Depends on the HL. E.g. XML has <>
That is true I never thought about this.

3) Should have (some basic) detection if the closing element already exist?

4) Make sure its one undo? Or should it be a separate undo, so if you did a closing bracket that you did not want. (Some word processors do that, e.g if the format certain text automatically)

5) Given the amount of options, in needs to be some form of add-on/plugin. So there could be alternative handlers, if users want that for their own code.


Some points could be deferred, added over time. (5) however must be part of the initial implementation.



Still, its overall not too complicated.

But its sums up to take some time...
What is the worst thing that can happen if I proceed with my experimentation flying blind ? I really do not want the ide to choke on me . I am going to open a new thread on how to add a plug-in that can hook-into the ide source editor and allow one to add features. Thank you for pointing out what to you must be obvious but to newbies like myself we miss all this...

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12143
  • Debugger - SynEdit - and more
    • wiki
Re: Can Lazarus support Auto-closing quota or parentheses?
« Reply #6 on: June 26, 2025, 02:19:59 pm »
1) It needs config for the user
 - properties in SynEdit for the form designer
 - Options in the IDE
Hmm...
Well at least an Enable/Disable.

That applies for both, the IDE, but also the standalone SynEdit (though in the standalone, this will be solved by it being a plugin. Don add it, and you don't need to switch it off.

Quote
What is the worst thing that can happen if I proceed with my experimentation flying blind ? I really do not want the ide to choke on me . I am going to open a new thread on how to add a plug-in that can hook-into the ide source editor and allow one to add features. Thank you for pointing out what to you must be obvious but to newbies like myself we miss all this...

Well that depends how we proceed.

- If a plugin is added to SynEdit (in the SynEdit package)
- The IDE creates the plugin
- The IDE has a disable/enable option

Then that should be fine.


 

TinyPortal © 2005-2018