Ejemplo n.º 1
0
        private void CreateCodeWindow()
        {
            // create code window
            Guid guidVsCodeWindow = typeof(VsCodeWindowClass).GUID;

            codeWindow = services.CreateObject(services.LocalRegistry, guidVsCodeWindow, typeof(IVsCodeWindow).GUID) as IVsCodeWindow;

            CustomizeCodeWindow();

            // set buffer
            Guid guidVsTextBuffer = typeof(VsTextBufferClass).GUID;

            textBuffer = services.CreateObject(services.LocalRegistry, guidVsTextBuffer,
                                               typeof(IVsTextBuffer).GUID) as IVsTextBuffer;
            textBuffer.InitializeContent("ed", 2);

            Guid langSvc = new Guid("{fa498a2d-116a-4f25-9b55-7938e8e6dda7}");

            int hr = textBuffer.SetLanguageServiceID(ref langSvc);

            if (hr != VSConstants.S_OK)
            {
                Marshal.ThrowExceptionForHR(hr);
            }

            hr = codeWindow.SetBuffer(textBuffer as IVsTextLines);
            if (hr != VSConstants.S_OK)
            {
                Marshal.ThrowExceptionForHR(hr);
            }

            // this is necessary for the adapters to work in VS2010
            Initialize(String.Empty);

            // create pane window
            IVsWindowPane windowPane = codeWindow as IVsWindowPane;

            hr = windowPane.SetSite(services.IOleServiceProvider);
            if (hr != VSConstants.S_OK)
            {
                Marshal.ThrowExceptionForHR(hr);
            }
            if (parentHandle != IntPtr.Zero)
            {
                hr = windowPane.CreatePaneWindow(parentHandle, 0, 0, 100, 100, out hwnd);
                if (hr != VSConstants.S_OK)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }
            }
        }
Ejemplo n.º 2
0
            protected override IWpfTextViewHost /*!*/ CreateTextViewHost()
            {
                var adapterFactory = ComponentModel.GetService <IVsEditorAdaptersFactoryService>();
                var provider       = (Microsoft.VisualStudio.OLE.Interop.IServiceProvider)_window.GetService(typeof(Microsoft.VisualStudio.OLE.Interop.IServiceProvider));

                // create the buffer adapter and initialize it
                IVsTextBuffer bufferAdapter = adapterFactory.CreateVsTextBufferAdapter(provider, ContentType);
                int           result        = bufferAdapter.InitializeContent("", 0);

                bufferAdapter.SetLanguageServiceID(_window.LanguageServiceGuid);

                // ITextEditor is available only after InitializeContent was called:
                ITextBuffer textBuffer = adapterFactory.GetDataBuffer(bufferAdapter);

                // we need to set IReplProptProvider property before TextViewHost is instantiated so that ReplPromptTaggerProvider can bind to it
                if (Evaluator.DisplayPromptInMargin)
                {
                    textBuffer.Properties.AddProperty(typeof(IReplPromptProvider), this);
                }

                // Create and inititalize text view adapter.
                // WARNING: This might trigger various services like IntelliSense, margins, taggers, etc.
                IVsTextView textViewAdapter = adapterFactory.CreateVsTextViewAdapter(provider, GetReplRoles());

                ((IVsWindowPane)textViewAdapter).SetSite(provider);

                // make us a code window so we'll have the same colors as a normal code window.
                IVsTextEditorPropertyContainer propContainer;

                ((IVsTextEditorPropertyCategoryContainer)textViewAdapter).GetPropertyCategory(Microsoft.VisualStudio.Editor.DefGuidList.guidEditPropCategoryViewMasterSettings, out propContainer);
                propContainer.SetProperty(VSEDITPROPID.VSEDITPROPID_ViewComposite_AllCodeWindowDefaults, true);

                textViewAdapter.Initialize(
                    (IVsTextLines)bufferAdapter,
                    IntPtr.Zero,
                    (uint)TextViewInitFlags.VIF_HSCROLL | (uint)TextViewInitFlags.VIF_VSCROLL,
                    new[] { new INITVIEW {
                                fSelectionMargin = 0, fWidgetMargin = 0, fVirtualSpace = 0, fDragDropMove = 1
                            } }
                    );

                // disable change tracking because everything will be changed
                var res = adapterFactory.GetWpfTextViewHost(textViewAdapter);

                res.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.ChangeTrackingId, false);
                return(res);
            }
