/// <summary> /// Initializes a new instance of the <see cref="AdornmentTagger" /> class. /// </summary> AdornmentTagger(ITagAggregator <TagData> dataTagger, AdornmentTaggerScope scope) { this.scope = scope; snapshot = view.TextBuffer.CurrentSnapshot; view.LayoutChanged += HandleLayoutChanged; view.TextBuffer.Changed += HandleBufferChanged; this.dataTagger = dataTagger; this.dataTagger.TagsChanged += HandleDataTagsChanged; }
/// <summary> /// Determines whether [is intersect with disabled spans] [the specified scope]. /// </summary> public static bool IsIntersectWithDisabledSpans(AdornmentTaggerScope scope, SnapshotSpan span) { if (scope.DisabledSnapshotSpans.Any(x => IntersectsWith(x, span))) { return(true); } if (scope.EditedSpans != null) { if (scope.EditedSpans.Any(x => IntersectsWith(x, span))) { return(true); } } return(false); }
/// <summary> /// Creates a tag provider for the specified view and buffer. /// </summary> public ITagger <T> CreateTagger <T>(ITextView textView, ITextBuffer buffer) where T : ITag { Trace(nameof(CreateTagger)); if (textView == null) { throw new ArgumentNullException("textView"); } if (buffer == null) { throw new ArgumentNullException("buffer"); } if (buffer != textView.TextBuffer) { return(null); } var textBlockStyler = MyUtil.GetTextBlockStyler(FormatMapService.GetEditorFormatMap(textView)); // FormatMapService.GetEditorFormatMap("text").GetProperties("Comment")["ForegroundColor"] var scope = new AdornmentTaggerScope { TextBlockStyler = textBlockStyler, WpfTextView = (IWpfTextView)textView }; ITagAggregator <TagData> CreateTagAggregator() { AdornmentTagger.scopeStatic = scope; var value = BufferTagAggregatorFactoryService.CreateTagAggregator <TagData>(textView.TextBuffer); AdornmentTagger.scopeStatic = null; return(value); } return(AdornmentTagger.GetTagger(new Lazy <ITagAggregator <TagData> >(CreateTagAggregator), scope) as ITagger <T>); }
/// <summary> /// Initializes a new instance of the <see cref="Tagger" /> class. /// </summary> public Tagger(ITextBuffer buffer) { buffer.Changed += (sender, args) => HandleBufferChanged(args); scope = AdornmentTagger.scopeStatic ?? throw new ArgumentNullException(nameof(AdornmentTagger.scopeStatic)); }
/// <summary> /// Gets the tagger. /// </summary> internal static ITagger <IntraTextAdornmentTag> GetTagger(Lazy <ITagAggregator <TagData> > tagger, AdornmentTaggerScope scope) { return(scope.WpfTextView.Properties.GetOrCreateSingletonProperty(() => new AdornmentTagger(tagger.Value, scope))); }