예제 #1
0
        private void Style(int sp, int ep, bool norepeat)
        {
            var text = UseUnicodeLexing ? GetTextRange(sp, ep) : GetTextRangeUnicode(sp, ep);//GetText();
            var e    = new StyleNeededEventArgs(sp, ep, 0, text);

            var h = StyleNeeded;

            if (h != null)
            {
                h(this, e);
            }

            Ref.Send(Sci.SCI_STARTSTYLING, sp, Sci.STYLE_MASK);
            Ref.Send(Sci.SCI_SETSTYLING, ep - sp, Sci.STYLE_DEFAULT);
            var tok  = default(StyledToken);
            var dict = new Dictionary <Int32, Int32>();

            foreach (var i in e.Items)
            {
                var pos = i.Position + sp;

                //if (pos + i.Length < sp || pos > ep)
                //    continue;

                var style = (Int32)i.StyleKey;
                Ref.Send(Sci.SCI_STARTSTYLING, pos, Sci.STYLE_MASK);
                Ref.Send(Sci.SCI_SETSTYLING, i.Length, style);

                var regStart = Ref.Send(Sci.SCI_LINEFROMPOSITION, pos);
                var regEnd   = Ref.Send(Sci.SCI_LINEFROMPOSITION, pos + i.Length);
                var st       = i.StyleKey == TextStyle.MultilineStyle1 ||
                               i.StyleKey == TextStyle.MultilineStyle2 ||
                               i.StyleKey == TextStyle.MultilineStyle3 ||
                               i.StyleKey == TextStyle.MultilineStyle4 ? 1 : 0;

                for (var l = regStart; l < regEnd + 1; l++)
                {
                    if (st == 1 || !dict.ContainsKey(l))
                    {
                        Ref.Send(Sci.SCI_SETLINESTATE, l, st);

                        if (st == 1 && !dict.ContainsKey(l))
                        {
                            dict.Add(l, l);
                        }
                    }
                }

                tok = i;
            }

            //if (!norepeat && (tok.StyleKey == TextStyle.VerbatimString || tok.StyleKey == TextStyle.MultilineComment))
            //{
            //    var text = GetLineFromPosition(sp);
            //    Style(sp, GetPositionFromLine(text + LinesOnScreen), true);
            //}
        }
예제 #2
0
        private void Lex(object sender, StyleNeededEventArgs e)
        {
            var lexer = new OutputLexer();
            var tokens = lexer.Parse(e.Text).ToList();

            if (!styling)
                tokens = tokens.Where(t => t.StyleKey == TextStyle.Invisible).ToList();

            tokens.ForEach(t => e.AddStyleItem(t.Position, t.Length, t.StyleKey));
        }
예제 #3
0
        private void Lex(object sender, StyleNeededEventArgs e)
        {
            if (!Styling)
                return;

            e.AddStyleItem(sci.GetPositionFromLine(0), sci.GetLineEndColumn(0), TextStyle.Style1);

            if (sci.ReadOnly && sci.LineCount > 2)
                e.AddStyleItem(sci.GetPositionFromLine(sci.LineCount - 2), 100, TextStyle.Style1);
        }
예제 #4
0
        private void Style(int sp, int ep, bool norepeat)
        {
            var text = UseUnicodeLexing ? GetTextRange(sp, ep) : GetTextRangeUnicode(sp, ep);//GetText();
            var e = new StyleNeededEventArgs(sp, ep, 0, text);

            var h = StyleNeeded;

            if (h != null)
                h(this, e);

            Ref.Send(Sci.SCI_STARTSTYLING, sp, Sci.STYLE_MASK);
            Ref.Send(Sci.SCI_SETSTYLING, ep - sp, Sci.STYLE_DEFAULT);
            var tok = default(StyledToken);
            var dict = new Dictionary<Int32,Int32>();

            foreach (var i in e.Items)
            {
                var pos = i.Position + sp;

                //if (pos + i.Length < sp || pos > ep)
                //    continue;

                var style = (Int32)i.StyleKey;
                Ref.Send(Sci.SCI_STARTSTYLING, pos, Sci.STYLE_MASK);
                Ref.Send(Sci.SCI_SETSTYLING, i.Length, style);

                var regStart = Ref.Send(Sci.SCI_LINEFROMPOSITION, pos);
                var regEnd = Ref.Send(Sci.SCI_LINEFROMPOSITION, pos + i.Length);
                var st = i.StyleKey == TextStyle.MultilineStyle1
                    || i.StyleKey == TextStyle.MultilineStyle2
                    || i.StyleKey == TextStyle.MultilineStyle3
                    || i.StyleKey == TextStyle.MultilineStyle4 ? 1 : 0;

                for (var l = regStart; l < regEnd + 1; l++)
                {
                    if (st == 1 || !dict.ContainsKey(l))
                    {
                        Ref.Send(Sci.SCI_SETLINESTATE, l, st);

                        if (st == 1 && !dict.ContainsKey(l))
                            dict.Add(l, l);
                    }
                }

                tok = i;
            }

            //if (!norepeat && (tok.StyleKey == TextStyle.VerbatimString || tok.StyleKey == TextStyle.MultilineComment))
            //{
            //    var text = GetLineFromPosition(sp);
            //    Style(sp, GetPositionFromLine(text + LinesOnScreen), true);
            //}
        }