Ejemplo n.º 3
0
        private void CreateHostedEditor()
        {
            //Get the component model so we can request the editor adapter factory which we can use to spin up an editor instance.
            IComponentModel componentModel = (IComponentModel)ServiceProvider.GlobalProvider.GetService(typeof(SComponentModel));

            IContentTypeRegistryService contentTypeRegistry = componentModel.GetService <IContentTypeRegistryService>();
            IContentType contentType = contentTypeRegistry.GetContentType("CSharp");

            IVsEditorAdaptersFactoryService editorAdapterFactory = componentModel.GetService <IVsEditorAdaptersFactoryService>();

            this.textBuffer = editorAdapterFactory.CreateVsTextBufferAdapter(OleServiceProvider);
            Guid CSharpLanguageService = new Guid("{694DD9B6-B865-4C5B-AD85-86356E9C88DC}");

            ErrorHandler.ThrowOnFailure(textBuffer.SetLanguageServiceID(ref CSharpLanguageService));

            string initialContents = String.Format("using System;{0}{0}namespace Lazers{0}{{{0}{1}public class Awesome{0}{1}{{{0}{1}}}{0}}}", Environment.NewLine, "    ");

            ErrorHandler.ThrowOnFailure(textBuffer.InitializeContent(initialContents, initialContents.Length));

            //Disable the splitter due to a crashing bug if we don't :(
            this.codeWindow = editorAdapterFactory.CreateVsCodeWindowAdapter(OleServiceProvider);
            ((IVsCodeWindowEx)this.codeWindow).Initialize((uint)_codewindowbehaviorflags.CWB_DISABLESPLITTER,
                                                          VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_Filter,
                                                          "",
                                                          "",
                                                          0,
                                                          new INITVIEW[1]);

            this.codeWindow.SetBuffer((IVsTextLines)this.textBuffer);

            ErrorHandler.ThrowOnFailure(this.codeWindow.GetPrimaryView(out this.textView));
            this.textViewHost = editorAdapterFactory.GetWpfTextViewHost(this.textView);

            this.Content             = textViewHost.HostControl;
            this.editorCommandTarget = (IOleCommandTarget)this.textView;
        }
Ejemplo n.º 4
0
        private void CreateCodeWindow()
        {
            // create code window
            Guid guidVsCodeWindow = typeof(VsCodeWindowClass).GUID;

            codeWindow = services.CreateObject(services.LocalRegistry, guidVsCodeWindow, typeof(IVsCodeWindow).GUID) as IVsCodeWindow;

            CustomizeCodeWindow();

            // set buffer
            Guid guidVsTextBuffer = typeof(VsTextBufferClass).GUID;

            textBuffer = services.CreateObject(services.LocalRegistry, guidVsTextBuffer,
                                               typeof(IVsTextBuffer).GUID) as IVsTextBuffer;
            textBuffer.InitializeContent("ed", 2);

            Guid langSvc = new Guid();

            if (parent == null || typeof(SqlEditor) == parent.Editor.GetType())
            {
                langSvc = new Guid(MySqlLanguageService.IID);
            }
            else
            {
                //TODO: [MYSQLFORVS-276] - CREATE A CLASSIFIER EXTENSION THAT COLORS THE APPROPRIATE TEXT (MYJS FILES).
                if (parent == null || typeof(MySqlHybridScriptEditor) == parent.Editor.GetType() && ((MySqlHybridScriptEditor)parent.Editor).ScriptLanguageType == ScriptLanguageType.JavaScript)
                {
                    langSvc = new Guid(MyJsLanguageService.IID);
                }
                //else
                //TODO: [MYSQLFORVS-402] - CREATE A CLASSIFIER EXTENSION THAT COLORS THE APPROPRIATE TEXT (MYPY FILES).
                else if (parent == null || typeof(MySqlHybridScriptEditor) == parent.Editor.GetType() && ((MySqlHybridScriptEditor)parent.Editor).ScriptLanguageType == ScriptLanguageType.Python)
                {
                    langSvc = new Guid(MyPyLanguageService.IID);
                }
            }

            int hr = textBuffer.SetLanguageServiceID(ref langSvc);

            if (hr != VSConstants.S_OK)
            {
                Marshal.ThrowExceptionForHR(hr);
            }

            hr = codeWindow.SetBuffer(textBuffer as IVsTextLines);
            if (hr != VSConstants.S_OK)
            {
                Marshal.ThrowExceptionForHR(hr);
            }

            // this is necessary for the adapters to work in VS2010
            Initialize(String.Empty);

            // create pane window
            IVsWindowPane windowPane = codeWindow as IVsWindowPane;

            hr = windowPane.SetSite(services.IOleServiceProvider);
            if (hr != VSConstants.S_OK)
            {
                Marshal.ThrowExceptionForHR(hr);
            }
            if (parentHandle != IntPtr.Zero)
            {
                hr = windowPane.CreatePaneWindow(parentHandle, 0, 0, 100, 100, out hwnd);
                if (hr != VSConstants.S_OK)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }
            }
        }
