Inheritance: System.EventArgs
Ejemplo n.º 1
0
        private void HighlightLine(HighlightLineEventArgs e, ImmutableArray <SpanInfo> spans)
        {
            var line = e.Line;

            foreach (var span in spans)
            {
                var start = line.Offset;
                var end   = line.Offset + line.Length;
                if (start > span.Span.EndPos || end < span.Span.StartPos)
                {
                    continue;
                }

                var spanClassId = span.SpanClassId;
                var color       = _highlightingStyles[spanClassId];
                var startOffset = Math.Max(line.Offset, span.Span.StartPos);
                var endOffset   = Math.Min(line.EndOffset, span.Span.EndPos);
                var section     = new HighlightedSection
                {
                    Offset = startOffset,
                    Length = endOffset - startOffset,
                    Color  = color
                };
                e.Sections.Add(section);
            }
        }
Ejemplo n.º 2
0
        private void textBox1_HighlightLine(object sender, HighlightLineEventArgs e)
        {
            if (_parseResult == null)
            {
                return;
            }

            try
            {
                var line  = e.Line;
                var spans = new HashSet <SpanInfo>();
                var timer = Stopwatch.StartNew();
                _parseResult.GetSpans(line.Offset, line.EndOffset, spans);
                _highlightingTimeSpan  = timer.Elapsed;
                _highlightingTime.Text = _highlightingTimeSpan.ToString();

                foreach (var span in spans)
                {
                    HighlightingColor color;
                    if (_highlightingStyles.TryGetValue(span.SpanClass.Name, out color))
                    {
                        var startOffset = Math.Max(line.Offset, span.Span.StartPos);
                        var endOffset   = Math.Min(line.EndOffset, span.Span.EndPos);
                        var section     = new HighlightedSection
                        {
                            Offset = startOffset,
                            Length = endOffset - startOffset,
                            Color  = color
                        };
                        e.Sections.Add(section);
                    }
                }
            }
            catch (Exception ex) { Debug.WriteLine(ex.GetType().Name + ":" + ex.Message); }
        }
Ejemplo n.º 3
0
 private void textBox1_HighlightLine(object sender, HighlightLineEventArgs e)
 {
     try
     {
         HighlightLine(e, _keywordsSpanInfos);
         HighlightLine(e, _symbolsSpanInfos);
     }
     catch (Exception ex) { Debug.WriteLine(ex.GetType().Name + ":" + ex.Message); }
 }
Ejemplo n.º 4
0
 private void textBox1_HighlightLine(object sender, HighlightLineEventArgs e)
 {
   try
   {
     HighlightLine(e, _keywordsSpanInfos);
     HighlightLine(e, _symbolsSpanInfos);
     HighlightLine(e, _interactiveSpanInfos);
   }
   catch (Exception ex) { Debug.WriteLine(ex.GetType().Name + ":" + ex.Message); }
 }
Ejemplo n.º 5
0
 private IList<HighlightedSection> OnHighlightLine(DocumentLine line)
 {
     var highlightLineHandler = HighlightLine;
       if (highlightLineHandler != null)
       {
     var args = new HighlightLineEventArgs(line);
     highlightLineHandler(this, args);
     return args.Sections;
       }
       return null;
 }
Ejemplo n.º 6
0
        private IList <HighlightedSection> OnHighlightLine(DocumentLine line)
        {
            var highlightLineHandler = HighlightLine;

            if (highlightLineHandler != null)
            {
                var args = new HighlightLineEventArgs(line);
                highlightLineHandler(this, args);
                return(args.Sections);
            }
            return(null);
        }
Ejemplo n.º 7
0
    private void HighlightLine(HighlightLineEventArgs e, ImmutableArray<SpanInfo> spans)
    {
      var line = e.Line;

      foreach (var span in spans)
      {
        var start = line.Offset;
        var end = line.Offset + line.Length;
        if (start > span.Span.EndPos || end < span.Span.StartPos)
          continue;

        var spanClassId = span.SpanClassId;
        var color = _highlightingStyles[spanClassId];
        var startOffset = Math.Max(line.Offset, span.Span.StartPos);
        var endOffset = Math.Min(line.EndOffset, span.Span.EndPos);
        var section = new HighlightedSection
        {
          Offset = startOffset,
          Length = endOffset - startOffset,
          Color = color
        };
        e.Sections.Add(section);
      }
    }
Ejemplo n.º 8
0
        private void textBox1_HighlightLine(object sender, HighlightLineEventArgs e)
        {
            if (_parseResult == null)
            return;

              try
              {
            var line = e.Line;
            var spans = new List<SpanInfo>();
            var timer = Stopwatch.StartNew();
            _parseResult.GetSpans(line.Offset, line.EndOffset, spans);
            _highlightingTimeSpan = timer.Elapsed;
            _highlightingTime.Text = _highlightingTimeSpan.ToString();

            foreach (var span in spans)
            {
              HighlightingColor color;
              if (_highlightingStyles.TryGetValue(span.SpanClass.Name, out color))
              {
            var startOffset = Math.Max(line.Offset, span.Span.StartPos);
            var endOffset = Math.Min(line.EndOffset, span.Span.EndPos);
            var section = new HighlightedSection
            {
              Offset = startOffset,
              Length = endOffset - startOffset,
              Color = color
            };
            e.Sections.Add(section);
              }
            }
              }
              catch (Exception ex) { Debug.WriteLine(ex.Message); }
        }
Ejemplo n.º 9
0
    private void textBox1_HighlightLine(object sender, HighlightLineEventArgs e)
    {
      if (_parseResult == null)
        return;

      try
      {
        var line = e.Line;
        var spans = new HashSet<SpanInfo>();
        _parseResult.GetSpans(line.Offset, line.EndOffset, spans);
        var astRoot = _astRoot;
        if (astRoot != null)
        {
          var visitor = new CollectSymbolsAstVisitor(new NSpan(line.Offset, line.EndOffset));
          astRoot.Accept(visitor);
          foreach (var spanInfo in visitor.SpanInfos)
            spans.Add(spanInfo);
        }

        foreach (var span in spans)
        {
          HighlightingColor color;
          if (!_highlightingStyles.TryGetValue(span.SpanClass.FullName, out color))
          {
            color = MakeHighlightingColor(span.SpanClass);
            _highlightingStyles.Add(span.SpanClass.FullName, color);
          }
          var startOffset = Math.Max(line.Offset, span.Span.StartPos);
          var endOffset = Math.Min(line.EndOffset, span.Span.EndPos);
          var section = new HighlightedSection
          {
            Offset = startOffset,
            Length = endOffset - startOffset,
            Color = color
          };
          e.Sections.Add(section);
        }
      }
      catch (Exception ex) { Debug.WriteLine(ex.GetType().Name + ":" + ex.Message); }
    }