private void rtb_TextChanged(object sender, EventArgs e) { if (rtb._ignore) { return; } int p0 = rtb.SelectionStart; int p1 = rtb.SelectionLength; string text = Path.GetFileName(CurrPath ?? _new) + (IsChanged ? "*" : ""); if (Text.TrimEnd() != text) { Text = text; } rtb._Paint = false; rtb.SuspendLayout(); int ln1 = rtb.GetLineFromCharIndex((prevSel < rtb.SelectionStart) ? prevSel : rtb.SelectionStart); int ln2 = rtb.GetLineFromCharIndex((prevSel + prevLen > rtb.SelectionStart + rtb.SelectionLength) ? prevSel + prevLen : rtb.SelectionStart + rtb.SelectionLength); for (int l = ln1; l <= ln2; l++) { Highlighter.Highlight(rtb, l); } rtb._Paint = true; rtb.ResumeLayout(); rtb.SelectionStart = p0; rtb.SelectionLength = p1; pLineNum.Invalidate(); }
public void Higlight(IHighlighter h) { UseWaitCursor = true; Highlighter = h; h.Highlight(rtb); UseWaitCursor = false; }
/// <summary> /// Formats and Highlights the text of a block. /// </summary> private void FormatBlock(InnerTextBlock currentBlock, InnerTextBlock previousBlock) { currentBlock.FormattedText = GetFormattedText(currentBlock.RawText); if (CurrentHighlighter != null) { var previousCode = previousBlock?.Code ?? -1; currentBlock.Code = CurrentHighlighter.Highlight(currentBlock.FormattedText, previousCode); } }
private void FileOpen(string path) { Cache = File.ReadAllText(path); Highlighter = AutoHighlight(Path.GetExtension(path)); rtb.TextChanged -= rtb_TextChanged; rtb.Text = Cache; Highlighter.Highlight(rtb); rtb.TextChanged += rtb_TextChanged; Text = Path.GetFileName(path); }
/// <summary> /// Formats and Highlights the text of a block. /// </summary> private void FormatBlock(InnerTextBlock currentBlock, InnerTextBlock previousBlock) { currentBlock.FormattedText = GetFormattedText(currentBlock.RawText); if (CurrentHighlighter != null) { ThreadPool.QueueUserWorkItem(p => { int previousCode = previousBlock != null ? previousBlock.Code : -1; currentBlock.Code = CurrentHighlighter.Highlight(currentBlock.FormattedText, previousCode); }); } }
/// <summary> /// Formats and Highlights the text of a block. /// </summary> private void FormatBlock(InnerTextBlock currentBlock, DpiScale dpi) { currentBlock.FormattedText = GetFormattedText(currentBlock.RawText, dpi); if (CurrentHighlighter != null) { ThreadPool.QueueUserWorkItem(p => { CurrentHighlighter.Highlight(currentBlock.FormattedText); currentBlock.Code = -1; }); } }
public void EnableHighlight() { myHighlighter?.Highlight(); }