Ejemplo n.º 5
0
        private void CreateVsCodeWindow()
        {
            int hr = VSConstants.S_OK;
            Guid clsidVsCodeWindow = typeof(VsCodeWindowClass).GUID;
            Guid iidVsCodeWindow = typeof(IVsCodeWindow).GUID;
            Guid clsidVsTextBuffer = typeof(VsTextBufferClass).GUID;
            Guid iidVsTextLines = typeof(IVsTextLines).GUID;

            // create/site a VsTextBuffer object
            _vsTextBuffer = (IVsTextBuffer)NuoDbVSPackagePackage.Instance.CreateInstance(ref clsidVsTextBuffer, ref iidVsTextLines, typeof(IVsTextBuffer));
            IObjectWithSite ows = (IObjectWithSite)_vsTextBuffer;
            ows.SetSite(_editor);
            //string strSQL = "select * from sometable";
            //hr = _vsTextBuffer.InitializeContent(strSQL, strSQL.Length);
            switch (NuoDbVSPackagePackage.Instance.GetMajorVStudioVersion())
            {
                case 10:
                    hr = _vsTextBuffer.SetLanguageServiceID(ref GuidList.guidSQLLangSvc_VS2010);
                    break;
                case 11:
                    hr = _vsTextBuffer.SetLanguageServiceID(ref GuidList.guidSQLLangSvc_VS2012);
                    break;
            }

            // create/initialize/site a VsCodeWindow object
            _vsCodeWindow = (IVsCodeWindow)NuoDbVSPackagePackage.Instance.CreateInstance(ref clsidVsCodeWindow, ref iidVsCodeWindow, typeof(IVsCodeWindow));

            INITVIEW[] initView = new INITVIEW[1];
            initView[0].fSelectionMargin = 0;
            initView[0].fWidgetMargin = 0;
            initView[0].fVirtualSpace = 0;
            initView[0].fDragDropMove = 1;
            initView[0].fVirtualSpace = 0;
            IVsCodeWindowEx vsCodeWindowEx = (IVsCodeWindowEx)_vsCodeWindow;
            hr = vsCodeWindowEx.Initialize((uint)_codewindowbehaviorflags.CWB_DISABLEDROPDOWNBAR | (uint)_codewindowbehaviorflags.CWB_DISABLESPLITTER,
                0, null, null,
                (uint)TextViewInitFlags.VIF_SET_WIDGET_MARGIN |
                (uint)TextViewInitFlags.VIF_SET_SELECTION_MARGIN |
                (uint)TextViewInitFlags.VIF_SET_VIRTUAL_SPACE |
                (uint)TextViewInitFlags.VIF_SET_DRAGDROPMOVE |
                (uint)TextViewInitFlags2.VIF_SUPPRESS_STATUS_BAR_UPDATE |
                (uint)TextViewInitFlags2.VIF_SUPPRESSBORDER |
                (uint)TextViewInitFlags2.VIF_SUPPRESSTRACKCHANGES |
                (uint)TextViewInitFlags2.VIF_SUPPRESSTRACKGOBACK,
                initView);

            hr = _vsCodeWindow.SetBuffer((IVsTextLines)_vsTextBuffer);
            IVsWindowPane vsWindowPane = (IVsWindowPane)_vsCodeWindow;
            hr = vsWindowPane.SetSite(_editor);
            hr = vsWindowPane.CreatePaneWindow(this.Handle, 0, 0, this.Parent.Size.Width, this.Parent.Size.Height, out _hWndCodeWindow);

            IVsTextView vsTextView;
            hr = _vsCodeWindow.GetPrimaryView(out vsTextView);

            // sink IVsTextViewEvents, so we can determine when a VsCodeWindow object actually has the focus.
            IConnectionPointContainer connptCntr = (IConnectionPointContainer)vsTextView;
            Guid riid = typeof(IVsTextViewEvents).GUID;
            IConnectionPoint cp;
            connptCntr.FindConnectionPoint(ref riid, out cp);
            cp.Advise(_editor, out cookie);

            // sink IVsTextLinesEvents, so we can determine when a VsCodeWindow text has been changed.
            connptCntr = (IConnectionPointContainer)_vsTextBuffer;
            riid = typeof(IVsTextLinesEvents).GUID;
            connptCntr.FindConnectionPoint(ref riid, out cp);
            cp.Advise(_editor, out cookie);
        }
