Forum > Editor

Region fold all not working?

<< < (2/3) > >>

chrnobel:

--- Quote from: Martin_fr on May 13, 2022, 10:59:17 pm ---For Pascal code levels depend on the config and code.
If you did set "unit" to be foldable, then that is likely the most outer level. "implementation (if configured) is then the 2nd level.

If you don't have those fold-able then "procedure" may be your first level, and then each nested begin inside opens a new level.

--- End quote ---
It is pure Pascal, so how do I see(set) if the unit is foldable?

Martin_fr:

--- Quote from: chrnobel on May 14, 2022, 12:59:39 pm ---It is pure Pascal, so how do I see(set) if the unit is foldable?

--- End quote ---

Menu: Tools > Options > Editor > Code Folding
Set the checkbox for the "unit" entry.

The "Fold" / "Hide" radio buttons are available only for certain elements, such as comments.
- Fold: keep the first line visible
- Hide: do not even show the first line (the unfold symbol will then be on the line above)

Martin_fr:
Some background....

Ignore IFDEF / REGION ... => Then all folding is hierarchically structured/nested.

That means if you have

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---if a then begin // fold start  if b then begin // nested fold startThe nested fold for "b" will always end before the fold for "a" ends.
Or it ends on the same line.

But it can not overlap. It is never possible that "b" folds any lines that are not also folded by "a".
There is no way that
- "b" folds lines 11 to 17
- "a" folds lines 10 to 15

The nest level is not determined by the keywords. It does not matter if you fold at a "begin", or a "procedure" or "implementation" or "class" ....
- Every time a fold starts (the gutter has a [+]) the nest level  goes up by one (or more, if several folds start on that line).
- Every time a fold ends the nest level goes down by one.

And the "fold to level n" simply counts how many surrounding/outer blocks exist.


IFDEF / REGION and region work different.

An IFDEF or REGION  can partly overlap a begin block

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---if a then begin  ...  {%REGION}  ...  end;...{%ENDREGION} 
If the REGION would increase/decrease the fold-level => then part of the begin/end would be at level 1, but part of that block would be at level 2 (because the "end" of the "begin..end" is in the REGION and therefore it would be at a higher level.

So IFDEF / REGION do not take part in the level counting. (There are also implementation details, which would make it incredible complicated to have them do level counting).


In theory they (can) have their own independent levels.
You could implement a command in the IDE that folds all regions, or only regions nested at n levels within other regions.
But someone would need to implement that.
(Adding it to the gutter menu is probably the easier task / yet still work that needs to be done by someone)

chrnobel:
I really don't get it.

I have tried to uncheck folding for everything, except region, but the result remains the same, the only way I can fold regions is by clicking the the - box at the left side, region by region.

And if i make unit foldable I can fold the entire unit, but still not the region (which should then be level 2, aka alt-shift-2).

And the editor nicely shows the beginning and end of the region.

Martin_fr:

--- Quote from: chrnobel on May 15, 2022, 06:38:21 pm ---I have tried to uncheck folding for everything, except region, but the result remains the same, the only way I can fold regions is by clicking the the - box at the left side, region by region.

--- End quote ---

As, I told you:

--- Quote from: Martin_fr on May 13, 2022, 10:59:17 pm ---regions don't have (that kind of) level.

The keyboard folding "fold to level n" (usually Alt-Shift-<num>) only works on Pascal-code.

--- End quote ---
The region-folds (and also the IFDEF folds) are not part of the "fold to level n".
There is no config to change that.

I agree that it would be nice to have some similar feature.
It just needs to be implemented by someone.

I did write "some similar feature" => because the current "fold to level n" are for various reason reserved to >>source-code-keyword<< folding.
But a new menu-entry or keyboard-combo "fold region to level n" or "fold all region in selection" or "fold all region" ... Well any of them would be welcome.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version