//===================================================================== /// <summary> /// Creates a tag provider for the specified view and buffer /// </summary> /// <typeparam name="T">The tag type</typeparam> /// <param name="textView">The text view</param> /// <param name="buffer">The text buffer</param> /// <returns>The tag provider for the specified view and buffer or null if the buffer does not match the /// one in the view or spell checking as you type is disabled.</returns> public ITagger <T> CreateTagger <T>(ITextView textView, ITextBuffer buffer) where T : ITag { SpellingTagger spellingTagger = null; // Make sure we are only tagging the top buffer if (textView == null || buffer == null || spellingService == null || textView.TextBuffer != buffer) { return(null); } if (!textView.Properties.TryGetProperty(typeof(SpellingTagger), out spellingTagger)) { // Getting the configuration determines if spell checking is enabled for this file var config = spellingService.GetConfiguration(buffer); if (config != null) { var dictionary = spellingService.GetDictionary(buffer); if (dictionary != null) { var naturalTextAggregator = aggregatorFactory.CreateTagAggregator <INaturalTextTag>(textView, TagAggregatorOptions.MapByContentType); var urlAggregator = aggregatorFactory.CreateTagAggregator <IUrlTag>(textView); spellingTagger = new SpellingTagger(buffer, textView, naturalTextAggregator, urlAggregator, config, dictionary); textView.Properties[typeof(SpellingTagger)] = spellingTagger; } } } return(spellingTagger as ITagger <T>); }
//===================================================================== /// <summary> /// Creates a tag provider for the specified view and buffer /// </summary> /// <typeparam name="T">The tag type</typeparam> /// <param name="textView">The text view</param> /// <param name="buffer">The text buffer</param> /// <returns>The tag provider for the specified view and buffer or null if the buffer does not match the /// one in the view or spell checking as you type is disabled.</returns> public ITagger <T> CreateTagger <T>(ITextView textView, ITextBuffer buffer) where T : ITag { SpellingTagger spellingTagger; // Make sure we only tagging top buffer and only if wanted if (textView.TextBuffer != buffer || !SpellCheckerConfiguration.SpellCheckAsYouType || SpellCheckerConfiguration.IsExcludedByExtension(buffer.GetFilenameExtension())) { return(null); } if (textView.Properties.TryGetProperty(typeof(SpellingTagger), out spellingTagger)) { return(spellingTagger as ITagger <T>); } var dictionary = spellingDictionaryFactory.GetDictionary(buffer); if (dictionary == null) { return(null); } var naturalTextAggregator = aggregatorFactory.CreateTagAggregator <INaturalTextTag>(textView, TagAggregatorOptions.MapByContentType); var urlAggregator = aggregatorFactory.CreateTagAggregator <IUrlTag>(textView); spellingTagger = new SpellingTagger(buffer, textView, naturalTextAggregator, urlAggregator, dictionary); textView.Properties[typeof(SpellingTagger)] = spellingTagger; return(spellingTagger as ITagger <T>); }
public CommandState GetCommandState(NavigateToHighlightedReferenceCommandArgs args, Func <CommandState> nextHandler) { using (var tagAggregator = _tagAggregatorFactory.CreateTagAggregator <AbstractNavigatableReferenceHighlightingTag>(args.TextView)) { var tagUnderCursor = FindTagUnderCaret(tagAggregator, args.TextView); return(tagUnderCursor == null ? CommandState.Unavailable : CommandState.Available); } }
public CommandState GetCommandStateImpl(EditorCommandArgs args) { using (var tagAggregator = _tagAggregatorFactory.CreateTagAggregator <NavigableHighlightTag>(args.TextView)) { var tagUnderCursor = FindTagUnderCaret(tagAggregator, args.TextView); return(tagUnderCursor == null ? CommandState.Unavailable : CommandState.Available); } }
/// <summary> /// Initializes a new instance of the <see cref="DocumentMarkMargin" /> class for a given textView /// </summary> /// <param name="viewTagAggregatorFactoryService"></param> /// <param name="glyphFactoryProviders"></param> /// <param name="wpfTextViewHost"></param> /// <param name="sessionService"></param> /// <param name="settingsManager"></param> public DocumentMarkMargin( IViewTagAggregatorFactoryService viewTagAggregatorFactoryService, IEnumerable <Lazy <IGlyphFactoryProvider, IGlyphMetadata> > glyphFactoryProviders, IWpfTextViewHost wpfTextViewHost, ISessionService sessionService, ISettingsManager settingsManager) { _glyphFactoryProviders = glyphFactoryProviders; _wpfTextViewHost = wpfTextViewHost; _sessionService = sessionService; _settingsManager = settingsManager; try { Assumes.Present(_sessionService); Assumes.Present(_settingsManager); } catch (Exception ex) { Log.Error(ex, nameof(DocumentMarkMargin)); } _iconCanvas = new Canvas { Background = Brushes.Transparent }; _tagAggregator = viewTagAggregatorFactoryService.CreateTagAggregator <IGlyphTag>(_wpfTextViewHost.TextView); Width = DefaultMarginWidth; ClipToBounds = true; _glyphFactories = new Dictionary <Type, GlyphFactoryInfo>(); _childCanvases = Array.Empty <Canvas>(); Background = new SolidColorBrush(Colors.Transparent); _lineInfos = new Dictionary <object, LineInfo>(); TryInitialize(); }
public ITagger <T> CreateTagger <T>(ITextView textView, ITextBuffer buffer) where T : ITag { ITagAggregator <ClojureTokenTag> clojureTagAggregator = aggregatorFactory.CreateTagAggregator <ClojureTokenTag>(textView); return(new ClojureClassifier(buffer, clojureTagAggregator, ClassificationTypeRegistry) as ITagger <T>); }
public static SnapshotSpan?GetUri(IViewTagAggregatorFactoryService viewTagAggregatorFactoryService, ITextView textView, SnapshotPoint point) { if (viewTagAggregatorFactoryService == null) { throw new ArgumentNullException(nameof(viewTagAggregatorFactoryService)); } if (point.Snapshot == null) { throw new ArgumentException(); } var pointSpan = new SnapshotSpan(point.Snapshot, point.Position, 0); using (var tagAggregator = viewTagAggregatorFactoryService.CreateTagAggregator <IUriTag>(textView)) { foreach (var tagSpan in tagAggregator.GetTags(new SnapshotSpan(point.Snapshot, point.Position, 0))) { foreach (var span in tagSpan.Span.GetSpans(point.Snapshot)) { if (span.IntersectsWith(pointSpan)) { return(span); } } } } return(null); }
internal AdornmentManager( IThreadingContext threadingContext, IWpfTextView textView, IViewTagAggregatorFactoryService tagAggregatorFactoryService, IAsynchronousOperationListener asyncListener, string adornmentLayerName) { Contract.ThrowIfNull(threadingContext); Contract.ThrowIfNull(textView); Contract.ThrowIfNull(tagAggregatorFactoryService); Contract.ThrowIfNull(adornmentLayerName); Contract.ThrowIfNull(asyncListener); _threadingContext = threadingContext; _textView = textView; _adornmentLayer = textView.GetAdornmentLayer(adornmentLayerName); textView.LayoutChanged += OnLayoutChanged; _asyncListener = asyncListener; // If we are not on the UI thread, we are at race with Close, but we should be on UI thread Contract.ThrowIfFalse(textView.VisualElement.Dispatcher.CheckAccess()); textView.Closed += OnTextViewClosed; _tagAggregator = tagAggregatorFactoryService.CreateTagAggregator <T>(textView); _tagAggregator.TagsChanged += OnTagsChanged; }
public IWpfTextViewMargin?CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer) { var textView = wpfTextViewHost.TextView; var tagAggregator = _tagAggregatorFactoryService.CreateTagAggregator <InheritanceMarginTag>(textView); var editorFormatMap = _editorFormatMapService.GetEditorFormatMap(textView); var document = wpfTextViewHost.TextView.TextBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges(); if (document == null) { return(null); } var optionService = document.Project.Solution.Workspace.Services.GetRequiredService <IOptionService>(); var listener = _listenerProvider.GetListener(FeatureAttribute.InheritanceMargin); return(new InheritanceMarginViewMargin( textView, _threadingContext, _streamingFindUsagesPresenter, _operationExecutor, _classificationFormatMapService.GetClassificationFormatMap("tooltip"), _classificationTypeMap, tagAggregator, editorFormatMap, optionService, listener, document.Project.Language)); }
public PlayMouseProcessor(IWpfTextViewHost wpfTextViewHost, IViewTagAggregatorFactoryService viewTagAggregatorFactoryService) { _wpfTextViewHost = wpfTextViewHost; _viewTagAggregatorFactoryService = viewTagAggregatorFactoryService; _createTagAggregator = _viewTagAggregatorFactoryService.CreateTagAggregator <PlayGlyphTag>(_wpfTextViewHost.TextView); }
void UpdateLineSeparator() { if (wpfTextView.Options.IsLineSeparatorEnabled()) { Debug.Assert(tagAggregator == null); if (tagAggregator != null) { throw new InvalidOperationException(); } if (adornmentLayer == null) { adornmentLayer = wpfTextView.GetAdornmentLayer(PredefinedDsAdornmentLayers.LineSeparator); } if (editorFormatMap == null) { editorFormatMap = editorFormatMapService.GetEditorFormatMap(wpfTextView); } tagAggregator = viewTagAggregatorFactoryService.CreateTagAggregator <ILineSeparatorTag>(wpfTextView); tagAggregator.BatchedTagsChanged += TagAggregator_BatchedTagsChanged; wpfTextView.LayoutChanged += WpfTextView_LayoutChanged; editorFormatMap.FormatMappingChanged += EditorFormatMap_FormatMappingChanged; UpdateLineSeparatorBrush(); UpdateRange(new NormalizedSnapshotSpanCollection(wpfTextView.TextViewLines.FormattedSpan)); } else { DisposeTagAggregator(); wpfTextView.LayoutChanged -= WpfTextView_LayoutChanged; if (editorFormatMap != null) { editorFormatMap.FormatMappingChanged -= EditorFormatMap_FormatMappingChanged; } RemoveAllLineSeparatorElements(); } }
public void TextViewCreated(IWpfTextView textView) { new BackgroundColorVisualManager(textView, AggregatorService.CreateTagAggregator <IClassificationTag>(textView), FormatMapService.GetClassificationFormatMap(textView), FCService, AdaptersService); }
private bool ExecuteCommandImpl(EditorCommandArgs args, bool navigateToNext, CommandExecutionContext context) { using (var tagAggregator = _tagAggregatorFactory.CreateTagAggregator <NavigableHighlightTag>(args.TextView)) { var tagUnderCursor = FindTagUnderCaret(tagAggregator, args.TextView); if (tagUnderCursor == null) { return(false); } var spans = GetTags(tagAggregator, args.TextView.TextSnapshot.GetFullSpan()).ToList(); Contract.ThrowIfFalse(spans.Any(), "We should have at least found the tag under the cursor!"); var destTag = GetDestinationTag(tagUnderCursor.Value, spans, navigateToNext); if (args.TextView.TryMoveCaretToAndEnsureVisible(destTag.Start, _outliningManagerService)) { args.TextView.SetSelection(destTag); } } return(true); }
public PlayMouseProcessor(IWpfTextViewHost wpfTextViewHost, IViewTagAggregatorFactoryService viewTagAggregatorFactoryService) { _wpfTextViewHost = wpfTextViewHost; _viewTagAggregatorFactoryService = viewTagAggregatorFactoryService; _createTagAggregator = _viewTagAggregatorFactoryService.CreateTagAggregator<PlayGlyphTag>(_wpfTextViewHost.TextView); }
internal ClassifierAggregator(ITextView textView, IViewTagAggregatorFactoryService viewTagAggregatorFactory, IClassificationTypeRegistryService classificationTypeRegistry) { // Validate. if (textView == null) { throw new ArgumentNullException(nameof(textView)); } if (viewTagAggregatorFactory == null) { throw new ArgumentNullException(nameof(viewTagAggregatorFactory)); } if (classificationTypeRegistry == null) { throw new ArgumentNullException(nameof(classificationTypeRegistry)); } _textBuffer = textView.TextBuffer; _classificationTypeRegistry = classificationTypeRegistry; // Create a tag aggregator that maps by content type, so we don't map through projection buffers that aren't "projection" content type. _tagAggregator = viewTagAggregatorFactory.CreateTagAggregator <IClassificationTag>(textView, TagAggregatorOptions.MapByContentType) as IAccurateTagAggregator <IClassificationTag>; _tagAggregator.BatchedTagsChanged += OnBatchedTagsChanged; }
private static JiraIssueLineGlyphTag getIssueGlyphTagUnderCursor(IWpfTextView view, IViewTagAggregatorFactoryService tagAggregatorFactory) { Point position = Mouse.GetPosition(view.VisualElement); position = relativeToView(view, position); ITextViewLine line = view.TextViewLines.GetTextViewLineContainingYCoordinate(position.Y); if (line == null) { return(null); } SnapshotPoint?bufferPos = line.GetBufferPositionFromXCoordinate(line.Left); if (!bufferPos.HasValue) { return(null); } ITagAggregator <JiraIssueLineGlyphTag> aggregator = tagAggregatorFactory.CreateTagAggregator <JiraIssueLineGlyphTag>(view); IEnumerable <IMappingTagSpan <JiraIssueLineGlyphTag> > spans = aggregator.GetTags(new SnapshotSpan(new SnapshotPoint(view.TextSnapshot, 0), view.TextSnapshot.Length - 1)); JiraIssueLineGlyphTag textTag = (from span in spans let t = span.Tag where t.Where.Start.GetContainingLine().LineNumber == bufferPos.Value.GetContainingLine().LineNumber select span.Tag).FirstOrDefault(); return(textTag); }
public MarksEnumerator(IViewTagAggregatorFactoryService aggregator_factory, ITextView view) { _view = view; _view.Closed += OnViewClosed; _aggregator = aggregator_factory.CreateTagAggregator<IVsVisibleTextMarkerTag>(view); _aggregator.BatchedTagsChanged += OnTagsChanged; }
public MarkFactory(IWpfTextView view, IViewTagAggregatorFactoryService aggregatorFactoryService) { _markerAggregator = aggregatorFactoryService.CreateTagAggregator <IVsVisibleTextMarkerTag>(view); _markerAggregator.TagsChanged += OnTagsChanged; view.Closed += OnClosed; }
IWpfTextViewMargin CreateMargin <TGlyphTag>(IGlyphFactory <TGlyphTag> glyphFactory, Func <Grid> gridFactory, IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin parent, IEditorFormatMap editorFormatMap) where TGlyphTag : ITag { var tagAggregator = tagAggregatorFactory.CreateTagAggregator <TGlyphTag>(wpfTextViewHost.TextView); return(new GlyphMargin <TGlyphTag>(wpfTextViewHost, glyphFactory, gridFactory, tagAggregator, editorFormatMap, IsMarginVisible, MarginPropertiesName, MarginName, true, 17.0)); }
public ChangeEnumerator(IViewTagAggregatorFactoryService aggregator_factory, ITextView view) { _view = view; _view.Closed += OnViewClosed; _aggregator = aggregator_factory.CreateTagAggregator <ChangeTag>(view); _aggregator.BatchedTagsChanged += OnTagsChanged; }
public void VimBufferCreated(IVimBuffer value) { _monitorMap[value] = new ExternalEditMonitor( value, _vsAdapter.GetTextLines(value.TextBuffer), new ReadOnlyCollection <IExternalEditAdapter>(_adapterList), _viewTagAggregatorFactoryService.CreateTagAggregator <ITag>(value.TextView)); value.Closed += delegate { _monitorMap.Remove(value); }; }
internal ExternalEditManager(IVimBuffer buffer, IVsTextLines vsTextLines, IViewTagAggregatorFactoryService tagAggregatorFactoryService) { _vsTextLines = vsTextLines; _tagAggregator = tagAggregatorFactoryService.CreateTagAggregator<ITag>(buffer.TextView); _buffer = buffer; _buffer.TextView.LayoutChanged += OnLayoutChanged; _buffer.SwitchedMode += OnSwitchedMode; _externalEditorAdapters.Add(new SnippetExternalEditorAdapter()); _externalEditorAdapters.Add(new ResharperExternalEditorAdapter()); }
GoToDefinitionMouseProcessor(IWpfTextView textView, TextViewConnectionListener textViewConnectionListener, IViewTagAggregatorFactoryService viewTagAggregatorFactoryService) { _textView = textView; _tagAggregator = viewTagAggregatorFactoryService.CreateTagAggregator<GoToDefinitionTag>(textView); _keyState = ModifierKeyState.GetStateForView(textView, textViewConnectionListener); _textView.LostAggregateFocus += OnTextViewLostAggregateFocus; _keyState.KeyStateChanged += OnKeyStateChanged; textViewConnectionListener.AddDisconnectAction(textView, RemoveMouseProcessorForView); }
internal ExternalEditManager(IVimBuffer buffer, IVsTextLines vsTextLines, IViewTagAggregatorFactoryService tagAggregatorFactoryService) { _vsTextLines = vsTextLines; _tagAggregator = tagAggregatorFactoryService.CreateTagAggregator <ITag>(buffer.TextView); _buffer = buffer; _buffer.TextView.LayoutChanged += OnLayoutChanged; _buffer.SwitchedMode += OnSwitchedMode; _externalEditorAdapters.Add(new SnippetExternalEditorAdapter()); _externalEditorAdapters.Add(new ResharperExternalEditorAdapter()); }
IWpfTextViewMargin CreateMargin <TGlyphTag>(IGlyphFactory <TGlyphTag> glyphFactory, Func <Grid> gridFactory, IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin parent, IEditorFormatMap editorFormatMap) where TGlyphTag : ITag { var tagAggregator = tagAggregatorFactory.CreateTagAggregator <TGlyphTag>(wpfTextViewHost.TextView); var margin = new GlyphMargin <TGlyphTag>(wpfTextViewHost, glyphFactory, gridFactory, tagAggregator, editorFormatMap, IsMarginVisible, MarginPropertiesName, MarginName, true, 17.0); TrackCommentGlyphOnDiffView(wpfTextViewHost, margin.VisualElement); return(margin); }
public ICocoaMouseProcessor GetAssociatedMouseProcessor( ICocoaTextViewHost wpfTextViewHost, ICocoaTextViewMargin margin) { return(new BreakpointGlyphMouseProcessor( wpfTextViewHost, margin, viewTagAggregatorService.CreateTagAggregator <IGlyphTag> (wpfTextViewHost.TextView), editorPrimitivesFactoryService.GetViewPrimitives(wpfTextViewHost.TextView))); }
public ITagger <T>?CreateTagger <T>(ITextView textView, ITextBuffer buffer) where T : ITag { if (textView.IsNotSurfaceBufferOfTextView(buffer)) { return(null); } var tagAggregator = _viewTagAggregatorFactoryService.CreateTagAggregator <InlineHintDataTag>(textView); return(new InlineHintsTagger(this, (IWpfTextView)textView, buffer, tagAggregator) as ITagger <T>); }
public ErrorMarkFactory(IWpfTextView view, IViewTagAggregatorFactoryService tagAggregatorFactoryService, IEditorFormatMapService editorFormatMapService) { _squiggleTagger = tagAggregatorFactoryService.CreateTagAggregator <IErrorTag>(view); _squiggleTagger.TagsChanged += OnTagsChanged; _editorFormatMap = editorFormatMapService.GetEditorFormatMap(view); _editorFormatMap.FormatMappingChanged += OnFormatMappingChanged; _view = view; _view.Closed += OnClosed; }
private static SnapshotPoint GetBlockHeaderStartPoint(ITextView view, ITextSnapshotLine caretLine, IViewTagAggregatorFactoryService tagAggregatorService) { var snapshot = caretLine.Snapshot; var aggregator = tagAggregatorService.CreateTagAggregator <IClassificationTag>(view); var line = caretLine; int closeBraceCount = 1; //Using this like a stack. while (line.LineNumber - 1 > 0 && closeBraceCount > 0) { string lineText = line.GetText(); if (lineText.Contains("}")) { int index = lineText.IndexOf("}"); while (index >= 0 && line.Start + index < view.Caret.Position.BufferPosition) { if (!TagUtils.isStringOrComment(line, index, aggregator)) { closeBraceCount++; } index = lineText.IndexOf("}", index + 1); } } if (lineText.Contains("{")) { int index = lineText.IndexOf("{"); while (index >= 0 && line.Start + index < view.Caret.Position.BufferPosition) { if (!TagUtils.isStringOrComment(line, index, aggregator)) { closeBraceCount--; } index = lineText.IndexOf("{", index + 1); } } if (closeBraceCount > 0) { line = snapshot.GetLineFromLineNumber(line.LineNumber - 1); } } int startLineNumber = (line.GetText().Trim().Length != 1 && TagUtils.ContainsTag(line, "keyword", aggregator)) || line.LineNumber == 0 ? line.LineNumber : line.LineNumber - 1; return(line.LineNumber == 1 || caretLine.Snapshot != view.TextSnapshot ? line.Start : caretLine.Snapshot.GetLineFromLineNumber(startLineNumber).Start); }
public ITagger <T> CreateTagger <T>(ITextView textView, ITextBuffer buffer) where T : ITag { if (buffer == null | textView == null) { return(null); } var tags = _tagAggregator.CreateTagAggregator <IClassificationTag>(textView); return(new VersionControlTagger(textView, tags, _classifiers) as ITagger <T>); }
public TestGlyphMouseProcessor( IWpfTextViewHost viewHost, IViewTagAggregatorFactoryService viewTagService, DTE dte ) { _viewHost = viewHost; _viewTagService = viewTagService; _dte = (DTE2) dte; _testTagAggregator = viewTagService.CreateTagAggregator<TestTag>( viewHost.TextView); }
#pragma warning restore 649 public ITagger <T> CreateTagger <T>(ITextView textView, ITextBuffer buffer) where T : ITag { // Only provide highlighting on the top-level buffer if (textView.TextBuffer != buffer) { return(null); } ITagAggregator <ScoreGlyphTag> tagAggregator = ViewTagAggregatorFactoryService.CreateTagAggregator <ScoreGlyphTag>(textView); return(new HighlightTagger(buffer, tagAggregator) as ITagger <T>); }
public TextViewChangeFormatter(ITextView textView, IViewTagAggregatorFactoryService tagAggregatorFactory, IClassificationFormatMapService classificationFormatMapService) { if (!textView.IsClosed) { _textView = textView; _classificationAggregator = tagAggregatorFactory.CreateTagAggregator <IClassificationTag>(_textView); _classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(textView); _textView.Closed += OnTextViewClosed; textView.TextBuffer.PostChanged += OnTextBufferPostChanged; } }
private static SnapshotPoint GetBlockEndPoint(ITextView view, ITextSnapshotLine caretLine, IViewTagAggregatorFactoryService tagAggregatorService) { var snapshot = caretLine.Snapshot; var aggregator = tagAggregatorService.CreateTagAggregator <IClassificationTag>(view); var line = caretLine; string lineText; int openBraceCount = 1; //Using this like a stack. while (line.LineNumber < snapshot.LineCount - 1 && openBraceCount > 0) { lineText = line.GetText(); if (lineText.Contains("{")) { int index = lineText.IndexOf("{"); while (index >= 0 && line.Start + index >= view.Caret.Position.BufferPosition) { if (!TagUtils.isStringOrComment(line, index, aggregator)) { openBraceCount++; } index = lineText.IndexOf("{", index + 1); } } if (lineText.Contains("}")) { int index = lineText.IndexOf("}"); while (index >= 0 && line.Start + index >= view.Caret.Position.BufferPosition) { if (!TagUtils.isStringOrComment(line, index, aggregator)) { openBraceCount--; } index = lineText.IndexOf("}", index + 1); } } if (openBraceCount > 0) { line = snapshot.GetLineFromLineNumber(line.LineNumber + 1); } } lineText = line.GetText(); return(lineText.Contains("}") ? new SnapshotPoint(snapshot, line.Start + lineText.IndexOf("}") + 1) : new SnapshotPoint(snapshot, snapshot.Length - 1)); }
public ITagger <T> CreateTagger <T>(ITextView textView, ITextBuffer buffer) where T : ITag { // Determining of the textView's buffer does not match the buffer in order to skip showing the hints for // the interactive window if (buffer != textView.TextBuffer) { return(null); } var tagAggregator = _viewTagAggregatorFactoryService.CreateTagAggregator <InlineParameterNameHintDataTag>(textView); return(new InlineParameterNameHintsTagger(this, textView, buffer, tagAggregator) as ITagger <T>); }
public static IMappingTagSpan<IUrlTag> GetUri(IViewTagAggregatorFactoryService viewTagAggregatorFactoryService, ITextView textView, SnapshotPoint point) { if (viewTagAggregatorFactoryService == null) throw new ArgumentNullException(nameof(viewTagAggregatorFactoryService)); if (point.Snapshot == null) throw new ArgumentException(); using (var tagAggregator = viewTagAggregatorFactoryService.CreateTagAggregator<IUrlTag>(textView)) { foreach (var tagSpan in tagAggregator.GetTags(new SnapshotSpan(point.Snapshot, point.Position, 0))) { foreach (var span in tagSpan.Span.GetSpans(point.Snapshot)) { if (span.Start <= point && point < span.End) return tagSpan; } } } return null; }
/// <summary> /// Creates a square image and attaches an event handler to the layout changed event that /// adds the the square in the upper right-hand corner of the TextView via the adornment layer /// </summary> /// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param> public TestAdorn(IWpfTextView view, TextInvisTagger tit, IViewTagAggregatorFactoryService tafs) { _view = view; _tit = tit; tagAggregator = tafs.CreateTagAggregator<TextInvisTag>(_view); //Grab a reference to the adornment layer that this adornment should be added to _adornmentLayer = view.GetAdornmentLayer("FocusArea"); _view.ViewportHeightChanged += delegate { this.onSizeChange(); }; _view.ViewportWidthChanged += delegate { this.onSizeChange(); }; //_tit.ScrollNumberFixed += delegate { this.onSizeChange(); }; _view.LayoutChanged += delegate { this.onSizeChange(); }; //may have problems //_view.LayoutChanged += new EventHandler<TextViewLayoutChangedEventArgs>(_view_LayoutChanged); }