/// <include file='doc\CodeWindowManager.uex' path='docs/doc[@for="CodeWindowManager.CodeWindowManager"]/*' /> /// <summary> /// The CodeWindowManager is constructed by the base LanguageService class when VS calls /// the IVsLanguageInfo.GetCodeWindowManager method. You can override CreateCodeWindowManager /// on your LanguageService if you want to plug in a different CodeWindowManager. /// </summary> public CodeWindowManager(LanguageService service, IVsCodeWindow codeWindow, Source source) { this.service = service; this.codeWindow = codeWindow; this.viewFilters = new ArrayList(); this.source = source; this.properties = service.CreateDocumentProperties(this); }
public CodeWindowManager(IVsCodeWindow codeWindow, IWpfTextView textView, IComponentModel componentModel) { _window = codeWindow; _textView = textView; _editorOperationsFactory = componentModel.GetService<IEditorOperationsFactoryService>(); _analyzer = componentModel.GetService<IPythonAnalyzer>(); }
public CodeWindowManager(IVsCodeWindow codeWindow, IWpfTextView textView, IComponentModel componentModel) { _window = codeWindow; _textView = textView; _editorOperationsFactory = componentModel.GetService<IEditorOperationsFactoryService>(); _textView.Properties.AddProperty(typeof(CodeWindowManager), this); }
public AvaloniaDesignerPane(IVsCodeWindow vsCodeWindow, IVsTextLines textBuffer, string fileName, IAvaloniaDesignerSettings designerSettings) { _vsCodeWindow = vsCodeWindow; _textBuffer = textBuffer.GetTextBuffer(); _fileName = fileName; _designerSettings = designerSettings; }
public NavigationBarClient( IVsDropdownBarManager manager, IVsCodeWindow codeWindow, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl workspace) { _manager = manager; _codeWindow = codeWindow; _workspace = workspace; _imageService = (IVsImageService2)serviceProvider.GetService(typeof(SVsImageService)); _projectItems = SpecializedCollections.EmptyList<NavigationBarProjectItem>(); _currentTypeItems = SpecializedCollections.EmptyList<NavigationBarItem>(); var vsShell = serviceProvider.GetService(typeof(SVsShell)) as IVsShell; if (vsShell != null) { object varImageList; int hresult = vsShell.GetProperty((int)__VSSPROPID.VSSPROPID_ObjectMgrTypesImgList, out varImageList); if (ErrorHandler.Succeeded(hresult) && varImageList != null) { _imageList = (IntPtr)(int)varImageList; } } _codeWindowEventsSink = ComEventSink.Advise<IVsCodeWindowEvents>(codeWindow, this); _editorAdaptersFactoryService = serviceProvider.GetMefService<IVsEditorAdaptersFactoryService>(); IVsTextView pTextView; codeWindow.GetPrimaryView(out pTextView); StartTrackingView(pTextView); pTextView = null; codeWindow.GetSecondaryView(out pTextView); StartTrackingView(pTextView); }
/// <summary> /// The CodeWindowManager is constructed by the base LanguageService class when VS calls /// the IVsLanguageInfo.GetCodeWindowManager method. You can override CreateCodeWindowManager /// on your LanguageService if you want to plug in a different CodeWindowManager. /// </summary> internal CodeWindowManager(LanguageService service, IVsCodeWindow codeWindow, ISource source) { this.service = service; this.codeWindow = codeWindow; this.viewFilters = new ArrayList(); this.source = source; #if DOCUMENT_PROPERTIES this.properties = service.CreateDocumentProperties(this); #endif }
int IVsLanguageInfo.GetCodeWindowManager(IVsCodeWindow codeWindow, out IVsCodeWindowManager codeWindowManager) { codeWindowManager = CreateCodeWindowManager(codeWindow); if (codeWindowManager != null) return VSConstants.S_OK; else return VSConstants.E_NOTIMPL; }
/// <include file='doc\CodeWindowManager.uex' path='docs/doc[@for="CodeWindowManager.Close"]/*' /> /// <summary>Closes all view filters, and the document properties window</summary> public void Close() { Trace.WriteLine("CodeWindowManager::Close"); if (this.properties != null) this.properties.Close(); CloseFilters(); this.viewFilters = null; properties = null; service = null; source = null; this.codeWindow = null; }
public DartCodeWindowManager(ITextDocumentFactoryService textDocumentFactory, IVsEditorAdaptersFactoryService editorAdapterFactory, IVsCodeWindow codeWindow, DartAnalysisServiceFactory analysisServiceFactory) { this.barManager = ((IVsDropdownBarManager)codeWindow); this.analysisServiceFactory = analysisServiceFactory; // Figure out the filename (seriously; this is the best way?!). IVsTextView textView; codeWindow.GetPrimaryView(out textView); wpfTextView = editorAdapterFactory.GetWpfTextView(textView); textDocumentFactory.TryGetTextDocument(wpfTextView.TextBuffer, out this.textDocument); }
public CodeWindowManager(IVsCodeWindow codeWindow, SVsServiceProvider serviceProvider, LanguagePreferences languagePreferences) { Contract.Requires<ArgumentNullException>(codeWindow != null, "codeWindow"); Contract.Requires<ArgumentNullException>(serviceProvider != null, "serviceProvider"); Contract.Requires<ArgumentNullException>(languagePreferences != null, "languagePreferences"); _codeWindow = codeWindow; _serviceProvider = serviceProvider; _languagePreferences = languagePreferences; _languagePreferences.PreferencesChanged += WeakEvents.AsWeak(HandleLanguagePreferencesChanged, handler => _languagePreferences.PreferencesChanged -= handler); }
public VisualGitCodeWindowManager(VisualGitLanguage language, IVsCodeWindow window) : base(language) { if (window == null) throw new ArgumentNullException("window"); _window = window; _views = new List<IVsTextView>(); if (!TryHookConnectionPoint<IVsCodeWindowEvents>(_window, this, out _cookie)) _cookie = 0; }
/// <summary> /// Get the last active view of the code window /// </summary> public static Result <IWpfTextView> GetLastActiveView(this IVsCodeWindow codeWindow, IVsEditorAdaptersFactoryService factoryService) { var result = GetLastActiveView(codeWindow); if (result.IsError) { return(Result.CreateError(result.HResult)); } var textView = factoryService.GetWpfTextViewNoThrow(result.Value); return(Result.CreateSuccessNonNull(textView)); }
public VsCodeWindowManager(TLanguageService languageService, IVsCodeWindow codeWindow) { _languageService = languageService; _codeWindow = codeWindow; _threadingContext = languageService.Package.ComponentModel.GetService <IThreadingContext>(); var listenerProvider = languageService.Package.ComponentModel.GetService <IAsynchronousOperationListenerProvider>(); _asynchronousOperationListener = listenerProvider.GetListener(FeatureAttribute.NavigationBar); _sink = ComEventSink.Advise <IVsCodeWindowEvents>(codeWindow, this); }
internal VsFilterKeysAdapter( IVsFilterKeys filterKeys, IVsCodeWindow codeWindow, IVsAdapter vsAdapter, IVimBuffer buffer) { _filterKeys = filterKeys; _buffer = buffer; _vsAdapter = vsAdapter; _codeWindow = codeWindow; _buffer.Closed += delegate { Uninstall(); }; }
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); } } }
/// <include file='doc\CodeWindowManager.uex' path='docs/doc[@for="CodeWindowManager.Close"]/*' /> /// <summary>Closes all view filters, and the document properties window</summary> public void Close() { Trace.WriteLine("CodeWindowManager::Close"); if (this.properties != null) { this.properties.Close(); } CloseFilters(); this.viewFilters = null; properties = null; service = null; source = null; this.codeWindow = null; }
public TextBufferEventListener(EditorFactoryBase editorFactory, IComponentModel compModel, IVsTextLines textLines, IVsTextManager textMgr, IVsCodeWindow window) { _editorFactory = editorFactory; _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); }
public CodeEditorHost(IVsTextLines textBuffer) { ThreadHelper.ThrowIfNotOnUIThread(); var editorSvc = Services.GetComponentService <IVsEditorAdaptersFactoryService>(); codeWindow = editorSvc.CreateVsCodeWindowAdapter(Services.ServiceProvider); // disable splitter since it will cause a crash var codeWindowEx = (IVsCodeWindowEx)codeWindow; var initView = new INITVIEW[1]; ErrorHandler.ThrowOnFailure(codeWindowEx.Initialize( (uint)_codewindowbehaviorflags.CWB_DISABLESPLITTER, VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_Filter, szNameAuxUserContext: string.Empty, szValueAuxUserContext: string.Empty, InitViewFlags: 0, pInitView: initView)); var buffer = editorSvc.GetDataBuffer(textBuffer); if (buffer == null) { ErrorHandler.ThrowOnFailure(VSConstants.VS_E_INCOMPATIBLEDOCDATA); } ErrorHandler.ThrowOnFailure(codeWindow.SetBuffer(textBuffer)); //needed for xeto/jeto files, not implemented for c# etc so we don't worry about the result //Guid clsIdView = VSConstants.LOGVIEWID.TextView_guid; //codeWindow.SetViewClassID(ref clsIdView); ErrorHandler.ThrowOnFailure(codeWindow.GetPrimaryView(out viewAdapter)); // get the view first so host is created //var wpfView = editorSvc.GetWpfTextView(viewAdapter); textViewHost = editorSvc.GetWpfTextViewHost(viewAdapter); wpfElement = textViewHost?.HostControl; if (wpfElement != null) { // get real host? var parent = VisualTreeHelper.GetParent(wpfElement) as System.Windows.FrameworkElement; while (parent != null) { wpfElement = parent; parent = VisualTreeHelper.GetParent(wpfElement) as System.Windows.FrameworkElement; } } }
private IntPtr CreateCodeView(IVsTextLines textLines, ref string editorCaption, ref Guid cmdUI) { Type codeWindowType = typeof(IVsCodeWindow); Guid riid = codeWindowType.GUID; Guid clsid = typeof(VsCodeWindowClass).GUID; IVsCodeWindow window = (IVsCodeWindow)_package.CreateInstance(ref clsid, ref riid, codeWindowType); ErrorHandler.ThrowOnFailure(window.SetBuffer(textLines)); ErrorHandler.ThrowOnFailure(window.SetBaseEditorCaption(null)); ErrorHandler.ThrowOnFailure(window.GetEditorCaption(READONLYSTATUS.ROSTATUS_Unknown, out editorCaption)); cmdUI = VSConstants.GUID_TextEditorFactory; return(Marshal.GetIUnknownForObject(window)); }
public void ClearEditor() { if (this.vsCodeWindow != null) { this.vsCodeWindow.Close(); this.vsCodeWindow = null; } if (this.vsTextView != null) { this.vsTextView.CloseView(); this.vsTextView = null; } }
public int GetCodeWindowManager(IVsCodeWindow pCodeWin, out IVsCodeWindowManager ppCodeWinMgr) { var model = _serviceProvider.GetService(typeof(SComponentModel)) as IComponentModel; var service = model.GetService<IVsEditorAdaptersFactoryService>(); IVsTextView textView; if (ErrorHandler.Succeeded(pCodeWin.GetPrimaryView(out textView))) { ppCodeWinMgr = new CodeWindowManager(pCodeWin, service.GetWpfTextView(textView), _componentModel); return VSConstants.S_OK; } ppCodeWinMgr = null; return VSConstants.E_FAIL; }
private IntPtr CreateTextView( IVsTextLines textLines, IntPtr docDataExisting, Guid languageServiceId, out string editorCaption) { IVsCodeWindow window = _adaptersFactory.CreateVsCodeWindowAdapter(VsServiceProvider); ErrorHandler.ThrowOnFailure(window.SetBuffer(textLines)); ErrorHandler.ThrowOnFailure(window.SetBaseEditorCaption(null)); ErrorHandler.ThrowOnFailure(window.GetEditorCaption(READONLYSTATUS.ROSTATUS_Unknown, out editorCaption)); CreateTextBufferInitializationTracker(textLines, docDataExisting, languageServiceId); return(Marshal.GetIUnknownForObject(window)); }
public CodeWindowManager(IVsCodeWindow codeWindow, IWpfTextView textView) { _window = codeWindow; _textView = textView; var model = CommonPackage.ComponentModel; var adaptersFactory = model.GetService<IVsEditorAdaptersFactoryService>(); var factory = model.GetService<IEditorOperationsFactoryService>(); EditFilter editFilter = _filter = new EditFilter(textView, factory.GetEditorOperations(textView)); var adapter = adaptersFactory.GetViewAdapter(textView); editFilter.AttachKeyboardFilter(adapter); var viewFilter = new TextViewFilter(); viewFilter.AttachFilter(adapter); }
/// <summary>Closes all view filters, and the document properties window</summary> internal void Close() { #if LANGTRACE Trace.WriteLine("CodeWindowManager::Close"); #endif #if DOCUMENT_PROPERTIES if (this.properties != null) this.properties.Close(); #endif CloseFilters(); this.viewFilters = null; #if DOCUMENT_PROPERTIES properties = null; #endif service = null; source = null; this.codeWindow = null; }
public int GetCodeWindowManager(IVsCodeWindow pCodeWin, out IVsCodeWindowManager ppCodeWinMgr) { var adaptersFactory = _serviceProvider.GetComponentModel().GetService<IVsEditorAdaptersFactoryService>(); IVsTextLines textLines; ErrorHandler.ThrowOnFailure(pCodeWin.GetBuffer(out textLines)); var textBuffer = adaptersFactory.GetDataBuffer(textLines); if (textBuffer == null) { ppCodeWinMgr = null; return VSConstants.E_FAIL; } ppCodeWinMgr = _serviceProvider.GetHlslToolsService().GetOrCreateCodeWindowManager(pCodeWin); return VSConstants.S_OK; }
public static bool IsReadOnly(this IVsCodeWindow codeWindow) { Contract.Requires <ArgumentNullException>(codeWindow != null, "codeWindow"); IVsCodeWindowEx codeWindowEx = codeWindow as IVsCodeWindowEx; if (codeWindowEx == null) { throw new NotSupportedException(); } int result = codeWindowEx.IsReadOnly(); ErrorHandler.ThrowOnFailure(result); return(result == VSConstants.S_OK); }
public int GetCodeWindowManager(IVsCodeWindow pCodeWin, out IVsCodeWindowManager ppCodeWinMgr) { var model = _serviceProvider.GetService(typeof(SComponentModel)) as IComponentModel; var service = model.GetService <IVsEditorAdaptersFactoryService>(); IVsTextView textView; if (ErrorHandler.Succeeded(pCodeWin.GetPrimaryView(out textView))) { ppCodeWinMgr = new CodeWindowManager(pCodeWin, service.GetWpfTextView(textView)); return(VSConstants.S_OK); } ppCodeWinMgr = null; return(VSConstants.E_FAIL); }
public static bool IsReadOnly([NotNull] this IVsCodeWindow codeWindow) { Requires.NotNull(codeWindow, nameof(codeWindow)); IVsCodeWindowEx codeWindowEx = codeWindow as IVsCodeWindowEx; if (codeWindowEx == null) { throw new NotSupportedException(); } int result = codeWindowEx.IsReadOnly(); ErrorHandler.ThrowOnFailure(result); return(result == VSConstants.S_OK); }
public AnkhCodeWindowManager(AnkhLanguage language, IVsCodeWindow window) : base(language) { if (window == null) { throw new ArgumentNullException("window"); } _window = window; _views = new List <IVsTextView>(); if (!TryHookConnectionPoint <IVsCodeWindowEvents>(_window, this, out _cookie)) { _cookie = 0; } }
private void CreateCodeEditor() { Guid clsidTextBuffer = typeof(VsTextBufferClass).GUID; Guid iidTextBuffer = VSConstants.IID_IUnknown; TextBuffer = (IVsTextBuffer)MySqlDataProviderPackage.Instance.CreateInstance( ref clsidTextBuffer, ref iidTextBuffer, typeof(object)); if (TextBuffer == null) { throw new Exception("Failed to create core editor"); } // first we need to site our buffer IObjectWithSite textBufferSite = TextBuffer as IObjectWithSite; if (textBufferSite != null) { textBufferSite.SetSite(psp); } // then we need to tell our buffer not to attempt to autodetect the // language settings IVsUserData userData = TextBuffer as IVsUserData; Guid g = EditorFactory.GuidVSBufferDetectLangSid; int result = userData.SetData(ref g, false); Guid clsidCodeWindow = typeof(VsCodeWindowClass).GUID; Guid iidCodeWindow = typeof(IVsCodeWindow).GUID; IVsCodeWindow pCodeWindow = (IVsCodeWindow)MySqlDataProviderPackage.Instance.CreateInstance( ref clsidCodeWindow, ref iidCodeWindow, typeof(IVsCodeWindow)); if (pCodeWindow == null) { throw new Exception("Failed to create core editor"); } // Give the text buffer to the code window. // We are giving up ownership of the text buffer! pCodeWindow.SetBuffer((IVsTextLines)TextBuffer); CodeWindow = pCodeWindow; }
public CodeWindowManager(IVsCodeWindow codeWindow, SVsServiceProvider serviceProvider, Smi.VisualStudio.Language.LanguagePreferences languagePreferences) { //System.Diagnostics.Contracts.Contract.Requires<ArgumentNullException>(codeWindow != null, "codeWindow"); //System.Diagnostics.Contracts.Contract.Requires<ArgumentNullException>(serviceProvider != null, "serviceProvider"); //System.Diagnostics.Contracts.Contract.Requires<ArgumentNullException>(languagePreferences != null, "languagePreferences"); Action<EventHandler> unregister = null; this._codeWindow = codeWindow; this._serviceProvider = serviceProvider; this._languagePreferences = languagePreferences; if (unregister == null) { unregister = delegate (EventHandler handler) { this._languagePreferences.PreferencesChanged -= handler; }; } this._languagePreferences.PreferencesChanged += WeakEvents.AsWeak(new EventHandler(this.HandleLanguagePreferencesChanged), unregister); }
void CreateCodeEditor() { var editorSvc = Services.GetComponentService <IVsEditorAdaptersFactoryService>(); codeWindow = editorSvc.CreateVsCodeWindowAdapter(Services.ServiceProvider); // disable splitter since it will cause a crash var codeWindowEx = (IVsCodeWindowEx)codeWindow; var initView = new INITVIEW[1]; ErrorHandler.ThrowOnFailure(codeWindowEx.Initialize( (uint)_codewindowbehaviorflags.CWB_DISABLESPLITTER, VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_Filter, szNameAuxUserContext: string.Empty, szValueAuxUserContext: string.Empty, InitViewFlags: 0, pInitView: initView)); ErrorHandler.ThrowOnFailure(codeWindow.SetBuffer(textBuffer)); //needed for xeto/jeto files, not implemented for c# etc so we don't worry about the result Guid clsIdView = VSConstants.LOGVIEWID.TextView_guid; //codeWindow.SetViewClassID(ref clsIdView); if (ErrorHandler.Succeeded(codeWindow.GetPrimaryView(out viewAdapter))) { // get the view first so host is created //var wpfView = editorSvc.GetWpfTextView(viewAdapter); wpfViewHost = editorSvc.GetWpfTextViewHost(viewAdapter); var wpfElement = wpfViewHost?.HostControl; if (wpfElement != null) { editorControl.Content = wpfElement.ToEto(); return; } } // something went wrong editorControl.Content = new Scrollable { Content = new Label { Text = "Could not load editor" } }; }
int IVsLanguageInfo.GetCodeWindowManager(IVsCodeWindow pCodeWin, out IVsCodeWindowManager ppCodeWinMgr) { IVsEditorAdaptersFactoryService adaptersFactory = ComponentModel.GetService <IVsEditorAdaptersFactoryService>(); IVsTextLines textLines; ErrorHandler.ThrowOnFailure(pCodeWin.GetBuffer(out textLines)); ITextBuffer textBuffer = adaptersFactory.GetDataBuffer(textLines); if (textBuffer == null) { ppCodeWinMgr = null; return(VSConstants.E_FAIL); } ppCodeWinMgr = GetCodeWindowManager(pCodeWin, textBuffer); return(VSConstants.S_OK); }
public VSGeneroCodeWindowManager(IServiceProvider serviceProvider, IVsCodeWindow codeWindow, IWpfTextView textView) { _serviceProvider = serviceProvider; _window = codeWindow; _textBuffer = textView.TextBuffer; // add the IWpfTextView (used by the QuickInfoSource for debugger info if (!_textBuffer.Properties.ContainsProperty(typeof(IWpfTextView))) { _textBuffer.Properties.AddProperty(typeof(IWpfTextView), textView); } else { _textBuffer.Properties[typeof(IWpfTextView)] = textView; } VSGeneroPackage.Instance.OnIdle += OnIdle; }
public CodeWindowManager(IVsCodeWindow codeWindow, IWpfTextView textView, IVsStatusbar statusBar) { _window = codeWindow; _textView = textView; var model = CommonPackage.ComponentModel; var adaptersFactory = model.GetService <IVsEditorAdaptersFactoryService>(); var factory = model.GetService <IEditorOperationsFactoryService>(); EditFilter editFilter = _filter = new EditFilter(textView, factory.GetEditorOperations(textView), statusBar); var textViewAdapter = adaptersFactory.GetViewAdapter(textView); editFilter.AttachKeyboardFilter(textViewAdapter); var viewFilter = new TextViewFilter(); viewFilter.AttachFilter(textViewAdapter); }
/// <summary> /// Cleans up an existing editor if we are about to put a new one in place, used to close down the old editor bits as well as /// nulling out any cached objects that we have that came from the now dead editor. /// </summary> private void ClearOldEditor() { if (this.codeWindow != null) { this.codeWindow.Close(); this.codeWindow = null; } if (this.textView != null) { this.textView.CloseView(); this.textView = null; } this.cachedEditorCommandTarget = null; this.cachedEditorFindTarget = null; this.invisibleEditor = null; }
public int GetCodeWindowManager(IVsCodeWindow pCodeWin, out IVsCodeWindowManager ppCodeWinMgr) { var adaptersFactory = _serviceProvider.GetComponentModel().GetService <IVsEditorAdaptersFactoryService>(); IVsTextLines textLines; ErrorHandler.ThrowOnFailure(pCodeWin.GetBuffer(out textLines)); var textBuffer = adaptersFactory.GetDataBuffer(textLines); if (textBuffer == null) { ppCodeWinMgr = null; return(VSConstants.E_FAIL); } ppCodeWinMgr = _languagePackage.GetOrCreateCodeWindowManager(pCodeWin); return(VSConstants.S_OK); }
public EditorNavigationDropdownBarClient(IVsCodeWindow codeWindow, IVsEditorAdaptersFactoryService editorAdaptersFactory, EditorNavigationSource source, IBufferGraphFactoryService bufferGraphFactoryService) { _codeWindow = codeWindow; _editorAdaptersFactory = editorAdaptersFactory; _source = source; _bufferGraphFactoryService = bufferGraphFactoryService; _currentTextView = editorAdaptersFactory.GetWpfTextView(codeWindow.GetLastActiveView()); _dispatcher = _currentTextView.VisualElement.Dispatcher; _imageList = new ImageList { ColorDepth = ColorDepth.Depth32Bit }; var connectionPointContainer = codeWindow as IConnectionPointContainer; if (connectionPointContainer != null) { var textViewEventsGuid = typeof(IVsCodeWindowEvents).GUID; IConnectionPoint connectionPoint; connectionPointContainer.FindConnectionPoint(ref textViewEventsGuid, out connectionPoint); connectionPoint?.Advise(this, out _codeWindowEventsCookie); } var primaryView = codeWindow.GetPrimaryView(); if (primaryView != null) { ((IVsCodeWindowEvents)this).OnNewView(primaryView); } var secondaryView = codeWindow.GetSecondaryView(); if (secondaryView != null) { ((IVsCodeWindowEvents)this).OnNewView(secondaryView); } _navigationItems = new List <EditorTypeNavigationTarget>(); source.NavigationTargetsChanged += OnNavigationTargetsChanged; UpdateNavigationTargets(); _currentTextView.Caret.PositionChanged += OnCaretPositionChanged; }
/// <include file='doc\EditorFactory.uex' path='docs/doc[@for="EditorFactory.CreateEditorView"]/*' /> /// <summary>Return docView IUnknown COM object.</summary> public virtual IntPtr CreateEditorView(string moniker, IVsTextLines buffer, string physicalView, out string editorCaption, out Guid cmdUI) { Type tcw = typeof(IVsCodeWindow); Guid riid = tcw.GUID; Guid clsid = typeof(VsCodeWindowClass).GUID; IntPtr docView = IntPtr.Zero; IVsCodeWindow window = (IVsCodeWindow)package.CreateInstance(ref clsid, ref riid, tcw); NativeMethods.ThrowOnFailure(window.SetBuffer(buffer)); NativeMethods.ThrowOnFailure(window.SetBaseEditorCaption(null)); NativeMethods.ThrowOnFailure(window.GetEditorCaption(READONLYSTATUS.ROSTATUS_Unknown, out editorCaption)); Guid CMDUIGUID_TextEditor = new Guid(0x8B382828, 0x6202, 0x11d1, 0x88, 0x70, 0x00, 0x00, 0xF8, 0x75, 0x79, 0xD2); cmdUI = CMDUIGUID_TextEditor; docView = Marshal.GetIUnknownForObject(window); return(docView); }
public static void WindowFrameGetTextView(IVsWindowFrame windowFrame, out IVsTextView textView) { textView = null; object pvar; windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocView, out pvar); if (pvar is IVsTextView) { textView = (IVsTextView)pvar; } else if (pvar is IVsCodeWindow) { IVsCodeWindow codeWin = (IVsCodeWindow)pvar; VsTextView vsTextView; codeWin.GetPrimaryView(out vsTextView); textView = (IVsTextView)vsTextView; } }
public VSCodeEditorWindow(ServiceBroker sb, VSCodeEditorUserControl parent) { Parent = parent; services = sb; coreEditor = new VSCodeEditor(Parent, services); //Create window IVsCodeWindow win = coreEditor.CodeWindow; cmdTarget = win as IOleCommandTarget; IVsTextView textView; int hr = win.GetPrimaryView(out textView); if (hr != VSConstants.S_OK) { Marshal.ThrowExceptionForHR(hr); } // assign the window handle IntPtr commandHwnd = textView.GetWindowHandle(); AssignHandle(commandHwnd); //// Register priority command target, this dispatches mappable keys like Enter, Backspace, Arrows, etc. //hr = services.VsRegisterPriorityCommandTarget.RegisterPriorityCommandTarget( // 0, (IOleCommandTarget)CommandBroker.Broker, out cmdTargetCookie); //if (hr != VSConstants.S_OK) // Marshal.ThrowExceptionForHR(hr); lock (typeof(EditorBroker)) { if (EditorBroker.Broker == null) { EditorBroker.CreateSingleton(services); } EditorBroker.RegisterEditor(this); } //Add message filter //Application.AddMessageFilter((System.Windows.Forms.IMessageFilter)this); }
public void Dispose() { if (!disposed) { this.disposed = true; this.editorCommandTarget = null; ((IVsPersistDocData)this.textBuffer).Close(); this.textBuffer = null; this.textViewHost.Close(); this.textViewHost = null; this.codeWindow.Close(); this.codeWindow = null; this.textView.CloseView(); this.textView = null; } }
/// <include file='doc\EditorFactory.uex' path='docs/doc[@for="EditorFactory.CreateEditorView"]/*' /> /// <summary>Return docView IUnknown COM object.</summary> public virtual IntPtr CreateEditorView(string moniker, IVsTextLines buffer, string physicalView, out string editorCaption, out Guid cmdUI) { Type tcw = typeof(IVsCodeWindow); Guid riid = tcw.GUID; // Once this is done the project's assembly reference to "$(EnvRefPath)\Microsoft.VisualStudio.Editor.dll" may be removed Guid clsid = typeof(VsCodeWindowClass).GUID; IntPtr docView = IntPtr.Zero; IVsCodeWindow window = (IVsCodeWindow)package.CreateInstance(ref clsid, ref riid, tcw); Marshal.ThrowExceptionForHR(window.SetBuffer(buffer)); Marshal.ThrowExceptionForHR(window.SetBaseEditorCaption(null)); Marshal.ThrowExceptionForHR(window.GetEditorCaption(READONLYSTATUS.ROSTATUS_Unknown, out editorCaption)); Guid CMDUIGUID_TextEditor = new Guid(0x8B382828, 0x6202, 0x11d1, 0x88, 0x70, 0x00, 0x00, 0xF8, 0x75, 0x79, 0xD2); cmdUI = CMDUIGUID_TextEditor; docView = Marshal.GetIUnknownForObject(window); return(docView); }
public void Close() { object window = _window; _window = null; if (window != null) { if (_cookie != 0) { ReleaseHook<IVsCodeWindowEvents>(window, _cookie); _cookie = 0; } if (Marshal.IsComObject(window)) try { Marshal.ReleaseComObject(window); } catch { } } }
/// <include file='doc\CodeWindowManager.uex' path='docs/doc[@for="CodeWindowManager.Close"]/*' /> /// <summary>Closes all view filters, and the document properties window</summary> internal void Close() { #if LANGTRACE Trace.WriteLine("CodeWindowManager::Close"); #endif #if DOCUMENT_PROPERTIES if (this.properties != null) { this.properties.Close(); } #endif CloseFilters(); this.viewFilters = null; #if DOCUMENT_PROPERTIES properties = null; #endif service = null; source = null; this.codeWindow = null; }
public int GetCodeWindowManager(IVsCodeWindow pCodeWin, out IVsCodeWindowManager ppCodeWinMgr) { #if !DEV12_OR_LATER var model = _serviceProvider.GetService(typeof(SComponentModel)) as IComponentModel; var service = model.GetService<IVsEditorAdaptersFactoryService>(); IVsTextView textView; if (ErrorHandler.Succeeded(pCodeWin.GetPrimaryView(out textView))) { var wpfView = service.GetWpfTextView(textView); var controller = DjangoIntellisenseControllerProvider.GetOrCreateController(model, wpfView); controller.AttachKeyboardFilter(); #if DEV11 new TextViewFilter(textView); #endif } #endif ppCodeWinMgr = null; return VSConstants.E_FAIL; }
public NavigationBarClient( IVsDropdownBarManager manager, IVsCodeWindow codeWindow, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl workspace) { _manager = manager; _codeWindow = codeWindow; _workspace = workspace; _imageService = (IVsImageService2)serviceProvider.GetService(typeof(SVsImageService)); _projectItems = SpecializedCollections.EmptyList <NavigationBarProjectItem>(); _currentTypeItems = SpecializedCollections.EmptyList <NavigationBarItem>(); _codeWindowEventsSink = ComEventSink.Advise <IVsCodeWindowEvents>(codeWindow, this); _editorAdaptersFactoryService = serviceProvider.GetMefService <IVsEditorAdaptersFactoryService>(); codeWindow.GetPrimaryView(out var pTextView); StartTrackingView(pTextView); codeWindow.GetSecondaryView(out pTextView); StartTrackingView(pTextView); }
public virtual void RemoveAdornments() { if (dropDownHelper != null) { IVsDropdownBarManager dbm =(IVsDropdownBarManager)this.codeWindow; dbm.RemoveDropdownBar(); dropDownHelper.Done(); dropDownHelper = null; } foreach (ViewFilter f in this.viewFilters) { f.Close(); } this.viewFilters.Clear(); this.service.CloseSource(this.source); this.source = null; service.RemoveCodeWindowManager(this); this.codeWindow = null; GC.Collect(); }
public CodeWindowManager(IVsCodeWindow codeWindow, IWpfTextView textView) { _window = codeWindow; _textView = textView; var model = JToolsPackage.ComponentModel; var adaptersFactory = model.GetService<IVsEditorAdaptersFactoryService>(); IEditorOperationsFactoryService factory = model.GetService<IEditorOperationsFactoryService>(); EditFilter editFilter = _filter = new EditFilter(textView, factory.GetEditorOperations(textView)); IntellisenseController intellisenseController = IntellisenseControllerProvider.GetOrCreateController(model, textView); var adapter = adaptersFactory.GetViewAdapter(textView); editFilter.AttachKeyboardFilter(adapter); intellisenseController.AttachKeyboardFilter(); #if DEV11 var viewFilter = new TextViewFilter(); viewFilter.AttachFilter(adapter); #endif }
private IVsTextView GetTextView(IVsWindowFrame windowFrame) { ThreadHelper.ThrowIfNotOnUIThread(); if (windowFrame == null) { throw new ArgumentException("windowFrame"); } try { object pvar; int hr = windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_DocView, out pvar); if (!VSErr.Succeeded(hr)) { return(null); } IVsTextView textView = pvar as IVsTextView; if (textView == null) { IVsCodeWindow codeWin = pvar as IVsCodeWindow; if (codeWin != null) { hr = codeWin.GetPrimaryView(out textView); if (!VSErr.Succeeded(hr)) { return(null); } } } return(textView); } catch /* Handle broken frame implementations that throw errors instead of * returning null or an error HResult */ { return(null); } }
public DropdownBarClient( ITextBuffer textBuffer, IVsDropdownBarManager manager, IVsCodeWindow codeWindow, IServiceProvider serviceProvider): base(textBuffer) { Logger.Trace($"{nameof(DropdownBarClient)}:Ctor"); _manager = manager; _codeWindow = codeWindow; _serviceProvider = serviceProvider; _projectItems = ImmutableList<NavigationItem>.Empty; _taskItems = ImmutableList<NavigationItem>.Empty; _dispatcher = Dispatcher.CurrentDispatcher; _activeSelections = new Dictionary<int, int>(); _focusedCombo = -1; _trackedViews = new Dictionary<IVsTextView, IWpfTextView>(); _workspaceRegistration = Workspace.GetWorkspaceRegistration(TextBuffer.AsTextContainer()); _workspaceRegistration.WorkspaceChanged += OnWorkspaceRegistrationChanged; VSColorTheme.ThemeChanged += OnThemeChanged; var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel)); _editorAdaptersFactoryService=componentModel.GetService<IVsEditorAdaptersFactoryService>(); _comEventSink = ComEventSink.Advise<IVsCodeWindowEvents>(codeWindow, this); IVsTextView pTextView; codeWindow.GetPrimaryView(out pTextView); ConnectView(pTextView); codeWindow.GetSecondaryView(out pTextView); ConnectView(pTextView); ConnectToWorkspace(_workspaceRegistration.Workspace); UpdateImageList(); }
public EditorNavigationDropdownBarClient(IVsCodeWindow codeWindow, IVsEditorAdaptersFactoryService editorAdaptersFactory, EditorNavigationSource source, IBufferGraphFactoryService bufferGraphFactoryService) { _codeWindow = codeWindow; _editorAdaptersFactory = editorAdaptersFactory; _source = source; _bufferGraphFactoryService = bufferGraphFactoryService; _currentTextView = editorAdaptersFactory.GetWpfTextView(codeWindow.GetLastActiveView()); _dispatcher = _currentTextView.VisualElement.Dispatcher; _imageList = new ImageList { ColorDepth = ColorDepth.Depth32Bit }; var connectionPointContainer = codeWindow as IConnectionPointContainer; if (connectionPointContainer != null) { var textViewEventsGuid = typeof(IVsCodeWindowEvents).GUID; IConnectionPoint connectionPoint; connectionPointContainer.FindConnectionPoint(ref textViewEventsGuid, out connectionPoint); connectionPoint?.Advise(this, out _codeWindowEventsCookie); } var primaryView = codeWindow.GetPrimaryView(); if (primaryView != null) ((IVsCodeWindowEvents)this).OnNewView(primaryView); var secondaryView = codeWindow.GetSecondaryView(); if (secondaryView != null) ((IVsCodeWindowEvents)this).OnNewView(secondaryView); _navigationItems = new List<EditorTypeNavigationTarget>(); source.NavigationTargetsChanged += OnNavigationTargetsChanged; UpdateNavigationTargets(); _currentTextView.Caret.PositionChanged += OnCaretPositionChanged; }
public IEditorNavigationDropdownBarClient CreateEditorNavigationDropdownBar(IVsCodeWindow codeWindow, IVsEditorAdaptersFactoryService editorAdaptersFactory) { // a code window can only be associated with a single buffer, so the primary view will get us the correct information IVsTextView primaryViewAdapter = codeWindow.GetPrimaryView(); IWpfTextView textView = editorAdaptersFactory.GetWpfTextView(primaryViewAdapter); IBufferGraph bufferGraph = BufferGraphFactoryService.CreateBufferGraph(textView.TextBuffer); Collection<ITextBuffer> buffers = bufferGraph.GetTextBuffers(i => true); List<IEditorNavigationSource> sources = new List<IEditorNavigationSource>(); foreach (ITextBuffer buffer in buffers) { var bufferProviders = NavigationSourceProviders.Where(provider => provider.Metadata.ContentTypes.Any(contentType => buffer.ContentType.IsOfType(contentType))); var bufferSources = bufferProviders .Select(provider => provider.Value.TryCreateEditorNavigationSource(buffer)) .Where(source => source != null); sources.AddRange(bufferSources); } return new EditorNavigationDropdownBar(codeWindow, editorAdaptersFactory, sources, BufferGraphFactoryService, EditorNavigationTypeRegistryService); }
protected virtual IVsCodeWindowManager GetCodeWindowManager(IVsCodeWindow codeWindow, ITextBuffer textBuffer) { //System.Diagnostics.Contracts.Contract.Requires<ArgumentNullException>(codeWindow != null, "codeWindow"); //System.Diagnostics.Contracts.Contract.Requires<ArgumentNullException>(textBuffer != null, "textBuffer"); return textBuffer.Properties.GetOrCreateSingletonProperty<CodeWindowManager>(() => new CodeWindowManager(codeWindow, this.ServiceProvider, this.LanguagePreferences)); }
int IVsLanguageInfo.GetCodeWindowManager(IVsCodeWindow pCodeWin, out IVsCodeWindowManager ppCodeWinMgr) { IVsTextLines lines; IVsEditorAdaptersFactoryService service = this.ComponentModel.GetService<IVsEditorAdaptersFactoryService>(); ErrorHandler.ThrowOnFailure(pCodeWin.GetBuffer(out lines)); IVsTextBuffer bufferAdapter = lines; ITextBuffer dataBuffer = service.GetDataBuffer(bufferAdapter); if (dataBuffer == null) { ppCodeWinMgr = null; return -2147467259; } ppCodeWinMgr = this.GetCodeWindowManager(pCodeWin, dataBuffer); return 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); }
public CodeWindowManager(LanguagePackageBase languagePackage, IVsCodeWindow codeWindow, SVsServiceProvider serviceProvider) : base(languagePackage, codeWindow, serviceProvider) { }
protected virtual AnkhCodeWindowManager CreateCodeWindowManager(IVsCodeWindow codeWindow) { return new AnkhCodeWindowManager(this, codeWindow); }
public int GetCodeWindowManager(IVsCodeWindow pCodeWin, out IVsCodeWindowManager ppCodeWinMgr) { ppCodeWinMgr = new CodeWindowManager(_componentModel.GetService<IVsEditorAdaptersFactoryService>()); return VSConstants.S_OK; }