예제 #1
0
        internal int Unregister(IVsDropdownBarManager manager)
        {
            _textView.Caret.PositionChanged -= CaretPositionChanged;

            // A buffer may have multiple DropDownBarClients, given one may open multiple CodeWindows
            // over a single buffer using Window/New Window
            List <DropDownBarClient> clients;

            if (_textView.Properties.TryGetProperty(typeof(DropDownBarClient), out clients))
            {
                clients.Remove(this);
                if (clients.Count == 0)
                {
                    _textView.Properties.RemoveProperty(typeof(DropDownBarClient));
                }
            }
            foreach (var tb in PythonTextBufferInfo.GetAllFromView(_textView))
            {
                tb.RemoveSink(this);
            }
#if DEBUG
            IVsDropdownBar       existing;
            IVsDropdownBarClient existingClient;
            if (ErrorHandler.Succeeded(manager.GetDropdownBar(out existing)) &&
                ErrorHandler.Succeeded(existing.GetClient(out existingClient)))
            {
                Debug.Assert(existingClient == this, "Unregistering the wrong dropdown client");
            }
#endif

            return(manager.RemoveDropdownBar());
        }
예제 #2
0
        public DropDownBarClient(IServiceProvider serviceProvider, ITextView textView)
        {
            Utilities.ArgumentNotNull(nameof(serviceProvider), serviceProvider);
            Utilities.ArgumentNotNull(nameof(textView), textView);

            _serviceProvider = serviceProvider;
            _uiThread        = _serviceProvider.GetUIThread();
            _services        = _serviceProvider.GetComponentModel().GetService <PythonEditorServices>();
            _textView        = textView;
            _dispatcher      = Dispatcher.CurrentDispatcher;
            _textView.Caret.PositionChanged += CaretPositionChanged;
            foreach (var tb in PythonTextBufferInfo.GetAllFromView(textView))
            {
                tb.AddSink(this, this);
            }
            textView.BufferGraph.GraphBuffersChanged += BufferGraph_GraphBuffersChanged;
            for (int i = 0; i < NavigationLevels; i++)
            {
                _curSelection[i] = -1;
            }
        }