public TextBufferEventListener(IComponentModel compModel, IVsTextLines textLines, IVsTextManager textMgr, IVsCodeWindow window)
            {
                _textLines = textLines;
                _compModel = compModel;
                _textMgr = textMgr;
                _window = window;

                var cpc = textLines as IConnectionPointContainer;
                var bufferEventsGuid = typeof(IVsTextBufferDataEvents).GUID;
                cpc.FindConnectionPoint(ref bufferEventsGuid, out _cp);
                _cp.Advise(this, out _cookie);
            }
Esempio n. 2
0
            public TextBufferEventListener(IComponentModel compModel, IVsTextLines textLines, IVsTextManager textMgr, IVsCodeWindow window)
            {
                _textLines = textLines;
                _compModel = compModel;
                _textMgr   = textMgr;
                _window    = window;

                var cpc = textLines as IConnectionPointContainer;
                var bufferEventsGuid = typeof(IVsTextBufferDataEvents).GUID;

                cpc.FindConnectionPoint(ref bufferEventsGuid, out _cp);
                _cp.Advise(this, out _cookie);
            }
Esempio n. 3
0
        protected override IVsCodeWindow CreateCodeView(string documentMoniker, IVsTextLines textLines, bool createdDocData, ref string editorCaption, ref Guid cmdUI)
        {
            IVsCodeWindow window = base.CreateCodeView(documentMoniker, textLines, createdDocData, ref editorCaption, ref cmdUI);

            var compModel           = Package.AsVsServiceProvider().GetComponentModel();
            var textMgr             = Package.AsVsServiceProvider().GetTextManager();
            var bufferEventListener = new TextBufferEventListener(compModel, textLines, textMgr, window);

            if (!createdDocData)
            {
                // we have a pre-created buffer, go ahead and initialize now as the buffer already
                // exists and is initialized.
                bufferEventListener.OnLoadCompleted(0);
            }

            return(window);
        }
Esempio n. 4
0
        protected virtual IVsCodeWindow CreateCodeView(string documentMoniker, IVsTextLines textLines, bool createdDocData, ref string editorCaption, ref Guid cmdUI)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            Type codeWindowType = typeof(IVsCodeWindow);
            Guid riid           = codeWindowType.GUID;
            Guid clsid          = typeof(VsCodeWindowClass).GUID;
            var  compModel      = (IComponentModel) new VsServiceProviderWrapper(_package).GetService(typeof(SComponentModel));
            IVsEditorAdaptersFactoryService adapterService = compModel.GetService <IVsEditorAdaptersFactoryService>();

            IVsCodeWindow window = adapterService.CreateVsCodeWindowAdapter((IOleServiceProvider)_serviceProvider.GetService(typeof(IOleServiceProvider)));

            ErrorHandler.ThrowOnFailure(window.SetBuffer(textLines));
            ErrorHandler.ThrowOnFailure(window.SetBaseEditorCaption(null));
            ErrorHandler.ThrowOnFailure(window.GetEditorCaption(READONLYSTATUS.ROSTATUS_Unknown, out editorCaption));

            if (textLines is IVsUserData userData)
            {
                if (PromptEncodingOnLoad)
                {
                    Guid guid = VSConstants.VsTextBufferUserDataGuid.VsBufferEncodingPromptOnLoad_guid;
                    userData.SetData(ref guid, (uint)1);
                }
            }

            cmdUI = VSConstants.GUID_TextEditorFactory;

            var componentModel      = (IComponentModel) new VsServiceProviderWrapper(Package).GetService(typeof(SComponentModel));
            var bufferEventListener = new TextBufferEventListener(componentModel, textLines, _languageServiceId);

            if (!createdDocData)
            {
                // we have a pre-created buffer, go ahead and initialize now as the buffer already
                // exists and is initialized
                bufferEventListener.OnLoadCompleted(0);
            }

            return(window);
        }
Esempio n. 5
0
 public int GetCodeWindowManager(IVsCodeWindow pCodeWin, out IVsCodeWindowManager ppCodeWinMgr)
 {
     // will need to implement this method to support type and member dropdown bars
     ppCodeWinMgr = null;
     return(VSConstants.E_FAIL);
 }
 public int GetCodeWindowManager(IVsCodeWindow pCodeWin, out IVsCodeWindowManager ppCodeWinMgr)
 {
     // will need to implement this method to support type and member dropdown bars
     ppCodeWinMgr = null;
     return VSConstants.E_FAIL;
 }