Recent

Author Topic: Collapsing Editor Nodes  (Read 252 times)

abtaylr

  • Full Member
  • ***
  • Posts: 104
Collapsing Editor Nodes
« on: November 27, 2019, 06:04:43 pm »
I have tried over the last few years on and off when my frustration gets high enough to look for a way to collapse the nodes found in the left side of the IDE Editor.  Currently, I collapse the methods one by one. It takes a long time to get through a unit to collapse all of the nodes individually.  I have looked extensively in IDE Tools -> Options and have found a table that I thought might relate to this issue -- Options-> Editor -> Mouse -> Advanced which I thing says under All->Gutter->Fold Tree->Collapsed->FoldCode->Left Mouse Button->Click-Any->AltKey->UpKey to fold one node.

When I have tried this combination or any of the others hitting the left mouse button followed by Alt or Cntrl and the up or down keys as shown in the table just makes my cursor fly to some other location in the form without doing anything about collapsing or uncollapsing a node.

Is there a command that I am missing?

FPC: 3.0.5
Lazarus: 2.0.6
Linux: Kubuntu 64bit v19.10
« Last Edit: November 27, 2019, 06:10:33 pm by abtaylr »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5788
    • wiki
Re: Collapsing Editor Nodes
« Reply #1 on: November 27, 2019, 08:21:53 pm »
"Collapsing Editor Nodes" the term you are looking for is "code folding"

What you are looking for (at least the most similar...) is in the Keymap. Tools > Option > Editor > Keymap
And on that page, under "Text folding commands"

"Fold to Level n" by default Alt-Shift-1  to Alt-Shift-9

However that does not only affect "procedures", it will also fold "classes", and "type" sections, etc.
Depends on what you have set up under: Tools > Option > Editor > Code Folding

It depends, if you have disabled folding for "unit", "program", "unit section" (interface, implementation)....
- If  you fold (collapse) "implementation" then that hides all the "procedures" inside it => that is called "nested" and makes one nested level.
- unit > implementation > procedure : 3 levels (procedure would be 3rd)
But if you disable them, procedure is on top (1st level)

Alt-Shift-1 => folds all at the 1st level. That could be "procedure" and "class". Or it could be "implementation", or it could be "procedure" and "type"...
Depends on what you allow to be folded.

So you have to try out what is at what level, depending on your config.
And that means, you may fold more that only "procedure".



If you select some text, then a right click, on the "[+]"/"[-]" area, allows you to fold comments, and inactive-IFDEF.


Not tested: You might be able to use the editors macro feature https://wiki.lazarus.freepascal.org/IDE_Window:_Editor_Macros (and it has a link to pascal script)

You could record, search for procedure  (that is easier to do with the pascal script macro)

Code: Pascal  [Select]
  1. begin
  2. ecIncrementalFind;
  3. ecChar('p');
  4. ecChar('r');
  5. ecChar('o');
  6. ecChar('c');
  7. ecChar('e');
  8. ecChar('d');
  9. ecChar('u');
  10. ecChar('r');
  11. ecChar('e');
  12. ecLeft;
  13. ecFoldCurrent;
  14. ecDown;
  15. end.
with pascalscript you can do search for diff keywords, verify if the search found something, and repeat in a loop
« Last Edit: November 27, 2019, 08:30:03 pm by Martin_fr »

abtaylr

  • Full Member
  • ***
  • Posts: 104
Re: Collapsing Editor Nodes
« Reply #2 on: November 28, 2019, 05:20:55 pm »
It's a miracle! It works!  It wouldn't work with the default combination so I had to find a different combination. Probably something to do with Linux.

Thank you.

abt