Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
 public void Higlight(IHighlighter h)
 {
     UseWaitCursor = true;
     Highlighter   = h;
     h.Highlight(rtb);
     UseWaitCursor = false;
 }
Ejemplo n.º 3
0
 /// <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);
     }
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
 /// <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);
         });
     }
 }
Ejemplo n.º 6
0
 /// <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;
         });
     }
 }
Ejemplo n.º 7
0
 public void EnableHighlight()
 {
     myHighlighter?.Highlight();
 }