protected string GetText(IInteractiveWindowVisualComponent window) { string text = null; if (TextView.Selection.IsActive && !TextView.Selection.IsEmpty) { // If the user has a selection, we want to use it.. StringBuilder tmpText = new StringBuilder(); foreach (var span in TextView.Selection.SelectedSpans) { foreach (var code in window.TextView.MapDownToR(span)) { // we never include the current input buffer in the appended code if (span.Snapshot.TextBuffer != window.CurrentLanguageBuffer) { tmpText.Append(code.GetText()); } } } if (tmpText.Length > 0) { text = tmpText.ToString(); } } else { // Otherwise use the selection that the caret is currently in, if it's not the // current language buffer var langBuffer = window.TextView.MapDownToR(window.TextView.Caret.Position.BufferPosition); if (langBuffer != null && langBuffer.Value.Snapshot.TextBuffer != window.CurrentLanguageBuffer) { text = TrimText(langBuffer.Value.Snapshot.GetText()); } } return text; }
public async Task <IInteractiveWindowVisualComponent> GetOrCreateVisualComponent(IInteractiveWindowComponentContainerFactory componentContainerFactory, int instanceId = 0) { Shell.AssertIsOnMainThread(); if (ActiveWindow != null) { // Right now only one instance of interactive window is allowed if (instanceId != 0) { throw new InvalidOperationException("Right now only one instance of interactive window is allowed"); } return(ActiveWindow); } var evaluator = RInstallationHelper.VerifyRIsInstalled(Shell, _settings.RBasePath) ? new RInteractiveEvaluator(RSession, History, Shell, _settings) : (IInteractiveEvaluator) new NullInteractiveEvaluator(); ActiveWindow = componentContainerFactory.Create(instanceId, evaluator); var interactiveWindow = ActiveWindow.InteractiveWindow; interactiveWindow.TextView.Closed += (_, __) => evaluator.Dispose(); _operations.InteractiveWindow = interactiveWindow; await interactiveWindow.InitializeAsync(); ActiveWindow.Container.UpdateCommandStatus(true); return(ActiveWindow); }
public async Task InitializeAsync() { await _workflow.RSessions.TrySwitchBrokerAsync(nameof(RPlotIntegrationUITest)); _interactiveWindow = await _workflow.GetOrCreateVisualComponentAsync(); _plotVisualComponent.Control.Width = 600; _plotVisualComponent.Control.Height = 500; _containerDisposable = await _containerHost.AddToHost(_plotVisualComponent.Control); }
public async Task InitializeAsync() { await _workflow.RSessions.TrySwitchBrokerAsync(nameof(RPlotIntegrationTest)); _replVisualComponent = await _workflow.GetOrCreateVisualComponentAsync(); _plotDeviceVisualComponentContainerFactory.DeviceProperties = new PlotDeviceProperties(600, 500, 96); }
public async Task InitializeAsync() { _plotVisualComponent.Control.Width = 600; _plotVisualComponent.Control.Height = 500; _replVisualComponent = await _workflow.GetOrCreateVisualComponent(_componentContainerFactory); _containerDisposable = await _containerHost.AddToHost(_plotVisualComponent.Control); }
private SnapshotPoint?MapUp(IInteractiveWindowVisualComponent window, SnapshotPoint point) { return(window.TextView.BufferGraph.MapUpToBuffer( point, PointTrackingMode.Positive, PositionAffinity.Successor, TextView.TextBuffer )); }
public async Task InitializeAsync() { await _remoteBroker.ConnectAsync(_workflow.RSessions); _replVisualComponent = await _workflow.GetOrCreateVisualComponentAsync(); _plotManager = (IRPlotManagerVisual)_workflow.Plots; _plotDeviceVisualComponentContainerFactory.DeviceProperties = new PlotDeviceProperties(600, 500, 96); }
private void UpdateInteractiveWindowIfRequired(IInteractiveWindowVisualComponent newInteractiveWindow) { var oldInteractiveWindow = Interlocked.Exchange(ref _lastActiveWindow, newInteractiveWindow); if (oldInteractiveWindow == newInteractiveWindow) { return; } IVsUIShell shell = VsAppShell.Current.GetGlobalService<IVsUIShell>(typeof(SVsUIShell)); shell.UpdateCommandUI(1); }
private void UpdateInteractiveWindowIfRequired(IInteractiveWindowVisualComponent newInteractiveWindow) { var oldInteractiveWindow = Interlocked.Exchange(ref _lastActiveWindow, newInteractiveWindow); if (oldInteractiveWindow == newInteractiveWindow) { return; } _coreShell.UI().UpdateCommandStatus(immediate: true); }
private void UpdateInteractiveWindowIfRequired(IInteractiveWindowVisualComponent newInteractiveWindow) { var oldInteractiveWindow = Interlocked.Exchange(ref _lastActiveWindow, newInteractiveWindow); if (oldInteractiveWindow == newInteractiveWindow) { return; } IVsUIShell shell = VsAppShell.Current.GetGlobalService <IVsUIShell>(typeof(SVsUIShell)); shell.UpdateCommandUI(1); }
private async Task CreateVisualComponentAsync(int instanceId) { var factory = Services.GetService <IInteractiveWindowComponentContainerFactory>(); var evaluator = new RInteractiveEvaluator(RSessions, RSession, History, Connections, Services, _settings, Console); var window = factory.Create(instanceId, evaluator, RSessions); var interactiveWindow = window.InteractiveWindow; interactiveWindow.TextView.Closed += (_, __) => evaluator.Dispose(); _operations.InteractiveWindow = interactiveWindow; if (!RSessions.HasBroker) { var connectedToBroker = await Connections.TryConnectToPreviouslyUsedAsync(); if (!connectedToBroker) { var showConnectionsWindow = Connections.RecentConnections.Any(); if (!showConnectionsWindow) { var message = Resources.NoLocalR.FormatInvariant(Environment.NewLine + Environment.NewLine, Environment.NewLine); var ui = Services.UI(); showConnectionsWindow = ui.ShowMessage(message, MessageButtons.YesNo) == MessageButtons.No; } if (!showConnectionsWindow) { var installer = Services.GetService <IMicrosoftRClientInstaller>(); installer.LaunchRClientSetup(Services); } else { var toolWindows = Services.GetService <IRInteractiveWorkflowToolWindowService>(); toolWindows.Connections().Show(focus: false, immediate: false); } } } await interactiveWindow.InitializeAsync(); RSession.RestartOnBrokerSwitch = true; ActiveWindow = window; ActiveWindow.Container.UpdateCommandStatus(true); _visualComponentTcs.SetResult(ActiveWindow); ActiveWindowChanged?.Invoke(this, new ActiveWindowChangedEventArgs(window)); }
private async Task WriteAsync(string text, bool isError) { await _workflow.Shell.SwitchToMainThreadAsync(); if (_component == null) { _component = await _workflow.GetOrCreateVisualComponentAsync(); _component.Container.Show(focus: false, immediate: false); } if (isError) { _component.InteractiveWindow.WriteError(text); } else { _component.InteractiveWindow.Write(text); } }
protected string GetText(IInteractiveWindowVisualComponent window) { string text = null; if (TextView.Selection.IsActive && !TextView.Selection.IsEmpty) { // If the user has a selection, we want to use it.. StringBuilder tmpText = new StringBuilder(); foreach (var span in TextView.Selection.SelectedSpans) { foreach (var code in window.TextView.MapDownToR(span)) { // we never include the current input buffer in the appended code if (span.Snapshot.TextBuffer != window.CurrentLanguageBuffer) { tmpText.Append(code.GetText()); } } } if (tmpText.Length > 0) { text = tmpText.ToString(); } } else { // Otherwise use the selection that the caret is currently in, if it's not the // current language buffer var langBuffer = window.TextView.MapDownToR(window.TextView.Caret.Position.BufferPosition); if (langBuffer != null && langBuffer.Value.Snapshot.TextBuffer != window.CurrentLanguageBuffer) { text = TrimText(langBuffer.Value.Snapshot.GetText()); } } return(text); }
public async Task InitializeAsync() { var componentFactory = _exportProvider.GetExportedValue <IInteractiveWindowComponentContainerFactory>(); _workflowComponent = await UIThreadHelper.Instance.Invoke(() => _workflow.GetOrCreateVisualComponent(componentFactory)); }
public InteractiveWindowChangedEventArgs(IInteractiveWindowVisualComponent oldWindow, IInteractiveWindowVisualComponent newWindow) { Old = oldWindow; New = newWindow; }
public async Task InitializeAsync() { _workflowComponent = await UIThreadHelper.Instance.Invoke(() => _workflow.GetOrCreateVisualComponentAsync()); }
private async Task CreateVisualComponentAsync(int instanceId) { var factory = Shell.ExportProvider.GetExportedValue<IInteractiveWindowComponentContainerFactory>(); var evaluator = new RInteractiveEvaluator(RSessions, RSession, History, Connections, Shell, _settings, new InteractiveWindowConsole(this)); var window = factory.Create(instanceId, evaluator, RSessions); var interactiveWindow = window.InteractiveWindow; interactiveWindow.TextView.Closed += (_, __) => evaluator.Dispose(); _operations.InteractiveWindow = interactiveWindow; if (!RSessions.HasBroker) { var connectedToBroker = await Connections.TryConnectToPreviouslyUsedAsync(); if (!connectedToBroker) { var showConnectionsWindow = Connections.RecentConnections.Any(); if (!showConnectionsWindow){ var message = Resources.NoLocalR.FormatInvariant(Environment.NewLine + Environment.NewLine, Environment.NewLine); showConnectionsWindow = Shell.ShowMessage(message, MessageButtons.YesNo) == MessageButtons.Yes; } if (!showConnectionsWindow) { var installer = Shell.ExportProvider.GetExportedValue<IMicrosoftRClientInstaller>(); installer.LaunchRClientSetup(Shell); } else { Connections.GetOrCreateVisualComponent().Container.Show(focus: false, immediate: false); } } } await interactiveWindow.InitializeAsync(); ActiveWindow = window; ActiveWindow.Container.UpdateCommandStatus(true); _visualComponentTcs.SetResult(ActiveWindow); ActiveWindowChanged?.Invoke(this, new ActiveWindowChangedEventArgs(window)); }
public ActiveWindowChangedEventArgs(IInteractiveWindowVisualComponent window) { Window = window; }
private SnapshotPoint? MapUp(IInteractiveWindowVisualComponent window, SnapshotPoint point) { return window.TextView.BufferGraph.MapUpToBuffer( point, PointTrackingMode.Positive, PositionAffinity.Successor, TextView.TextBuffer ); }
public async Task<IInteractiveWindowVisualComponent> GetOrCreateVisualComponent(IInteractiveWindowComponentContainerFactory componentContainerFactory, int instanceId = 0) { // Right now only one instance of interactive window is allowed if (ActiveWindow != null) { throw new InvalidOperationException("Right now only one instance of interactive window is allowed"); } _coreShell.AssertIsOnMainThread(); var evaluator = RInstallationHelper.VerifyRIsInstalled(_coreShell, _settings.RBasePath) ? new RInteractiveEvaluator(RSession, History, _coreShell, _settings) : (IInteractiveEvaluator) new NullInteractiveEvaluator(); ActiveWindow = componentContainerFactory.Create(instanceId, evaluator); var interactiveWindow = ActiveWindow.InteractiveWindow; interactiveWindow.TextView.Closed += (_, __) => evaluator.Dispose(); _operations.InteractiveWindow = interactiveWindow; await interactiveWindow.InitializeAsync(); ActiveWindow.Container.UpdateCommandStatus(true); return ActiveWindow; }
public async Task InitializeAsync() { var componentFactory = _exportProvider.GetExportedValue<IInteractiveWindowComponentContainerFactory>(); _workflowComponent = await UIThreadHelper.Instance.Invoke(() => _workflow.GetOrCreateVisualComponent(componentFactory)); }
public async Task InitializeAsync() { _plotDeviceVisualComponentContainerFactory.DeviceProperties = new PlotDeviceProperties(600, 500, 96); _replVisualComponent = await _workflow.GetOrCreateVisualComponent(_componentContainerFactory); }