示例#1
0
        public void Highlight(FlickerFreeRichEditTextBox box, int line)
        {
            if (line < 0 || line >= box.Lines.Length)
            {
                return;
            }

            box.Select(box.GetFirstCharIndexFromLine(line), box.Lines[line].Length);
            box.SelectionColor = Color.Black;

            Match m;

            foreach (Pair <Regex, Color> rc in Regexes)
            {
                m = rc.t.Match(box.Lines[line]);
                while (m.Success)
                {
                    box.Select(box.GetFirstCharIndexFromLine(line) + m.Index, m.Length);
                    if (box.SelectionColor == Color.Black)
                    {
                        box.SelectionColor = rc.u;
                    }
                    m = m.NextMatch();
                }
            }
        }
示例#2
0
        public void Highlight(FlickerFreeRichEditTextBox box)
        {
            box._ignore = true;
            box._Paint  = false;
            box.SuspendLayout();
            box.SuspendDrawing();

            int p0 = box.SelectionStart;
            int p1 = box.SelectionLength;

            box.SelectAll();
            box.SelectionColor = Color.Black;

            if (_context != null)
            {
                string txt = box.Text;
                try
                {
                    ScriptChecker checker = new ScriptChecker(txt, null);
                    SortedList <Pair <int, int>, LintType> lints = checker.Lint(_context);
                    string[] lines = box.Lines;
                    if (lines.Length > 0)
                    {
                        box.Rtf = MakeRTF(lines, lints);

                        /*
                         * LinterType prev = LinterType.NONE;
                         * LinterStep current = new LinterStep(0, 0, LinterType.NONE);
                         * foreach (LinterStep lint in lints)
                         * {
                         * if (current.Line <= lint.Line && current.Position < lint.Position)
                         * {
                         *  if (current.Lint != prev)
                         *  {
                         *    box.Select(box.GetFirstCharIndexFromLine(current.Line - 1) + current.Position, lint.Position - current.Position);
                         *    if (box.SelectionColor == Color.Black)
                         *      box.SelectionColor = LintColors[current.Lint];
                         *  }
                         * }
                         * prev = current.Lint;
                         * current = lint;
                         * }
                         */
                    }
                }
                catch
                {
                    box.Text = txt;
                }
            }

            box.SelectionStart  = p0;
            box.SelectionLength = p1;

            box._Paint = true;
            box.ResumeLayout();
            box.ResumeDrawing();
            box._ignore = false;
        }
示例#3
0
        public virtual void Highlight(FlickerFreeRichEditTextBox box)
        {
            box._ignore = true;
            box._Paint  = false;
            box.Enabled = false;
            box.SuspendLayout();
            box.SuspendDrawing();

            int p0 = box.SelectionStart;
            int p1 = box.SelectionLength;

            box.SelectAll();
            box.SelectionColor = Color.Black;

            HighlighterInfo[] h = new HighlighterInfo[box.Lines.Length];
            for (int i = 0; i < box.Lines.Length; i++)
            {
                h[i] = new HighlighterInfo()
                {
                    Line = i, LineText = box.Lines[i]
                }
            }
            ;

            Parallel.ForEach(h, Calc);

            while (Result.TryDequeue(out Quad <int, int, int, Color> r))
            {
                box.Select(box.GetFirstCharIndexFromLine(r.t) + r.u, r.v);
                if (box.SelectionColor == Color.Black)
                {
                    box.SelectionColor = r.w;
                }
            }

            box.SelectionStart  = p0;
            box.SelectionLength = p1;

            box._Paint = true;
            box.ResumeLayout();
            box.ResumeDrawing();
            box._ignore = false;
            box.Enabled = true;
            box.ClearUndo();
        }
示例#4
0
        public void Highlight(FlickerFreeRichEditTextBox box)
        {
            box._ignore = true;
            box._Paint  = false;
            box.SuspendLayout();

            int p0 = box.SelectionStart;
            int p1 = box.SelectionLength;

            box.SelectAll();
            box.SelectionColor = Color.Black;

            box.SelectionStart  = p0;
            box.SelectionLength = p1;

            box._Paint = true;
            box.ResumeLayout();
            box._ignore = false;
        }
示例#5
0
 public void Highlight(FlickerFreeRichEditTextBox box, int line)
 {
 }