public void Create(int instanceId) { var evaluator = CreateInteractiveEvaluator(_vsServiceProvider, _classifierAggregator, _contentTypeRegistry, _vsWorkspace); Debug.Assert(_vsInteractiveWindow == null); // ForceCreate means that the window should be created if the persisted layout indicates that it is visible. _vsInteractiveWindow = _vsInteractiveWindowFactory.Create(Id, instanceId, Title, evaluator, __VSCREATETOOLWIN.CTW_fForceCreate); _vsInteractiveWindow.SetLanguage(LanguageServiceGuid, evaluator.ContentType); if (_vsInteractiveWindow is ToolWindowPane interactiveWindowPane) { evaluator.OnBeforeReset += is64bit => interactiveWindowPane.Caption = Title + (is64bit ? " (64-bit)" : " (32-bit)"); } var window = _vsInteractiveWindow.InteractiveWindow; window.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.SuggestionMarginId, true); void closeEventDelegate(object sender, EventArgs e) { window.TextView.Closed -= closeEventDelegate; LogCloseSession(evaluator.SubmissionCount); evaluator.Dispose(); } // the tool window now owns the engine: window.TextView.Closed += closeEventDelegate; // vsWindow.AutoSaveOptions = true; // fire and forget: window.InitializeAsync(); LogSession(LogMessage.Window, LogMessage.Create); }
public IVsInteractiveWindow Create(int instanceId) { var evaluator = CreateInteractiveEvaluator(_vsServiceProvider, _classifierAggregator, _contentTypeRegistry, _vsWorkspace); // ForceCreate means that the window should be created if the persisted layout indicates that it is visible. var vsWindow = _vsInteractiveWindowFactory.Create(Id, instanceId, Title, evaluator, __VSCREATETOOLWIN.CTW_fForceCreate); vsWindow.SetLanguage(LanguageServiceGuid, evaluator.ContentType); // the tool window now owns the engine: vsWindow.InteractiveWindow.TextView.Closed += new EventHandler((_, __) => { LogSession(LogMessage.Window, LogMessage.Close); evaluator.Dispose(); }); // vsWindow.AutoSaveOptions = true; var window = vsWindow.InteractiveWindow; // fire and forget: window.InitializeAsync(); LogSession(LogMessage.Window, LogMessage.Create); return(vsWindow); }
public IVsInteractiveWindow Create(int instanceId) { var evaluator = CreateInteractiveEvaluator(_vsServiceProvider, _classifierAggregator, _contentTypeRegistry, _vsWorkspace); // ForceCreate means that the window should be created if the persisted layout indicates that it is visible. var vsWindow = _vsInteractiveWindowFactory.Create(Id, instanceId, Title, evaluator, __VSCREATETOOLWIN.CTW_fForceCreate); vsWindow.SetLanguage(LanguageServiceGuid, evaluator.ContentType); vsWindow.InteractiveWindow.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.SuggestionMarginId, true); EventHandler closeEventDelegate = null; closeEventDelegate = (sender, e) => { vsWindow.InteractiveWindow.TextView.Closed -= closeEventDelegate; InteractiveWindow.InteractiveWindow intWindow = vsWindow.InteractiveWindow as InteractiveWindow.InteractiveWindow; LogCloseSession(intWindow.LanguageBufferCounter); evaluator.Dispose(); }; // the tool window now owns the engine: vsWindow.InteractiveWindow.TextView.Closed += closeEventDelegate; // vsWindow.AutoSaveOptions = true; var window = vsWindow.InteractiveWindow; // fire and forget: window.InitializeAsync(); LogSession(LogMessage.Window, LogMessage.Create); return(vsWindow); }
private IVsInteractiveWindow CreateInteractiveWindowInternal( IInteractiveEvaluator evaluator, IContentType contentType, bool alwaysCreate, int id, string title, Guid languageServiceGuid, string replId ) { var creationFlags = __VSCREATETOOLWIN.CTW_fMultiInstance | __VSCREATETOOLWIN.CTW_fActivateWithProject; if (alwaysCreate) { creationFlags |= __VSCREATETOOLWIN.CTW_fForceCreate; } var replWindow = _windowFactory.Create(GuidList.guidPythonInteractiveWindowGuid, id, title, evaluator, creationFlags); replWindow.InteractiveWindow.Properties[VsInteractiveWindowKey] = replWindow; var toolWindow = replWindow as ToolWindowPane; if (toolWindow != null) { toolWindow.BitmapImageMoniker = KnownMonikers.PYInteractiveWindow; } replWindow.SetLanguage(GuidList.guidPythonLanguageServiceGuid, contentType); replWindow.InteractiveWindow.InitializeAsync(); return(replWindow); }
public void Create(int instanceId) { var evaluator = CreateInteractiveEvaluator( _vsServiceProvider, _classifierAggregator, _contentTypeRegistry, _vsWorkspace ); Debug.Assert(_vsInteractiveWindow == null); // ForceCreate means that the window should be created if the persisted layout indicates that it is visible. _vsInteractiveWindow = _vsInteractiveWindowFactory.Create( Id, instanceId, Title, evaluator, __VSCREATETOOLWIN.CTW_fForceCreate ); _vsInteractiveWindow.SetLanguage(LanguageServiceGuid, evaluator.ContentType); if (_vsInteractiveWindow is ToolWindowPane interactiveWindowPane) { evaluator.OnBeforeReset += platform => interactiveWindowPane.Caption = Title + platform switch { InteractiveHostPlatform.Desktop64 => " (.NET Framework " + ServicesVSResources.Bitness64 + ")", InteractiveHostPlatform.Desktop32 => " (.NET Framework " + ServicesVSResources.Bitness32 + ")", InteractiveHostPlatform.Core => " (.NET Core)", _ => throw ExceptionUtilities.Unreachable }; } var window = _vsInteractiveWindow.InteractiveWindow; window.TextView.Options.SetOptionValue( DefaultTextViewHostOptions.SuggestionMarginId, true ); void closeEventDelegate(object sender, EventArgs e) { window.TextView.Closed -= closeEventDelegate; LogCloseSession(evaluator.SubmissionCount); evaluator.Dispose(); } // the tool window now owns the engine: window.TextView.Closed += closeEventDelegate; // vsWindow.AutoSaveOptions = true; // fire and forget: window.InitializeAsync(); LogSession(LogMessage.Window, LogMessage.Create); }
private IVsInteractiveWindow CreateInteractiveWindowInternal( IInteractiveEvaluator evaluator, IContentType contentType, bool alwaysCreate, int id, string title, Guid languageServiceGuid, string replId ) { var creationFlags = __VSCREATETOOLWIN.CTW_fMultiInstance | __VSCREATETOOLWIN.CTW_fActivateWithProject; if (alwaysCreate) { creationFlags |= __VSCREATETOOLWIN.CTW_fForceCreate; } #if DEV15_OR_LATER var windowFactory2 = _windowFactory as IVsInteractiveWindowFactory2; var replWindow = windowFactory2.Create( GuidList.guidPythonInteractiveWindowGuid, id, title, evaluator, creationFlags, GuidList.guidPythonToolsCmdSet, PythonConstants.ReplWindowToolbar, null ); #else var replWindow = _windowFactory.Create( GuidList.guidPythonInteractiveWindowGuid, id, title, evaluator, creationFlags ); #endif replWindow.InteractiveWindow.Properties[VsInteractiveWindowKey] = replWindow; var toolWindow = replWindow as ToolWindowPane; if (toolWindow != null) { toolWindow.BitmapImageMoniker = KnownMonikers.PYInteractiveWindow; } replWindow.SetLanguage(GuidList.guidPythonLanguageServiceGuid, contentType); var selectEval = evaluator as SelectableReplEvaluator; if (selectEval != null) { selectEval.ProvideInteractiveWindowEvents(InteractiveWindowEvents.GetOrCreate(replWindow)); } _serviceProvider.GetUIThread().InvokeTaskSync(() => replWindow.InteractiveWindow.InitializeAsync(), CancellationToken.None); return(replWindow); }
public IVsInteractiveWindow Create() { var evaluator = new DebuggerEvaluator(_vsDebugger); // TODO: localize var vsWindow = _vsInteractiveWindowFactory.Create(VsImmediateWindowPackage.Id, 0, "Immediate Window", evaluator); // the tool window now owns the engine: vsWindow.InteractiveWindow.TextView.Closed += new EventHandler((_, __) => evaluator.Dispose()); var window = vsWindow.InteractiveWindow; // fire and forget: window.InitializeAsync(); return(vsWindow); }
public IVsInteractiveWindow Create(int instanceId) { var evaluator = CreateInteractiveEvaluator(_vsServiceProvider, _classifierAggregator, _contentTypeRegistry, _vsWorkspace); var vsWindow = _vsInteractiveWindowFactory.Create(Id, instanceId, Title, evaluator, 0); vsWindow.SetLanguage(LanguageServiceGuid, evaluator.ContentType); // the tool window now owns the engine: vsWindow.InteractiveWindow.TextView.Closed += new EventHandler((_, __) => evaluator.Dispose()); // vsWindow.AutoSaveOptions = true; var window = vsWindow.InteractiveWindow; // fire and forget: window.InitializeAsync(); return(vsWindow); }
private ReplWindowInfo CreateReplWindowInternal(IReplEvaluator evaluator, IContentType contentType, string[] roles, int id, string title, Guid languageServiceGuid, string replId) { var service = (IVsUIShell)ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShell)); var model = (IComponentModel)ServiceProvider.GlobalProvider.GetService(typeof(SComponentModel)); SaveReplInfo(id, evaluator, contentType, roles, title, languageServiceGuid, replId); // we don't pass __VSCREATETOOLWIN.CTW_fMultiInstance because multi instance panes are // destroyed when closed. We are really multi instance but we don't want to be closed. This // seems to work fine. __VSCREATETOOLWIN creationFlags = 0; if (!roles.Contains("DontPersist")) { creationFlags |= __VSCREATETOOLWIN.CTW_fForceCreate; } var replWindow = _windowFactory.Create(GuidList.guidPythonInteractiveWindowGuid, id, title, evaluator, creationFlags); replWindow.SetLanguage(GuidList.guidPythonLanguageServiceGuid, contentType); replWindow.InteractiveWindow.InitializeAsync(); return(_windows[id] = new ReplWindowInfo(replWindow, replId)); }
private IVsInteractiveWindow CreateInteractiveWindowInternal( IInteractiveEvaluator evaluator, IContentType contentType, bool alwaysCreate, int id, string title, Guid languageServiceGuid, string replId ) { var creationFlags = __VSCREATETOOLWIN.CTW_fMultiInstance | __VSCREATETOOLWIN.CTW_fActivateWithProject; if (alwaysCreate) { creationFlags |= __VSCREATETOOLWIN.CTW_fForceCreate; } #if DEV15_OR_LATER var windowFactory2 = _windowFactory as IVsInteractiveWindowFactory2; var replWindow = windowFactory2.Create( CommonGuidList.guidPythonInteractiveWindowGuid, id, title, evaluator, creationFlags, CommonGuidList.guidPythonToolsCmdSet, PythonConstants.ReplWindowToolbar, null ); #else var replWindow = _windowFactory.Create( CommonGuidList.guidPythonInteractiveWindowGuid, id, title, evaluator, creationFlags ); #endif replWindow.InteractiveWindow.Properties[VsInteractiveWindowId] = id; replWindow.InteractiveWindow.Properties[VsInteractiveWindowKey] = replWindow; var toolWindow = replWindow as ToolWindowPane; if (toolWindow != null) { toolWindow.BitmapImageMoniker = KnownMonikers.PYInteractiveWindow; } // Initializes the command filters with the base Python content type // so that our MEF exports, such as ReplWindowCreationListener, are activated. var pythonContentType = _contentTypeService.GetContentType(PythonCoreConstants.ContentType); replWindow.SetLanguage(CommonGuidList.guidPythonLanguageServiceGuid, pythonContentType); var selectEval = evaluator as SelectableReplEvaluator; if (selectEval != null) { selectEval.ProvideInteractiveWindowEvents(InteractiveWindowEvents.GetOrCreate(replWindow)); } // Start repl but don't wait. It will block on the main thread replWindow.InteractiveWindow.InitializeAsync().DoNotWait(); return(replWindow); }