示例#1
0
        private void setStyle(ScintillaNET.Scintilla scintilla)
        {
            // Reset the styles
            scintilla.StyleResetDefault();
            scintilla.Styles[ScintillaNET.Style.Default].Font = "Consolas";
            scintilla.Styles[ScintillaNET.Style.Default].Size = 10;
            scintilla.StyleClearAll();

            // Show line numbers
            scintilla.Margins[0].Width = 20;

            // Enable folding
            scintilla.SetProperty("fold", "1");
            scintilla.SetProperty("fold.compact", "1");
            scintilla.SetProperty("fold.html", "1");

            // Use Margin 2 for fold markers
            scintilla.Margins[2].Type      = ScintillaNET.MarginType.Symbol;
            scintilla.Margins[2].Mask      = ScintillaNET.Marker.MaskFolders;
            scintilla.Margins[2].Sensitive = true;
            scintilla.Margins[2].Width     = 20;

            // Reset folder markers
            for (int i = ScintillaNET.Marker.FolderEnd; i <= ScintillaNET.Marker.FolderOpen; i++)
            {
                scintilla.Markers[i].SetForeColor(SystemColors.ControlLightLight);
                scintilla.Markers[i].SetBackColor(SystemColors.ControlDark);
            }

            // Style the folder markers
            scintilla.Markers[ScintillaNET.Marker.Folder].Symbol = ScintillaNET.MarkerSymbol.BoxPlus;
            scintilla.Markers[ScintillaNET.Marker.Folder].SetBackColor(SystemColors.ControlText);
            scintilla.Markers[ScintillaNET.Marker.FolderOpen].Symbol = ScintillaNET.MarkerSymbol.BoxMinus;
            scintilla.Markers[ScintillaNET.Marker.FolderEnd].Symbol  = ScintillaNET.MarkerSymbol.BoxPlusConnected;
            scintilla.Markers[ScintillaNET.Marker.FolderEnd].SetBackColor(SystemColors.ControlText);
            scintilla.Markers[ScintillaNET.Marker.FolderMidTail].Symbol = ScintillaNET.MarkerSymbol.TCorner;
            scintilla.Markers[ScintillaNET.Marker.FolderOpenMid].Symbol = ScintillaNET.MarkerSymbol.BoxMinusConnected;
            scintilla.Markers[ScintillaNET.Marker.FolderSub].Symbol     = ScintillaNET.MarkerSymbol.VLine;
            scintilla.Markers[ScintillaNET.Marker.FolderTail].Symbol    = ScintillaNET.MarkerSymbol.LCorner;

            // Enable automatic folding
            scintilla.AutomaticFold = ScintillaNET.AutomaticFold.Show | ScintillaNET.AutomaticFold.Click | ScintillaNET.AutomaticFold.Change;

            // Set the Styles
            scintilla.StyleResetDefault();
            // I like fixed font for XML
            scintilla.Styles[ScintillaNET.Style.Default].Font = "Courier";
            scintilla.Styles[ScintillaNET.Style.Default].Size = 10;
            scintilla.StyleClearAll();
            scintilla.Styles[ScintillaNET.Style.Xml.Attribute].ForeColor    = Color.Red;
            scintilla.Styles[ScintillaNET.Style.Xml.Entity].ForeColor       = Color.Red;
            scintilla.Styles[ScintillaNET.Style.Xml.Comment].ForeColor      = Color.Green;
            scintilla.Styles[ScintillaNET.Style.Xml.Tag].ForeColor          = Color.Blue;
            scintilla.Styles[ScintillaNET.Style.Xml.TagEnd].ForeColor       = Color.Blue;
            scintilla.Styles[ScintillaNET.Style.Xml.DoubleString].ForeColor = Color.DeepPink;
            scintilla.Styles[ScintillaNET.Style.Xml.SingleString].ForeColor = Color.DeepPink;
        }
