You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 22, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Dec 22, 2023. It is now read-only.
Save Folding state to a temporary file so that the folding can be rebuilt when the file.is loaded again #508
I am using scintilla to load .c files and want to save the states of the folded lines.
I can do this successfully with markers using line.MarkerGet(); and line.MarkerAddSet().
What are the best folding values to save this way ?
I also found that the folding state needs a delay between loading the TextArea.Text and calling TextArea.Lines[1].ToggleFold();
If this is called straight away, it does not work, thus:
Peter, thanks for your info, and I can get this working.
I did have to have a scintilla.Update() in between loading scintilla.Text and loading the folding state though which causes an annoying flicker when the windows is first displayed.
What you have provided below is quite new to me, what is the best place to learn this type of operation ?
FoldingState = string.Join(";", scintilla.Lines.Where(f => !f.Expanded).Select(f => f.Index).ToArray());
I see in this example, it is saving the state for only lines that are folded,, can it be used to save both a line index and MarkerGet() for example ?
The resulting "save" string would in this case be like this from a small Json file with folding: 0|Circle|True;1|Circle|True;2|Circle|True;3|Circle|True;4|Circle|True;5|Circle|True;6|Circle|True;7|Circle|True;8|Circle|True;9|Circle|True;10|Circle|True;11|Circle|True;12|Circle|False;13|Circle|True;14|Circle|True;15|Circle|True;16|Circle|False;17|Circle|True;18|Circle|True;19|Circle|True;20|Circle|True;21|Circle|True;22|Circle|True;23|Circle|True;24|Circle|True;25|BoxPlusConnected|True;26|BoxMinusConnected|True;27|TCorner|True;28|LCorner|True;29|VLine|True;30|BoxPlus|True;31|BoxMinus|True
C# Corner seems to have some samples of how to learn LINQ.
For the flickering part I would need a small sample to try to fix it - no promises though 🙂
Activity
VPKSoft commentedon Mar 25, 2021
For a quick test, this code seems to do the trick:
BTW, the idea is good, perhaps this should be included in the package 👍
Added helper methods for state saving, see: jacobslusser/ScintillaNET…
intech-paul commentedon Mar 26, 2021
Peter, thanks for your info, and I can get this working.
I did have to have a scintilla.Update() in between loading scintilla.Text and loading the folding state though which causes an annoying flicker when the windows is first displayed.
What you have provided below is quite new to me, what is the best place to learn this type of operation ?
FoldingState = string.Join(";", scintilla.Lines.Where(f => !f.Expanded).Select(f => f.Index).ToArray());
I see in this example, it is saving the state for only lines that are folded,, can it be used to save both a line index and MarkerGet() for example ?
VPKSoft commentedon Mar 26, 2021
Hi,

The syntax is LINQ with Lambda expressions:
The
f => f...here is an instance of a single line in Scintilla control:The code:
The resulting "save" string would in this case be like this from a small Json file with folding:
0|Circle|True;1|Circle|True;2|Circle|True;3|Circle|True;4|Circle|True;5|Circle|True;6|Circle|True;7|Circle|True;8|Circle|True;9|Circle|True;10|Circle|True;11|Circle|True;12|Circle|False;13|Circle|True;14|Circle|True;15|Circle|True;16|Circle|False;17|Circle|True;18|Circle|True;19|Circle|True;20|Circle|True;21|Circle|True;22|Circle|True;23|Circle|True;24|Circle|True;25|BoxPlusConnected|True;26|BoxMinusConnected|True;27|TCorner|True;28|LCorner|True;29|VLine|True;30|BoxPlus|True;31|BoxMinus|TrueC# Corner seems to have some samples of how to learn LINQ.
For the flickering part I would need a small sample to try to fix it - no promises though 🙂