Recent

Author Topic: [SOLVED] synEdit autoCompleteList editor syntax rules  (Read 187 times)

Weiss

  • Sr. Member
  • ****
  • Posts: 257
[SOLVED] synEdit autoCompleteList editor syntax rules
« on: August 06, 2026, 01:08:45 am »
where can I find the exact rules for entering code autocompletion templates into autoCompleteList editor?

Examples show only a single line completion templates. For multi-line, there must some escape characters? if I simply enter

Code: Pascal  [Select][+][-]
  1. f
  2. =for then
  3.    begin
  4.      |              //this is text entered into editor, not the code
  5.    end;
  6.  


then result will be

Code: Pascal  [Select][+][-]
  1. for then
  2.  

any new line will be ignored by some kind of parser managing the templates.

Gents, this is not something covered in examples or documentation (is there documentation), and Google and AI keep suggesting all kind of ways of entering multi-line templates, apparently from Delphi, none of them work.

I can built strings with sLineBreak programmatically, and add them like so

Code: Pascal  [Select][+][-]
  1. synAutoComplete1.AutoCompleteList.Add(templateText);
  2.  


but indentation is something that needs to be caught dynamically at runtime. How to enter multi-line template correctly and let autoComplete to manage indentation?
« Last Edit: August 06, 2026, 09:25:49 pm by Weiss »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12634
  • Debugger - SynEdit - and more
    • wiki
Re: synEdit autoCompleteList editor syntax rules for multi-line templates?
« Reply #1 on: August 06, 2026, 10:29:56 am »
Unfortunately this module is hardly maintained. Afaik it was part of the fork 2, nearly 3 decades ago. And at best had fixes to compile or avoid crashes.

The parser is in
procedure TSynAutoComplete.Execute(token: string; aEditor: TCustomSynEdit);


The example expands "pc" and "po" each to 2 lines. So that is covered?

There is one line with the token that should be expanded. Then 1 or more lines that each must start with an "=" as very first char. Not tested, but afaik they can be empty after that (i.e. just the "=").

The expansion ends with the last line found starting with a "=".

Weiss

  • Sr. Member
  • ****
  • Posts: 257
Re: synEdit autoCompleteList editor syntax rules for multi-line templates?
« Reply #2 on: August 06, 2026, 09:19:53 pm »
yes Martin, I somehow missed it, thank you for pointing out. Editor still does not eat more than one line, but adding programmatically works fine. I do not know if this is worth the bug report, I would feel guilty for diverting attention to such small thing.

I looked at .execute proc earlier with lazy eye, did not see what I was looking for.

 

TinyPortal © 2005-2018