public TextViewDocumentHighlighter(HighlightingColorizer colorizer, TextView textView, TextDocument document, HighlightingRuleSet baseRuleSet) : base(document, baseRuleSet) { Debug.Assert(colorizer != null); Debug.Assert(textView != null); this.colorizer = colorizer; this.textView = textView; }
/// <inheritdoc/> protected override void ColorizeLine(DocumentLine line) { var sections = richTextModel.GetHighlightedSections(line.Offset, line.Length); foreach (HighlightedSection section in sections) { if (HighlightingColorizer.IsEmptyColor(section.Color)) { continue; } ChangeLinePart(section.Offset, section.Offset + section.Length, visualLineElement => HighlightingColorizer.ApplyColorToElement(visualLineElement, section.Color, CurrentContext)); } }
void OnSyntaxHighlightingChanged(IHighlightingDefinition newValue) { if (colorizer != null) { this.TextArea.TextView.LineTransformers.Remove(colorizer); colorizer = null; } if (newValue != null) { TextView textView = this.TextArea.TextView; colorizer = new HighlightingColorizer(textView, newValue.MainRuleSet); textView.LineTransformers.Insert(0, colorizer); } }
void UpdatePreview() { XshdSyntaxDefinition xshd = (XshdSyntaxDefinition)languageComboBox.SelectedItem; if (xshd != null) { var customizationsForCurrentLanguage = customizationList.Where(c => c.Language == null || c.Language == xshd.Name); CustomizingHighlighter.ApplyCustomizationsToDefaultElements(textEditor, customizationsForCurrentLanguage); ApplyToRendering(textEditor, customizationsForCurrentLanguage); var item = (IHighlightingItem)listBox.SelectedItem; TextView textView = textEditor.TextArea.TextView; foldingManager.Clear(); textMarkerService.RemoveAll(m => true); textView.LineTransformers.Remove(colorizer); colorizer = null; if (item != null) { if (item.ParentDefinition != null) { var highlighter = new CustomizingHighlighter( new DocumentHighlighter(textView.Document, item.ParentDefinition), customizationsForCurrentLanguage ); colorizer = new HighlightingColorizer(highlighter); textView.LineTransformers.Add(colorizer); } textEditor.Select(0, 0); bracketHighlighter.SetHighlight(null); item.ShowExample(textEditor.TextArea); ITextMarker m = textMarkerService.TextMarkers.SingleOrDefault(); if (m != null && m.Tag != null) { ((Action<IHighlightingItem, ITextMarker>)m.Tag)(item, m); } } } }
public TextViewDocumentHighlighter(HighlightingColorizer colorizer, TextView textView, TextDocument document, HighlightingRuleSet baseRuleSet) : base(document, baseRuleSet) { Debug.Assert(colorizer != null); Debug.Assert(textView != null); this.colorizer = colorizer; this.textView = textView; }