Ejemplo n.º 6
0
    private void CreateCodeWindow()
    {
      // create code window
      Guid guidVsCodeWindow = typeof(VsCodeWindowClass).GUID;
      codeWindow = services.CreateObject(services.LocalRegistry, guidVsCodeWindow, typeof(IVsCodeWindow).GUID) as IVsCodeWindow;

      CustomizeCodeWindow();

      // set buffer
      Guid guidVsTextBuffer = typeof(VsTextBufferClass).GUID;
      textBuffer = services.CreateObject(services.LocalRegistry, guidVsTextBuffer,
          typeof(IVsTextBuffer).GUID) as IVsTextBuffer;
      textBuffer.InitializeContent("ed", 2);

      Guid langSvc = new Guid(MySqlLanguageService.IID);

      int hr = textBuffer.SetLanguageServiceID(ref langSvc);
      if (hr != VSConstants.S_OK)
        Marshal.ThrowExceptionForHR(hr);

      hr = codeWindow.SetBuffer(textBuffer as IVsTextLines);
      if (hr != VSConstants.S_OK)
        Marshal.ThrowExceptionForHR(hr);

      // this is necessary for the adapters to work in VS2010
      Initialize(String.Empty);

      // create pane window
      IVsWindowPane windowPane = codeWindow as IVsWindowPane;
      hr = windowPane.SetSite(services.IOleServiceProvider);
      if (hr != VSConstants.S_OK)
        Marshal.ThrowExceptionForHR(hr);
      if (parentHandle != IntPtr.Zero)
      {
        hr = windowPane.CreatePaneWindow(parentHandle, 0, 0, 100, 100, out hwnd);
        if (hr != VSConstants.S_OK)
          Marshal.ThrowExceptionForHR(hr);
      }
    }
