示例#1
0
        private void InitCodeFolding()
        {
            TextArea.SetFoldMarginColor(true, IntToColor(BACK_COLOR));
            TextArea.SetFoldMarginHighlightColor(true, IntToColor(BACK_COLOR));

            // Enable code folding
            TextArea.SetProperty("fold", "1");
            TextArea.SetProperty("fold.compact", "1");

            // Configure a margin to display folding symbols
            TextArea.Margins[FOLDING_MARGIN].Type      = ScintillaNET.MarginType.Symbol;
            TextArea.Margins[FOLDING_MARGIN].Mask      = ScintillaNET.Marker.MaskFolders;
            TextArea.Margins[FOLDING_MARGIN].Sensitive = true;
            TextArea.Margins[FOLDING_MARGIN].Width     = 20;

            // Set colors for all folding markers
            for (int i = 25; i <= 31; i++)
            {
                TextArea.Markers[i].SetForeColor(IntToColor(BACK_COLOR)); // styles for [+] and [-]
                TextArea.Markers[i].SetBackColor(IntToColor(FORE_COLOR)); // styles for [+] and [-]
            }

            // Configure folding markers with respective symbols
            TextArea.Markers[ScintillaNET.Marker.Folder].Symbol        = CODEFOLDING_CIRCULAR ? ScintillaNET.MarkerSymbol.CirclePlus : ScintillaNET.MarkerSymbol.BoxPlus;
            TextArea.Markers[ScintillaNET.Marker.FolderOpen].Symbol    = CODEFOLDING_CIRCULAR ? ScintillaNET.MarkerSymbol.CircleMinus : ScintillaNET.MarkerSymbol.BoxMinus;
            TextArea.Markers[ScintillaNET.Marker.FolderEnd].Symbol     = CODEFOLDING_CIRCULAR ? ScintillaNET.MarkerSymbol.CirclePlusConnected : ScintillaNET.MarkerSymbol.BoxPlusConnected;
            TextArea.Markers[ScintillaNET.Marker.FolderMidTail].Symbol = ScintillaNET.MarkerSymbol.TCorner;
            TextArea.Markers[ScintillaNET.Marker.FolderOpenMid].Symbol = CODEFOLDING_CIRCULAR ? ScintillaNET.MarkerSymbol.CircleMinusConnected : ScintillaNET.MarkerSymbol.BoxMinusConnected;
            TextArea.Markers[ScintillaNET.Marker.FolderSub].Symbol     = ScintillaNET.MarkerSymbol.VLine;
            TextArea.Markers[ScintillaNET.Marker.FolderTail].Symbol    = ScintillaNET.MarkerSymbol.LCorner;

            // Enable automatic folding
            TextArea.AutomaticFold = (ScintillaNET.AutomaticFold.Show | ScintillaNET.AutomaticFold.Click | ScintillaNET.AutomaticFold.Change);
        }