예제 #1
0
파일: SBDiff.cs 프로젝트: Blockguy24/SB-IDE
        private static void SetDiff()
        {
            TabItem    item1 = (TabItem)tabConstrol1.Items[tabConstrol1.SelectedIndex];
            SBDocument doc1  = (SBDocument)item1.Tag;
            TabItem    item2 = (TabItem)tabConstrol2.Items[tabConstrol2.SelectedIndex];
            SBDocument doc2  = (SBDocument)item2.Tag;

            Diff.Item[] items = Diff.DiffText(doc1.TextArea.Text, doc2.TextArea.Text, true, true, true);

            foreach (Diff.Item item in items)
            {
                Marker marker1 = doc1.TextArea.Markers[SBDocument.DELETED_MARKER];
                marker1.Symbol = MarkerSymbol.Background;
                marker1.SetBackColor(SBDocument.IntToColor(MainWindow.DELETED_HIGHLIGHT_COLOR));
                for (int i = item.StartA; i < item.StartA + item.deletedA; i++)
                {
                    doc1.TextArea.Lines[i].MarkerAdd(SBDocument.DELETED_MARKER);
                }
                Marker marker2 = doc2.TextArea.Markers[SBDocument.INSERTED_MARKER];
                marker2.Symbol = MarkerSymbol.Background;
                marker2.SetBackColor(SBDocument.IntToColor(MainWindow.INSERTED_HIGHLIGHT_COLOR));
                for (int i = item.StartB; i < item.StartB + item.insertedB; i++)
                {
                    doc2.TextArea.Lines[i].MarkerAdd(SBDocument.INSERTED_MARKER);
                }
            }
        }
예제 #2
0
        public SBContext(SBDocument sbDocument)
        {
            this.sbDocument = sbDocument;
            textArea        = sbDocument.TextArea;

            menuColors = SetColors();
            menuFonts  = SetFonts();
        }
예제 #3
0
        public SBLexer(SBDocument sbDocument, Scintilla textArea)
        {
            this.sbDocument = sbDocument;
            this.textArea   = textArea;

            if (false)
            {
                // Configuring the default style with properties
                // we have common to every lexer style saves time.
                textArea.StyleResetDefault();
                textArea.Styles[Style.Default].Font = "Consolas";
                textArea.Styles[Style.Default].Size = 40;
                textArea.StyleClearAll();

                // Configure the CPP (C#) lexer styles
                textArea.Styles[Style.Cpp.Default].ForeColor        = Color.Silver;
                textArea.Styles[Style.Cpp.Comment].ForeColor        = Color.FromArgb(0, 128, 0);     // Green
                textArea.Styles[Style.Cpp.CommentLine].ForeColor    = Color.FromArgb(0, 128, 0);     // Green
                textArea.Styles[Style.Cpp.CommentLineDoc].ForeColor = Color.FromArgb(128, 128, 128); // Gray
                textArea.Styles[Style.Cpp.Number].ForeColor         = Color.Olive;
                textArea.Styles[Style.Cpp.Word].ForeColor           = Color.Blue;
                textArea.Styles[Style.Cpp.Word2].ForeColor          = Color.Blue;
                textArea.Styles[Style.Cpp.String].ForeColor         = Color.FromArgb(163, 21, 21); // Red
                textArea.Styles[Style.Cpp.Character].ForeColor      = Color.FromArgb(163, 21, 21); // Red
                textArea.Styles[Style.Cpp.Verbatim].ForeColor       = Color.FromArgb(163, 21, 21); // Red
                textArea.Styles[Style.Cpp.StringEol].BackColor      = Color.Pink;
                textArea.Styles[Style.Cpp.Operator].ForeColor       = Color.Purple;
                textArea.Styles[Style.Cpp.Preprocessor].ForeColor   = Color.Maroon;
                textArea.Lexer = Lexer.Cpp;

                // Set the keywords
                textArea.SetKeywords(0, "abstract as base break case catch checked continue default delegate do else event explicit extern false finally fixed for foreach goto if implicit in interface internal is lock namespace new null object operator out override params private protected public readonly ref return sealed sizeof stackalloc switch this throw true try typeof unchecked unsafe using virtual while");
                textArea.SetKeywords(1, "bool byte char class const decimal double enum float int long sbyte short static string struct uint ulong ushort void");
            }

            // STYLING
            InitSyntaxColoring();
            InitAutoComplete();

            // EVENTS
            textArea.InsertCheck    += (this.OnInsertCheck);
            textArea.Insert         += (this.OnInsert);
            textArea.Delete         += (this.OnDelete);
            textArea.CharAdded      += (this.OnCharAdded);
            textArea.StyleNeeded    += OnStyleNeeded;
            textArea.TextChanged    += OnTextChanged;
            textArea.MouseDwellTime  = 100;
            textArea.DwellStart     += OnDwellStart;
            textArea.DwellEnd       += OnDwellEnd;
            textArea.AutoCSelection += OnAutoCSelection;
            textArea.AutoCCompleted += OnAutoCCompleted;
            textArea.UpdateUI       += OnUpdateUI;

            AutoCTimer          = new Timer();
            AutoCTimer.Enabled  = false;
            AutoCTimer.Interval = 100;
            AutoCTimer.Tick    += new EventHandler(AutoCTimerCallback);
        }
