// Called multiple times as subject buffers get connected and disconnected in the buffer graph public virtual void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { EnsureInitialized(); foreach (ITextBuffer textBuffer in subjectBuffers) { TextViewData viewData = null; bool newBuffer = !TextBufferToViewData.ContainsKey(textBuffer); if (newBuffer) { viewData = new TextViewData(); TextBufferToViewData[textBuffer] = viewData; } else { viewData = TextBufferToViewData[textBuffer]; } viewData.AddView(textView); if (newBuffer) { OnTextBufferCreated(textView, textBuffer); } OnTextViewConnected(textView, textBuffer); } }
public virtual void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers) { if (TextBufferToViewData != null) { foreach (ITextBuffer textBuffer in subjectBuffers) { OnTextViewDisconnected(textView, textBuffer); if (TextBufferToViewData.ContainsKey(textBuffer)) { TextViewData viewData = TextBufferToViewData[textBuffer]; viewData.RemoveView(textView); if (viewData.AllViews.Count == 0 && _pendingCheckForViewlessTextBuffers == null) { if (reason == ConnectionReason.BufferGraphChange) { // The buffer could be temporarily removed from the view, so don't // immediately check if it's unused - do that after posting a message. _pendingCheckForViewlessTextBuffers = CheckForViewlessTextBuffers; Shell.Idle += OnIdle; } else { CheckForViewlessTextBuffers(); } } } } } }
public static TextViewData GetTextViewDataForBuffer(ITextBuffer textBuffer) { if (_allInstances != null) { foreach (TextViewConnectionListener instance in _allInstances) { TextViewData textViewData = null; if ((instance.TextBufferToViewData != null) && (instance.TextBufferToViewData.TryGetValue(textBuffer, out textViewData))) { if (textViewData.AllViews.Count > 0) { return(textViewData); } } } } return(null); }
// Called multiple times as subject buffers get connected and disconnected in the buffer graph public virtual void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) { EnsureInitialized(); foreach (ITextBuffer textBuffer in subjectBuffers) { TextViewData viewData = null; bool newBuffer = !TextBufferToViewData.ContainsKey(textBuffer); if (newBuffer) { viewData = new TextViewData(); TextBufferToViewData[textBuffer] = viewData; } else { viewData = TextBufferToViewData[textBuffer]; } viewData.AddView(textView); if (newBuffer) { OnTextBufferCreated(textBuffer); } OnTextViewConnected(textView, textBuffer); } }
public static IEnumerable <ITextView> GetViewsForBuffer(ITextBuffer textBuffer) { TextViewData textViewData = GetTextViewDataForBuffer(textBuffer); return(textViewData != null ? textViewData.AllViews : new ITextView[0]); }