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