예제 #4
0
        public SBDebug(MainWindow mainWindow, SBInterop sbInterop, SBDocument sbDocument, bool debug)
        {
            this.mainWindow = mainWindow;
            this.sbInterop  = sbInterop;
            this.sbDocument = sbDocument;
            this.debug      = debug;

            threadTimer = new Timer(new TimerCallback(ThreadTimerCallback));
            threadTimer.Change(100, 100);

            ip = GetIP();
        }
예제 #5
0
        public void HighLight(string search)
        {
            LastHighLight = search;

            TextArea.IndicatorClearRange(0, TextArea.TextLength);

            if (search.Length > 0)
            {
                TextArea.Indicators[0].ForeColor = SBDocument.IntToColor(MainWindow.FIND_HIGHLIGHT_COLOR);
                TextArea.Indicators[0].Style     = IndicatorStyle.RoundBox;

                TextArea.TargetStart = 0;
                TextArea.TargetEnd   = TextArea.TextLength;
                TextArea.SearchFlags = MainWindow.searchFlags;
                while (TextArea.SearchInTarget(search) != -1)
                {
                    // Mark the search results with the current indicator
                    if (TextArea.TargetStart != TextArea.SelectionStart)
                    {
                        TextArea.IndicatorFillRange(TextArea.TargetStart, TextArea.TargetEnd - TextArea.TargetStart);
                    }

                    // Search the remainder of the document
                    int iEnd = TextArea.TargetEnd;
                    TextArea.TargetStart = iEnd;
                    if (TextArea.TargetStart != iEnd)
                    {
                        break;                               //No idea why this is necessary sometimes
                    }
                    TextArea.TargetEnd = TextArea.TextLength;
                }

                //RegexOptions caseSensitive = RegexOptions.IgnoreCase;
                //MatchCollection matches = Regex.Matches(TextArea.Text, search, caseSensitive);
                //foreach (Match match in matches)
                //{
                //    TextArea.IndicatorFillRange(match.Index, match.Length);
                //}
            }
        }
예제 #6
0
파일: SBDiff.cs 프로젝트: Blockguy24/SB-IDE
        private static void ClearDiff()
        {
            foreach (TabItem item in tabConstrol1.Items)
            {
                SBDocument doc = (SBDocument)item.Tag;
                foreach (Line line in doc.TextArea.Lines)
                {
                    line.MarkerDelete(SBDocument.DELETED_MARKER);
                    line.MarkerDelete(SBDocument.INSERTED_MARKER);
                }
            }

            foreach (TabItem item in tabConstrol2.Items)
            {
                SBDocument doc = (SBDocument)item.Tag;
                foreach (Line line in doc.TextArea.Lines)
                {
                    line.MarkerDelete(SBDocument.DELETED_MARKER);
                    line.MarkerDelete(SBDocument.INSERTED_MARKER);
                }
            }
        }