示例#2
0
        private void InitSyntaxColoring()
        {
            // Configure the default style
            TextArea.StyleResetDefault();
            TextArea.Styles[ScintillaNET.Style.Default].Font      = "Consolas";
            TextArea.Styles[ScintillaNET.Style.Default].Size      = 10;
            TextArea.Styles[ScintillaNET.Style.Default].BackColor = IntToColor(0x212121);
            TextArea.Styles[ScintillaNET.Style.Default].ForeColor = IntToColor(0xFFFFFF);
            TextArea.StyleClearAll();

            // Configure the CPP (C#) lexer styles
            TextArea.Styles[ScintillaNET.Style.Cpp.Identifier].ForeColor             = IntToColor(0xD0DAE2);
            TextArea.Styles[ScintillaNET.Style.Cpp.Comment].ForeColor                = IntToColor(0x0ba728);
            TextArea.Styles[ScintillaNET.Style.Cpp.CommentLine].ForeColor            = IntToColor(0x40BF57);
            TextArea.Styles[ScintillaNET.Style.Cpp.CommentDoc].ForeColor             = IntToColor(0x2FAE35);
            TextArea.Styles[ScintillaNET.Style.Cpp.Number].ForeColor                 = IntToColor(0xFFFF00);
            TextArea.Styles[ScintillaNET.Style.Cpp.String].ForeColor                 = IntToColor(0x07E8DB);
            TextArea.Styles[ScintillaNET.Style.Cpp.Character].ForeColor              = IntToColor(0xE95454);
            TextArea.Styles[ScintillaNET.Style.Cpp.Preprocessor].ForeColor           = IntToColor(0x8AAFEE);
            TextArea.Styles[ScintillaNET.Style.Cpp.Operator].ForeColor               = IntToColor(0xE0E0E0);
            TextArea.Styles[ScintillaNET.Style.Cpp.Regex].ForeColor                  = IntToColor(0xff00ff);
            TextArea.Styles[ScintillaNET.Style.Cpp.CommentLineDoc].ForeColor         = IntToColor(0x77A7DB);
            TextArea.Styles[ScintillaNET.Style.Cpp.Word].ForeColor                   = IntToColor(0x48A8EE);
            TextArea.Styles[ScintillaNET.Style.Cpp.Word2].ForeColor                  = IntToColor(0xF98906);
            TextArea.Styles[ScintillaNET.Style.Cpp.CommentDocKeyword].ForeColor      = IntToColor(0xB3D991);
            TextArea.Styles[ScintillaNET.Style.Cpp.CommentDocKeywordError].ForeColor = IntToColor(0xFF0000);
            TextArea.Styles[ScintillaNET.Style.Cpp.GlobalClass].ForeColor            = IntToColor(0x48A8EE);

            TextArea.Lexer = ScintillaNET.Lexer.Cpp;

            TextArea.SetKeywords(0, "class extends implements import interface new case do while else if for in switch throw get set function var try catch finally while with default break continue delete return each const namespace package include use is as instanceof typeof author copy default deprecated eventType example exampleText exception haxe inheritDoc internal link mtasc mxmlc param private return see serial serialData serialField since throws usage version langversion playerversion productversion dynamic private public partial static intrinsic internal native override protected AS3 final super this arguments null Infinity NaN undefined true false abstract as base bool break by byte case catch char checked class const continue decimal default delegate do double descending explicit event extern else enum false finally fixed float for foreach from goto group if implicit in int interface internal into is lock long new null namespace object operator out override orderby params private protected public readonly ref return switch struct sbyte sealed short sizeof stackalloc static string select this throw true try typeof uint ulong unchecked unsafe ushort using var virtual volatile void while where yield");
            TextArea.SetKeywords(1, "void Null ArgumentError arguments Array Boolean Class Date DefinitionError Error EvalError Function int Math Namespace Number Object RangeError ReferenceError RegExp SecurityError String SyntaxError TypeError uint XML XMLList Boolean Byte Char DateTime Decimal Double Int16 Int32 Int64 IntPtr SByte Single UInt16 UInt32 UInt64 UIntPtr Void Path File System Windows Forms ScintillaNET");
        }
示例#3
0
    public Form1()
    {
        InitializeComponent();
        var editor = new ScintillaNET.Scintilla {
            Dock = DockStyle.Fill,
        };

        this.Controls.Add(editor);
        editor.StyleResetDefault();
        editor.Styles[Style.Default].Font = "Consolas";
        editor.Styles[Style.Default].Size = 10;
        editor.StyleClearAll();
        editor.Styles[CustomLexer.StyleText].ForeColor   = Color.Black;
        editor.Styles[CustomLexer.StyleParens].ForeColor = Color.Red;
        editor.Lexer        = Lexer.Container;
        editor.StyleNeeded += scintilla_StyleNeeded;
    }