[Solved] How to do fold / unfold all actions?

Topics: User Forum
Jun 1, 2013 at 10:19 AM
Hi,
I'm trying to add Fold All - Unfold All actions to my project but i have no idea how to do it.
I'm using "vb" lexer name and looks like folding rules of vb lexer are just about tab and spaces at the line beginings.
<frame> 0 standing
   pic: 0  state: 0  wait: 5  next: 1  dvx: 0  dvy: 0  dvz: 0  centerx: 39
   bpoint:
      x: 43  y: 38
   bpoint_end:
   wpoint:
      kind: 1  x: 23  y: 46  weaponact: 35  attacking: 0  cover: 0  dvx: 0
   wpoint_end:
   bdy:
      kind: 0  x: 21  y: 18  w: 43  h: 62
   bdy_end:
<frame_end>

<frame> 1 standing
   pic: 1  state: 0  wait: 5  next: 2  dvx: 0  dvy: 0  dvz: 0  centerx: 39
   bpoint:
      x: 43  y: 38
   bpoint_end:
   wpoint:
      kind: 1  x: 22  y: 47  weaponact: 35  attacking: 0  cover: 0  dvx: 0
   wpoint_end:
   bdy:
      kind: 0  x: 21  y: 18  w: 43  h: 62
   bdy_end:
<frame_end>
(...)
I have a similar document like this and i have to fold all "frame"s when a button is pressed or i can say i have to fold lines which contain <frame> tag. Folding is already useful but what i want to do is to fold all / unfold all...

Thanks in Advance!..
Jul 3, 2013 at 2:43 PM
I found a solution:
void FoldAll(string target)
{
    foreach(ScintillaNET.Line linear in ActiveDocument.Scintilla.Lines)
    {
        if(linear.IsFoldPoint && linear.FoldExpanded && linear.Text.Contains(target))
        {
            linear.ToggleFoldExpanded();
        }
    }
}

void UnfoldAll(string target)
{
    foreach(ScintillaNET.Line linear in ActiveDocument.Scintilla.Lines)
    {
        if(linear.IsFoldPoint && !linear.FoldExpanded && linear.Text.Contains(target))
        {
            linear.ToggleFoldExpanded();
        }
    }
}