Code folding lazarus / 6-IDE-CodeTools ---------------------------------------------------------------------- anonymous coward · 2008-09-07 18:13 Currently this code: Code: [Select] procedure example; var blah: type; begin {stuff} end; can fold to: Code: [Select] procedure example; var blah: type; begin but I think it would be nice if it could further fold it to: Code: [Select] procedure example; var begin and Code: [Select] procedure example; ---------------------------------------------------------------------- anonymous coward · 2008-10-04 01:18 So is it a good idea or a bad idea? ---------------------------------------------------------------------- theo · 2008-10-04 09:51 Is code folding a good idea at all? ;-) I never use it. Jumping from declaration to implementation and back does the job for me. ---------------------------------------------------------------------- anonymous coward · 2008-10-04 21:15 Quote from: "theo"Is code folding a good idea at all? ;-) I never use it. Jumping from declaration to implementation and back does the job for me. That's beside the point though. If code folding is done, which way should it be done? ---------------------------------------------------------------------- LazaruX · 2008-10-13 10:05 Hi, actually, I also do not use it often, but already a while a go, I had your same idea, and i would prefer the last suggestion you made ---------------------------------------------------------------------- Orgun109uk · 2008-10-20 08:11 I think it would be nice to be able to use {$REGION}'s, useful to fold entire sections of code. ---------------------------------------------------------------------- anonymous coward · 2008-11-14 22:50 Quote from: "BPsoftware"Hi, actually, I also do not use it often, but already a while a go, I had your same idea, and i would prefer the last suggestion you made It's just one suggestion. I mean something like this (btw I've slightly changed my mind): Code: [Select] [-] |procedure example; [-] |var  │  | blah: type; [-] |begin  │  | {stuff}  └  |end; Code: [Select] [-] |procedure example; [+] |var [-] |begin  │  | {stuff}  └  |end; Code: [Select] [-] |procedure example; [-] |var  │  | blah: type; [+] |begin  └  |end; Code: [Select] [-] |procedure example; [+] |var [+] |begin  └  |end; Code: [Select] [+] |procedure example; ---------------------------------------------------------------------- Martin_fr · 2008-11-18 01:46 Best is to add a feature request to mantis, so It will not be forgotten. And yes that means the idea has chances to get implemented (but it's not top priority :( ). There is a similar request for class declarations at http://bugs.freepascal.org/view.php?id=12139 And last not least, since the discussion is on. [-]  if a=1 then Begin  if b=2 then begin          writeln(a+b);        end;  // fold ends here        writeln(a);      end;     // can not fold to here Despite winning a price for unreadable code-formatting, currently only the inner block can be folded. (try it) Any idea how the [+] / [-] in the gutter could be improved to allow proper selection what should be folded? Any other editor that deals with situations like this? ---------------------------------------------------------------------- anonymous coward · 2008-12-02 01:10 Quote from: "Martin_fr"Best is to add a feature request to mantis, so It will not be forgotten. And yes that means the idea has chances to get implemented (but it's not top priority ). There is a similar request for class declarations at http://bugs.freepascal.org/view.php?id=12139 Alright but, how should I word it? "The code between a declaration- block-starter-thingy and either another declaration-block-starter- thingy or 'begin' should fold and, the code between the function declaration and the corresponding 'end' should fold"? Quote from: "Martin_fr" And last [but] not least, since the discussion is on. [-]  if a=1 then Begin  if b=2 then begin          writeln(a+b);        end;  // fold ends here        writeln(a);      end;     // can not fold to here Despite winning a price for unreadable code-formatting, currently only the inner block can be folded. (try it) Any idea how the / [-] in the gutter could be improved to allow proper selection what should be folded? I guess the gutter could either be bigger or use numbers like this: Code: [Select] [0] |if a=1 then Begin if b=2 then begin  │  | writeln(a+b)  └  | end;  │  | writeln(a);  └  |end; Code: [Select] [1] |if a=1 then Begin if b=2 then ...  │  | writeln(a);  └  |end; Code: [Select] [2] |if a=1 then ... ---------------------------------------------------------------------- Martin_fr · 2008-12-02 12:17 Quote from: "non-4chan_anonymous" I guess the gutter could either be bigger or use numbers like this: Code: [Select] [0] |if a=1 then Begin if b=2 then begin  │  | writeln(a+b)  └  | end;  │  | writeln(a);  └  |end; Code: [Select] [1] |if a=1 then Begin if b=2 then ...  │  | writeln(a);  └  |end; Code: [Select] [2] |if a=1 then ... A lot of people wouldn't like a bigger gutter. As for the numbers, I don't see how they solve the issue Code: [Select] [+/-]  begin begin  x           writeln;  x         end;  │         writeln;  └      end; The lines with the "x" are invisible, so the smaller nested block is currently folded. It does not matter if you ended up in this situation from by "folfing the small block" or by "unfolding the big block". Your next action must not relay on what your previous action was. Now if you click on the [+/-], what should happen, fold the big, or unfold the small block? The question is the same, if nstead of a [+] or [-] there was a [1]. I thought about possibilities like: - divide the folding symbol diagonal [+/-]. That is this would still be a little square, with the upper left being half meaning plus, and the lower right being minus. =? this will be far to small to work - allowing a menu from either the [+] or the [-] (but which is the default?) ---------------------------------------------------------------------- anonymous coward · 2008-12-07 19:15 Quote from: "Martin_fr"Now if you click on the [+/-], what should happen, fold the big, or unfold the small block? The question is the same, if instead of a or [-] there was a [1]. I was thinking of a modulo kind of thing where the left click increased the number and right click decreased the number. ---------------------------------------------------------------------- anonymous coward · 2008-12-07 19:23 Quote from: "Orgun109uk"I think it would be nice to be able to use {$REGION}'s, useful to fold entire sections of code. I don't know if the "$" is really appropriate though. ---------------------------------------------------------------------- Martin_fr · 2009-01-01 21:41 The Region Stuff is still outstanding, but folding at "procedure foo" or class declaration is available now ---------------------------------------------------------------------- anonymous coward · 2009-01-05 00:39 Quote from: Martin_fr on January 01, 2009, 10:41:32 pmThe Region Stuff is still outstanding, but folding at "procedure foo" or class declaration is available now Hey, it is. Thanks to the developer who is responsible. ---------------------------------------------------------------------- Paul Ishenin · 2009-01-05 09:24 Developer who is responsible is Martin_fr ---------------------------------------------------------------------- Martin_fr · 2009-04-13 15:56 Folding at user region is available in 0.9.27 SVN Recognizing both %Region and $Region see http://bugs.freepascal.org/view.php?id=12718 Issue remaining: http://bugs.freepascal.org/view.php?id=12811 With more than one fold starting in the same line, you can only fold the last one for this line.