You probably do not need to store the height of any vertical line. ...
But you need to know when a vertical line moves x pos.
I did it. I've able to identify when a 'begin' is moved or not, by comparing the both texts :
* text on the line/caret before editing
* text that has been updated.
It's done because:
+ when the Caret moved up or down, I store the text in the line.
+ when text changed, I can only get the text being changed, but I already have text before change that I store when caret moved vertical.
I think it would be better when the bugfix happens in TSynCustomFoldHighlighter (SynEditHighlighterFoldBase.pas),
Because, the job (invalidate rest line) has already been done (without my bugfix)
when I delete "b" from "begin", Also, when I edit again the "egin" into "begin".
The HL does indeed some of the invalidation. If a begin is inserted/removed it will invalidate down to the last affected end (potentially end of file).
But: if a "begin" simply changes x pos (add a space on that line, but somewhere before the begin) then for the HL no invalidation is needed. SynEdit will invalidate just that line (sometimes 1 or 2 extra)
Both of the above are as intended.
if my bugfixed invalidation runs, so the rest lines possibly invalidated twices !
Can it configured outside SynMarkup? As you said, people play in laptop, and every invalidate cost battery ha ha haa...
Well, This SynEdit Fold Color is only works fine with TSynHighlighterPasSyn.
To make this useful for any other SynHighlighter,
i think we need to add some nice feature to TSynCustomFoldHighlighter
Yep, some code needs to be factored up from pas to the base class.
It's crucial feature
agreed, and I try to allocate as much of my time as I can.
Thanks you!
----
But the position of 'begin'~'end' (or '{' and '}' in java/c) is
not for drawing vertical purpose
only.
Another reason we need it (knowing their coordinate) is
also for drawing that pair in same color as vertical lines.
and in SynMarkup, drawing text in nested color require the position of those elements.
____
My bottom line is: how to make Lazarus FoldHL (Demo) multi level color folding with my SynMarkup class,
by a little effort.
----
My next plan is to draw horizontal dotted line when the left position of begin & end is horizontally different.
But, before do that, I should able to detect the deferential between begin & end, from up to bottom
I think the easiest way is when HL puts this info on StartCodeFoldBlock & EndCodeFoldBlock.
But, Maybe it couldn't be done automagically, because each HL has different way to parse, hence different possibility of when to callStartCodeFoldBlock & EndCodeFoldBlock (can't make sure if a new token has already stored or not yet). Hence, the TSynCustomFoldHighlighter couldn't make sure where the token starts nor when it ends.
So, maybe giving the each HL a chance to tell TSynCustomFoldHighlighter of where is the opening fold & closing fold located, is perfect solution.
When the open~close token attached to a range, we can easily detect the 'end' coordinate when drawing the row of 'begin'.
procedure TSynDemoHlFold.Next;
begin
inherited Next;
if (copy(FLineText, FTokenPos, FTokenEnd - FTokenPos) = '-(-') then
begin
StartCodeFoldBlock(nil);
// store the opening fold bracket after push / attached new child-area
StartCodeFoldToken( FTokenPos, FTokenEnd ); // if level increased
end;
if (copy(FLineText, FTokenPos, FTokenEnd - FTokenPos) = '-)-') then
begin
// put the closing fold bracket before pop / detached, back to parent work-area
EndCodeFoldToken( FTokenPos, FTokenEnd ); // level decreasing.
EndCodeFoldBlock;(
end;
end;