|
using System;
using System.Windows.Forms;
using FastColoredTextBoxNS;
using System.Text.RegularExpressions;
namespace Tester
{
public partial class CustomFoldingSample : Form
{
public CustomFoldingSample()
{
InitializeComponent();
fctb.OnTextChangedDelayed(fctb.Range);
}
private void fctb_TextChangedDelayed(object sender, TextChangedEventArgs e)
{
//delete all markers
fctb.Range.ClearFoldingMarkers();
var currentIndent = 0;
var lastNonEmptyLine = 0;
for (int i = 0; i < fctb.LinesCount; i++)
{
var line = fctb[i];
var spacesCount = line.StartSpacesCount;
if (spacesCount == line.Count) //empty line
continue;
if (currentIndent < spacesCount)
//append start folding marker
fctb[lastNonEmptyLine].FoldingStartMarker = "m" + currentIndent;
else
if (currentIndent > spacesCount)
//append end folding marker
fctb[lastNonEmptyLine].FoldingEndMarker = "m" + spacesCount;
currentIndent = spacesCount;
lastNonEmptyLine = i;
}
}
private void fctb_AutoIndentNeeded(object sender, AutoIndentEventArgs e)
{
//we assign this handler for disable AutoIndent by folding
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am Pavеl Tоrgаshоv, and I live in Kyiv, Ukraine.
I've been developing software since 1998.
Main activities: processing of large volumes of data, statistics, computer vision and graphics.