// ---------------------------------------------------------------------------------- /// <summary> /// Initialize the editor /// </summary> // ---------------------------------------------------------------------------------- private void InitializeEditor() { const string message = ""; var componentModel = (IComponentModel)Microsoft.VisualStudio.Shell.Package.GetGlobalService( typeof(SComponentModel)); _OleServiceProvider = (IServiceProvider)GetService(typeof(IServiceProvider)); _BufferFactory = componentModel.GetService <ITextBufferFactoryService>(); _EditorAdapterFactory = componentModel.GetService <IVsEditorAdaptersFactoryService>(); _BufferAdapter = _EditorAdapterFactory.CreateVsTextBufferAdapter(_OleServiceProvider, _BufferFactory.TextContentType); _BufferAdapter.InitializeContent(message, message.Length); _ViewAdapter = _EditorAdapterFactory.CreateVsTextViewAdapter(_OleServiceProvider); ((IVsWindowPane)_ViewAdapter).SetSite(_OleServiceProvider); var initView = new[] { new INITVIEW() }; initView[0].fSelectionMargin = 0; // original: 0 initView[0].fWidgetMargin = 0; // original: 0 initView[0].fVirtualSpace = 0; initView[0].fDragDropMove = 1; initView[0].fVirtualSpace = 0; _ViewAdapter.Initialize(_BufferAdapter as IVsTextLines, IntPtr.Zero, (uint)TextViewInitFlags.VIF_HSCROLL | (uint)TextViewInitFlags3.VIF_NO_HWND_SUPPORT, initView); }
protected override void Initialize() { base.Initialize(); IComponentModel compMod = GetService(typeof(SComponentModel)) as IComponentModel; ITextBufferFactoryService bufferFactory = compMod.GetService <ITextBufferFactoryService>(); ITextEditorFactoryService editorFactory = compMod.GetService <ITextEditorFactoryService>(); IVsEditorAdaptersFactoryService adapterFactory = compMod.GetService <IVsEditorAdaptersFactoryService>(); IContentTypeRegistryService registryService = compMod.GetService <IContentTypeRegistryService>(); //completionBroker = compMod.GetService<ICompletionBroker>(); textView = adapterFactory.CreateVsTextViewAdapter(GetService(typeof(IOleServiceProvider)) as IOleServiceProvider); IVsTextBuffer textBuffer = adapterFactory.CreateVsTextBufferAdapter(GetService(typeof(IOleServiceProvider)) as IOleServiceProvider); uint textViewInitFlags = (uint)TextViewInitFlags.VIF_DEFAULT | (uint)TextViewInitFlags.VIF_HSCROLL | (uint)TextViewInitFlags.VIF_VSCROLL; textBuffer.InitializeContent("", 0); textView.Initialize(textBuffer as IVsTextLines, IntPtr.Zero, textViewInitFlags, null); // Create Dev10 objects _textView = adapterFactory.GetWpfTextView(textView); mefTextBuffer = adapterFactory.GetDataBuffer(textBuffer); IVsUserData userData = textView as IVsUserData; if (userData != null) { Guid g = Microsoft.VisualStudio.Editor.DefGuidList.guidIWpfTextViewHost; object obj; int hr = userData.GetData(ref g, out obj); if (hr == VSConstants.S_OK) { _textViewHost = obj as IWpfTextViewHost; } } // disable zoom view _textView.Options.SetOptionValue(DefaultTextViewHostOptions.ZoomControlId, false); //Initialize the history if (null == history) { history = new HistoryBuffer(); } adapterFactory.GetWpfTextView(textView).Caret.MoveTo(new SnapshotPoint(mefTextBuffer.CurrentSnapshot, mefTextBuffer.CurrentSnapshot.Length)); IContentType ivsdContentType = registryService.GetContentType(VSDContentTypeDefinition.ContentType); mefTextBuffer.ChangeContentType(ivsdContentType, null); // init console input WriteConsoleInputSymbol(); return; }
private IVsTextView CreateVsTextView(IVsTextBuffer vsTextBuffer, params string[] textViewRoles) { var textViewRoleSet = _textEditorFactoryService.CreateTextViewRoleSet(textViewRoles); var vsTextView = _vsEditorAdaptersFactoryService.CreateVsTextViewAdapter(_oleServiceProvider, textViewRoleSet); var hr = vsTextView.Initialize((IVsTextLines)vsTextBuffer, IntPtr.Zero, 0, null); ErrorHandler.ThrowOnFailure(hr); return(vsTextView); }
IWpfTextView IInteractiveWindowEditorFactoryService.CreateTextView(IInteractiveWindow window, ITextBuffer buffer, ITextViewRoleSet roles) { var bufferAdapter = _adapterFactory.CreateVsTextBufferAdapterForSecondaryBuffer(_provider, buffer); // Create and initialize text view adapter. // WARNING: This might trigger various services like IntelliSense, margins, taggers, etc. var textViewAdapter = _adapterFactory.CreateVsTextViewAdapter(_provider, roles); var commandFilter = new VsInteractiveWindowCommandFilter(_adapterFactory, window, textViewAdapter, bufferAdapter); window.Properties[typeof(VsInteractiveWindowCommandFilter)] = commandFilter; return(commandFilter.TextViewHost.TextView); }
//<summary> //Instantiates a ViewportAdornment1 manager when a textView is created. //</summary> //<param name="textView">The <see cref="IWpfTextView"/> upon which the adornment should be placed</param> public void TextViewCreated(IWpfTextView textView) { IComponentModel componentModel = ServiceProvider.GetService(typeof(SComponentModel)) as IComponentModel; IVsEditorAdaptersFactoryService editorFactory = componentModel.GetService <IVsEditorAdaptersFactoryService>(); IServiceProvider sp = Package.GetGlobalService( typeof(Microsoft.VisualStudio.OLE.Interop.IServiceProvider)) as Microsoft.VisualStudio.OLE.Interop.IServiceProvider; IVsTextView vsTextView = editorFactory.CreateVsTextViewAdapter(sp); var tve = new TextViewExtensions(editorFactory); new ViewportAdornment1(textView, tve); }
public void InitializeEditor() { VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(); IOleServiceProvider oleServiceProvider = codeWindowHost.ServiceProvider; bufferAdapter = editorAdapterFactoryService.CreateVsTextBufferAdapter(oleServiceProvider, codeSnippetContentType); int result = bufferAdapter.InitializeContent("", 0); viewAdapter = editorAdapterFactoryService.CreateVsTextViewAdapter(oleServiceProvider); ((IVsWindowPane)viewAdapter).SetSite(oleServiceProvider); var initView = new[] { new INITVIEW() }; initView[0].fSelectionMargin = 1; initView[0].fWidgetMargin = 0; initView[0].fVirtualSpace = 0; initView[0].fDragDropMove = 1; initView[0].fVirtualSpace = 0; uint readOnlyValue = 0; if (codeWindowHost.ReadOnlyCodeWindow) { readOnlyValue = (uint)TextViewInitFlags2.VIF_READONLY; } uint flags = (uint)TextViewInitFlags.VIF_SET_SELECTION_MARGIN | (uint)TextViewInitFlags.VIF_SET_DRAGDROPMOVE | (uint)TextViewInitFlags2.VIF_SUPPRESS_STATUS_BAR_UPDATE | (uint)TextViewInitFlags2.VIF_SUPPRESSBORDER | (uint)TextViewInitFlags2.VIF_SUPPRESSTRACKCHANGES | (uint)TextViewInitFlags2.VIF_SUPPRESSTRACKGOBACK | (uint)TextViewInitFlags.VIF_HSCROLL | (uint)TextViewInitFlags.VIF_VSCROLL | (uint)TextViewInitFlags3.VIF_NO_HWND_SUPPORT | readOnlyValue; viewAdapter.Initialize(bufferAdapter as IVsTextLines, Handle, flags, initView); }
private void InitializeEditor() { IComponentModel m_componentModel = (IComponentModel)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SComponentModel)); oleServiceProvider = (IOleServiceProvider)GetService(typeof(IOleServiceProvider)); bufferFactory = m_componentModel.GetService <ITextBufferFactoryService>(); m_EditorAdapterFactory = m_componentModel.GetService <IVsEditorAdaptersFactoryService>(); bufferAdapter = m_EditorAdapterFactory.CreateVsTextBufferAdapter(oleServiceProvider, bufferFactory.TextContentType); int result = bufferAdapter.InitializeContent("ed", 2); viewAdapter = m_EditorAdapterFactory.CreateVsTextViewAdapter(oleServiceProvider); ((IVsWindowPane)viewAdapter).SetSite(oleServiceProvider); INITVIEW[] _initView = new INITVIEW[] { new INITVIEW() }; _initView[0].fSelectionMargin = 0; _initView[0].fWidgetMargin = 0; _initView[0].fVirtualSpace = 0; _initView[0].fDragDropMove = 1; _initView[0].fVirtualSpace = 0; viewAdapter.Initialize(bufferAdapter as IVsTextLines, IntPtr.Zero, (uint)TextViewInitFlags.VIF_HSCROLL | (uint)TextViewInitFlags3.VIF_NO_HWND_SUPPORT, _initView); }
protected override void Initialize() { base.Initialize(); IComponentModel compMod = GetService(typeof(SComponentModel)) as IComponentModel; ITextBufferFactoryService bufferFactory = compMod.GetService <ITextBufferFactoryService>(); ITextEditorFactoryService editorFactory = compMod.GetService <ITextEditorFactoryService>(); IVsEditorAdaptersFactoryService adapterFactory = compMod.GetService <IVsEditorAdaptersFactoryService>(); IContentTypeRegistryService registryService = compMod.GetService <IContentTypeRegistryService>(); completionBroker = compMod.GetService <ICompletionBroker>(); textView = adapterFactory.CreateVsTextViewAdapter(GetService(typeof(IOleServiceProvider)) as IOleServiceProvider); IVsTextBuffer textBuffer = adapterFactory.CreateVsTextBufferAdapter(GetService(typeof(IOleServiceProvider)) as IOleServiceProvider); uint textViewInitFlags = (uint)TextViewInitFlags.VIF_DEFAULT | (uint)TextViewInitFlags.VIF_HSCROLL | (uint)TextViewInitFlags.VIF_VSCROLL; textBuffer.InitializeContent("", 0); textView.Initialize(textBuffer as IVsTextLines, IntPtr.Zero, textViewInitFlags, null); // Create Dev10 objects _textView = adapterFactory.GetWpfTextView(textView); mefTextBuffer = adapterFactory.GetDataBuffer(textBuffer); IVsUserData userData = textView as IVsUserData; if (userData != null) { Guid g = Microsoft.VisualStudio.Editor.DefGuidList.guidIWpfTextViewHost; object obj; int hr = userData.GetData(ref g, out obj); if (hr == VSConstants.S_OK) { _textViewHost = obj as IWpfTextViewHost; } } //Initialize the history history = new HistoryBuffer(); // Create the stream on top of the text buffer. textStream = new TextBufferStream(mefTextBuffer); // Initialize the engine. InitializeEngine(); IContentType ipContentType = registryService.GetContentType(PyContentTypeDefinition.ConsoleContentType); mefTextBuffer.ChangeContentType(ipContentType, null); adapterFactory.GetWpfTextView(textView).Caret.MoveTo(new SnapshotPoint(mefTextBuffer.CurrentSnapshot, mefTextBuffer.CurrentSnapshot.Length)); // Set the title of the window. this.Caption = Resources.ToolWindowTitle; // Set the icon of the toolwindow. this.BitmapResourceID = 301; this.BitmapIndex = 0; return; }
// ---------------------------------------------------------------------------------- /// <summary> /// Initialize the editor /// </summary> // ---------------------------------------------------------------------------------- private void InitializeEditor() { const string message = ""; var componentModel = (IComponentModel)Microsoft.VisualStudio.Shell.Package.GetGlobalService( typeof(SComponentModel)); _OleServiceProvider = (IServiceProvider)GetService(typeof(IServiceProvider)); _BufferFactory = componentModel.GetService<ITextBufferFactoryService>(); _EditorAdapterFactory = componentModel.GetService<IVsEditorAdaptersFactoryService>(); _BufferAdapter = _EditorAdapterFactory.CreateVsTextBufferAdapter(_OleServiceProvider, _BufferFactory.TextContentType); _BufferAdapter.InitializeContent(message, message.Length); _ViewAdapter = _EditorAdapterFactory.CreateVsTextViewAdapter(_OleServiceProvider); ((IVsWindowPane)_ViewAdapter).SetSite(_OleServiceProvider); var initView = new[] { new INITVIEW() }; initView[0].fSelectionMargin = 0; // original: 0 initView[0].fWidgetMargin = 0; // original: 0 initView[0].fVirtualSpace = 0; initView[0].fDragDropMove = 1; initView[0].fVirtualSpace = 0; _ViewAdapter.Initialize(_BufferAdapter as IVsTextLines, IntPtr.Zero, (uint)TextViewInitFlags.VIF_HSCROLL | (uint)TextViewInitFlags3.VIF_NO_HWND_SUPPORT, initView); }