コード例 #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //For SciLexer.dll, seek out my modified Scintilla source on GitHub. I modified BraceMatch() to ignore Styling.
            //The original Scintilla version of BraceMatch() takes Styling into account. Why?
            //At first, in this project, it looks like it doesn't work.  But, it does.  You have to mess around with it and all the sudden they all properly highlight.
            //I can provide a screenshot of a "real" app, where you can see it works right off the bat.  I'll try to figure out the difference between that project and this project.
            Scintilla.SetModulePath("SciLexer.dll"); //Comment this line out

            sc.CaretStyle = CaretStyle.Block;

            sc.Lexer = Lexer.Container;

            sc.StyleResetDefault();
            sc.Styles[Style.Default].BackColor = IntToColor(0x1E1E1E);
            sc.Styles[Style.Default].ForeColor = IntToColor(0xEFEAEF);
            sc.StyleClearAll();

            //Ugly Test Colors
            sc.Styles[Style.LineNumber].ForeColor                    = sc.CaretForeColor = IntToColor(0xEFEAEF);
            sc.Styles[CSharpLexer.StyleDefault].ForeColor            = IntToColor(0xEFEAEF);
            sc.Styles[CSharpLexer.StyleKeyword].ForeColor            = IntToColor(0x35aec6);
            sc.Styles[CSharpLexer.StyleContainerProcedure].ForeColor = Color.HotPink;
            sc.Styles[CSharpLexer.StyleProcedureContainer].ForeColor =
                sc.Styles[CSharpLexer.StyleContextual].ForeColor     = IntToColor(0xb4ceaf);
            sc.Styles[CSharpLexer.StyleIdentifier].ForeColor         = IntToColor(0xEFEAEF);
            sc.Styles[CSharpLexer.StyleNumber].ForeColor             = Color.Purple;
            sc.Styles[CSharpLexer.StyleString].ForeColor             = Color.Red;
            sc.Styles[CSharpLexer.StyleComment].ForeColor            = Color.Orange;
            sc.Styles[CSharpLexer.StyleProcedure].ForeColor          = IntToColor(0x3ac190);
            sc.Styles[CSharpLexer.StyleVerbatim].ForeColor           = Color.YellowGreen;
            sc.Styles[CSharpLexer.StylePreprocessor].ForeColor       = Color.DarkSlateGray;
            sc.Styles[CSharpLexer.StyleEscapeSequence].ForeColor     = Color.Yellow;
            sc.Styles[CSharpLexer.StyleOperator].ForeColor           = Color.HotPink;
            sc.Styles[CSharpLexer.StyleBraces].ForeColor             = Color.GreenYellow;
            sc.Styles[CSharpLexer.StyleError].ForeColor              = Color.DarkRed;
            sc.Styles[CSharpLexer.StyleUser].ForeColor               = Color.Olive;
            sc.Styles[CSharpLexer.StyleMultiIdentifier].ForeColor    = Color.DeepPink;
            sc.Styles[CSharpLexer.StyleQuotedString].ForeColor       = Color.Yellow;

            CSharpLexer.Init_Lexer(sc);
            CSharpLexer.SetKeyWords("abstract add as ascending async await base bool break by byte case catch char checked class const continue decimal default delegate descending do double dynamic else enum equals explicit extern false finally fixed float for foreach from get global global goto goto group if implicit in int interface internal into is join let lock long namespace new null object on operator orderby out override params partial private protected public readonly ref remove return sbyte sealed select set short sizeof stackalloc static string struct switch this throw true try typeof uint ulong unchecked unsafe ushort using value var virtual void volatile where while yield",
                                    inUserKeywords: "Goblin Hammer", inMultiStringKeywords: "New York,New Jersey", AutoFillContextual: true
                                    );

            sc.UpdateUI += (s, ue) =>
            {
                label3.Text = $"{sc.CurrentLine + 1}";
                label4.Text = $"{sc.CurrentPosition + 1}";
                label5.Text = $"{(sc.Overtype ? "OVR" : "INS")}";
            };
        }