Ejemplo n.º 7
0
        private void CreateVsCodeWindow()
        {
            int hr = VSConstants.S_OK;
            //ILocalRegistry localRegistry = (ILocalRegistry)Package.GetGlobalService(typeof(SLocalRegistry));
            IComponentModel componentModel = (IComponentModel)Package.GetGlobalService(typeof(SComponentModel));

            Guid clsidVsCodeWindow = typeof(VsCodeWindowClass).GUID;
            Guid iidVsCodeWindow = typeof(IVsCodeWindow).GUID;
            Guid iidVsTextLines = typeof(IVsTextLines).GUID;
            Guid clsidTextBuffer = typeof(VsTextBufferClass).GUID;
            Guid iidTextBuffer = VSConstants.IID_IUnknown;

            // create/site a VsTextBuffer object
            var editorAdaptersFactoryService = componentModel.GetService<IVsEditorAdaptersFactoryService>();
            vsTextBuffer = editorAdaptersFactoryService.CreateVsTextBufferAdapter(OleServiceProvider);

            string strSQL = Global.textStub;
            hr = vsTextBuffer.InitializeContent(strSQL, strSQL.Length);
            hr = vsTextBuffer.SetLanguageServiceID(ref GuidList.guidCppLangSvc);

            // create/initialize/site a VsCodeWindow object
            _vsCodeWindow = editorAdaptersFactoryService.CreateVsCodeWindowAdapter(OleServiceProvider);

            INITVIEW[] initView = new INITVIEW[1];
            initView[0].fSelectionMargin = 0;
            initView[0].fWidgetMargin = 0;
            initView[0].fVirtualSpace = 0;
            initView[0].fDragDropMove = 1;
            initView[0].fVirtualSpace = 0;
            IVsCodeWindowEx vsCodeWindowEx = (IVsCodeWindowEx)_vsCodeWindow;
            hr = vsCodeWindowEx.Initialize((uint)_codewindowbehaviorflags.CWB_DISABLEDROPDOWNBAR | (uint)_codewindowbehaviorflags.CWB_DISABLESPLITTER,
                0, null, null,
                (uint)TextViewInitFlags.VIF_SET_WIDGET_MARGIN |
                (uint)TextViewInitFlags.VIF_SET_SELECTION_MARGIN |
                (uint)TextViewInitFlags.VIF_SET_VIRTUAL_SPACE |
                (uint)TextViewInitFlags.VIF_SET_DRAGDROPMOVE |
                (uint)TextViewInitFlags2.VIF_SUPPRESS_STATUS_BAR_UPDATE |
                (uint)TextViewInitFlags2.VIF_READONLY |
                (uint)TextViewInitFlags2.VIF_SUPPRESSBORDER |
                (uint)TextViewInitFlags2.VIF_SUPPRESSTRACKCHANGES |
                (uint)TextViewInitFlags2.VIF_SUPPRESSTRACKGOBACK,
                initView);

            hr = _vsCodeWindow.SetBuffer((IVsTextLines)vsTextBuffer);

            IVsTextView vsTextView;
            hr = _vsCodeWindow.GetPrimaryView(out vsTextView);

            textViewHost = editorAdaptersFactoryService.GetWpfTextViewHost(vsTextView);

            textViewHost.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.ChangeTrackingId, false);
            textViewHost.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.GlyphMarginId, false);
            textViewHost.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.HorizontalScrollBarId, false);
            textViewHost.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.OutliningMarginId, false);

            textViewHost.TextView.Options.SetOptionValue(DefaultTextViewOptions.ViewProhibitUserInputId, true);
            Content = textViewHost.HostControl;
        }
        private void CreateHostedEditor()
        {
            //Get the component model so we can request the editor adapter factory which we can use to spin up an editor instance.
            IComponentModel componentModel = (IComponentModel)ServiceProvider.GlobalProvider.GetService(typeof(SComponentModel));

            IContentTypeRegistryService contentTypeRegistry = componentModel.GetService<IContentTypeRegistryService>();
            IContentType contentType = contentTypeRegistry.GetContentType("CSharp");

            IVsEditorAdaptersFactoryService editorAdapterFactory = componentModel.GetService<IVsEditorAdaptersFactoryService>();
            this.textBuffer = editorAdapterFactory.CreateVsTextBufferAdapter(OleServiceProvider);
            Guid CSharpLanguageService = new Guid("{694DD9B6-B865-4C5B-AD85-86356E9C88DC}");
            ErrorHandler.ThrowOnFailure(textBuffer.SetLanguageServiceID(ref CSharpLanguageService));

            string initialContents = String.Format("using System;{0}{0}namespace Lazers{0}{{{0}{1}public class Awesome{0}{1}{{{0}{1}}}{0}}}", Environment.NewLine, "    ");
            ErrorHandler.ThrowOnFailure(textBuffer.InitializeContent(initialContents, initialContents.Length));

            //Disable the splitter due to a crashing bug if we don't :(
            this.codeWindow = editorAdapterFactory.CreateVsCodeWindowAdapter(OleServiceProvider);
            ((IVsCodeWindowEx)this.codeWindow).Initialize((uint)_codewindowbehaviorflags.CWB_DISABLESPLITTER,
                                                          VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_Filter,
                                                          "",
                                                          "",
                                                          0,
                                                          new INITVIEW[1]);

            this.codeWindow.SetBuffer((IVsTextLines)this.textBuffer);

            ErrorHandler.ThrowOnFailure(this.codeWindow.GetPrimaryView(out this.textView));
            this.textViewHost = editorAdapterFactory.GetWpfTextViewHost(this.textView);

            this.Content = textViewHost.HostControl;
            this.editorCommandTarget = (IOleCommandTarget)this.textView;
        }