예제 #7
0
        private void InitSyntaxColoring()
        {
            Color foreColor = IntToColor(MainWindow.FORE_COLOR);
            Color backColor = IntToColor(MainWindow.BACK_COLOR);

            if (theme == 1)
            {
                foreColor = IntToColor(MainWindow.BACK_COLOR);
                backColor = IntToColor(MainWindow.FORE_COLOR);
            }

            // Configure the default style
            textArea.StyleResetDefault();
            //textArea.Styles[Style.CallTip].Font = "Consolas";
            //textArea.Styles[Style.CallTip].Size = 20;
            textArea.Styles[Style.Default].Font      = "Consolas";
            textArea.Styles[Style.Default].Size      = 10;
            textArea.Styles[Style.Default].BackColor = backColor;
            textArea.Styles[Style.Default].ForeColor = foreColor;
            textArea.CaretForeColor = foreColor;
            textArea.TabWidth       = MainWindow.indentSpaces;
            spaces = "";
            for (int i = 0; i < textArea.TabWidth; i++)
            {
                spaces += " ";
            }
            textArea.StyleClearAll();

            textArea.Styles[Style.LineNumber].ForeColor  = IntToColor(MainWindow.FORE_MARGIN_COLOR);
            textArea.Styles[Style.LineNumber].BackColor  = IntToColor(MainWindow.BACK_MARGIN_COLOR);
            textArea.Styles[Style.IndentGuide].ForeColor = IntToColor(MainWindow.FORE_FOLDING_COLOR);
            textArea.Styles[Style.IndentGuide].BackColor = IntToColor(MainWindow.BACK_FOLDING_COLOR);

            textArea.Styles[STYLE_SPACE].ForeColor      = foreColor;
            textArea.Styles[STYLE_COMMENT].ForeColor    = IntToColor(MainWindow.COMMENT_COLOR);
            textArea.Styles[STYLE_STRING].ForeColor     = IntToColor(MainWindow.STRING_COLOR);
            textArea.Styles[STYLE_OPERATOR].ForeColor   = IntToColor(MainWindow.OPERATOR_COLOR);
            textArea.Styles[STYLE_KEYWORD].ForeColor    = IntToColor(MainWindow.KEYWORD_COLOR);
            textArea.Styles[STYLE_OBJECT].ForeColor     = IntToColor(MainWindow.OBJECT_COLOR);
            textArea.Styles[STYLE_METHOD].ForeColor     = IntToColor(MainWindow.METHOD_COLOR);
            textArea.Styles[STYLE_SUBROUTINE].ForeColor = foreColor;
            textArea.Styles[STYLE_LABEL].ForeColor      = foreColor;
            textArea.Styles[STYLE_VARIABLE].ForeColor   = foreColor;
            textArea.Styles[STYLE_LITERAL].ForeColor    = IntToColor(MainWindow.LITERAL_COLOR);

            textArea.Styles[STYLE_COMMENT].Italic = true;
            textArea.Styles[STYLE_KEYWORD].Bold   = true;

            styles.Add(new SBStyle(STYLE_COMMENT, new Regex("^[\'].*")));
            styles.Add(new SBStyle(STYLE_STRING, new Regex("^[\"][^\"\\n]*[\"\\n]")));
            styles.Add(new SBStyle(STYLE_OPERATOR, new Regex("^[\\+|\\-|*|/|<|>|=]|^( AND | OR )")));
            styles.Add(new SBStyle(STYLE_SPACE, new Regex("^[\\s]")));
            styles.Add(new SBStyle(STYLE_KEYWORD, new Regex("^[\\W](" + keywords.ToUpper() + ")[\\W]")));
            styles.Add(new SBStyle(STYLE_OBJECT, new Regex("^[A-Za-z_][\\w]*[\\.][A-Za-z_][\\w]*")));
            styles.Add(new SBStyle(STYLE_SUBROUTINE, new Regex("^[A-Za-z_][\\w]*[(]")));
            styles.Add(new SBStyle(STYLE_LABEL, new Regex("^[A-Za-z_][\\w]*[ ]*[:]")));
            styles.Add(new SBStyle(STYLE_VARIABLE, new Regex("^[A-Za-z_][\\w]*[\\W]")));
            styles.Add(new SBStyle(STYLE_LITERAL, new Regex("^[-?\\d*\\.?\\d*]")));

            // Configure the lexer styles
            textArea.Lexer = Lexer.Container;

            const int SCI_CALLTIPSETBACK = 2205;
            const int SCI_CALLTIPSETFORE = 2206;

            textArea.DirectMessage(SCI_CALLTIPSETBACK, new IntPtr(ColorTranslator.ToWin32(SBDocument.IntToColor(MainWindow.BACK_CALLTIP_COLOR))), IntPtr.Zero);
            textArea.DirectMessage(SCI_CALLTIPSETFORE, new IntPtr(ColorTranslator.ToWin32(SBDocument.IntToColor(MainWindow.FORE_CALLTIP_COLOR))), IntPtr.Zero);
            textArea.CallTipSetForeHlt(SBDocument.IntToColor(MainWindow.HIGHLIGHT_CALLTIP_COLOR));
        }