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); } } }
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); //} } }
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)); }