Ejemplo n.º 9
0
        private void CreateVsCodeWindow()
        {
            int  hr = VSConstants.S_OK;
            Guid clsidVsCodeWindow = typeof(VsCodeWindowClass).GUID;
            Guid iidVsCodeWindow   = typeof(IVsCodeWindow).GUID;
            Guid clsidVsTextBuffer = typeof(VsTextBufferClass).GUID;
            Guid iidVsTextLines    = typeof(IVsTextLines).GUID;

            // create/site a VsTextBuffer object
            _vsTextBuffer = (IVsTextBuffer)NuoDbVSPackagePackage.Instance.CreateInstance(ref clsidVsTextBuffer, ref iidVsTextLines, typeof(IVsTextBuffer));
            IObjectWithSite ows = (IObjectWithSite)_vsTextBuffer;

            ows.SetSite(_editor);
            //string strSQL = "select * from sometable";
            //hr = _vsTextBuffer.InitializeContent(strSQL, strSQL.Length);
            switch (NuoDbVSPackagePackage.Instance.GetMajorVStudioVersion())
            {
            case 10:
                hr = _vsTextBuffer.SetLanguageServiceID(ref GuidList.guidSQLLangSvc_VS2010);
                break;

            case 11:
                hr = _vsTextBuffer.SetLanguageServiceID(ref GuidList.guidSQLLangSvc_VS2012);
                break;
            }

            // create/initialize/site a VsCodeWindow object
            _vsCodeWindow = (IVsCodeWindow)NuoDbVSPackagePackage.Instance.CreateInstance(ref clsidVsCodeWindow, ref iidVsCodeWindow, typeof(IVsCodeWindow));

            INITVIEW[] initView = new INITVIEW[1];
            initView[0].fSelectionMargin = 0;
            initView[0].fWidgetMargin    = 0;
            initView[0].fVirtualSpace    = 0;
            initView[0].fDragDropMove    = 1;
            initView[0].fVirtualSpace    = 0;
            IVsCodeWindowEx vsCodeWindowEx = (IVsCodeWindowEx)_vsCodeWindow;

            hr = vsCodeWindowEx.Initialize((uint)_codewindowbehaviorflags.CWB_DISABLEDROPDOWNBAR | (uint)_codewindowbehaviorflags.CWB_DISABLESPLITTER,
                                           0, null, null,
                                           (uint)TextViewInitFlags.VIF_SET_WIDGET_MARGIN |
                                           (uint)TextViewInitFlags.VIF_SET_SELECTION_MARGIN |
                                           (uint)TextViewInitFlags.VIF_SET_VIRTUAL_SPACE |
                                           (uint)TextViewInitFlags.VIF_SET_DRAGDROPMOVE |
                                           (uint)TextViewInitFlags2.VIF_SUPPRESS_STATUS_BAR_UPDATE |
                                           (uint)TextViewInitFlags2.VIF_SUPPRESSBORDER |
                                           (uint)TextViewInitFlags2.VIF_SUPPRESSTRACKCHANGES |
                                           (uint)TextViewInitFlags2.VIF_SUPPRESSTRACKGOBACK,
                                           initView);

            hr = _vsCodeWindow.SetBuffer((IVsTextLines)_vsTextBuffer);
            IVsWindowPane vsWindowPane = (IVsWindowPane)_vsCodeWindow;

            hr = vsWindowPane.SetSite(_editor);
            hr = vsWindowPane.CreatePaneWindow(this.Handle, 0, 0, this.Parent.Size.Width, this.Parent.Size.Height, out _hWndCodeWindow);

            IVsTextView vsTextView;

            hr = _vsCodeWindow.GetPrimaryView(out vsTextView);

            // sink IVsTextViewEvents, so we can determine when a VsCodeWindow object actually has the focus.
            IConnectionPointContainer connptCntr = (IConnectionPointContainer)vsTextView;
            Guid             riid = typeof(IVsTextViewEvents).GUID;
            IConnectionPoint cp;

            connptCntr.FindConnectionPoint(ref riid, out cp);
            cp.Advise(_editor, out cookie);

            // sink IVsTextLinesEvents, so we can determine when a VsCodeWindow text has been changed.
            connptCntr = (IConnectionPointContainer)_vsTextBuffer;
            riid       = typeof(IVsTextLinesEvents).GUID;
            connptCntr.FindConnectionPoint(ref riid, out cp);
            cp.Advise(_editor, out cookie);
        }