diff options
6 files changed, 108 insertions, 10 deletions
diff --git a/src/vs/workbench/parts/terminal/browser/terminalQuickOpen.ts b/src/vs/workbench/parts/terminal/browser/terminalQuickOpen.ts index 7fabfc6d869..89054824270 100644 --- a/src/vs/workbench/parts/terminal/browser/terminalQuickOpen.ts +++ b/src/vs/workbench/parts/terminal/browser/terminalQuickOpen.ts @@ -14,6 +14,7 @@ import { QuickOpenModel, QuickOpenEntryGroup, QuickOpenEntry } from 'vs/base/par import { QuickOpenHandler } from 'vs/workbench/browser/quickopen'; import { ITerminalService } from 'vs/workbench/parts/terminal/common/terminal'; import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; +import { ContributableActionProvider } from 'vs/workbench/browser/actions'; export class TerminalEntry extends QuickOpenEntryGroup { @@ -79,7 +80,7 @@ export class TerminalPickerHandler extends QuickOpenHandler { return true; }); - return TPromise.as(new QuickOpenModel(entries)); + return TPromise.as(new QuickOpenModel(entries, new ContributableActionProvider())); } private getTerminals(): TerminalEntry[] { diff --git a/src/vs/workbench/parts/terminal/electron-browser/media/configure-inverse.svg b/src/vs/workbench/parts/terminal/electron-browser/media/configure-inverse.svg new file mode 100644 index 00000000000..61baaea2b8b --- /dev/null +++ b/src/vs/workbench/parts/terminal/electron-browser/media/configure-inverse.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g fill="#C5C5C5"><path d="M12.714 9.603c-.07.207-.15.407-.246.601l1.017 2.139c-.335.424-.718.807-1.142 1.143l-2.14-1.018c-.193.097-.394.176-.601.247l-.795 2.235c-.265.03-.534.05-.807.05-.272 0-.541-.02-.806-.05l-.795-2.235c-.207-.071-.408-.15-.602-.247l-2.14 1.017c-.424-.336-.807-.719-1.143-1.143l1.017-2.139c-.094-.193-.175-.393-.245-.6l-2.236-.796c-.03-.265-.05-.534-.05-.807s.02-.542.05-.807l2.236-.795c.07-.207.15-.407.246-.601l-1.016-2.139c.336-.423.719-.807 1.143-1.142l2.14 1.017c.193-.096.394-.176.602-.247l.793-2.236c.265-.03.534-.05.806-.05.273 0 .542.02.808.05l.795 2.236c.207.07.407.15.601.246l2.14-1.017c.424.335.807.719 1.142 1.142l-1.017 2.139c.096.194.176.394.246.601l2.236.795c.029.266.049.535.049.808s-.02.542-.05.807l-2.236.796zm-4.714-4.603c-1.657 0-3 1.343-3 3s1.343 3 3 3 3-1.343 3-3-1.343-3-3-3z"/><circle cx="8" cy="8" r="1.5"/></g></svg>
\ No newline at end of file diff --git a/src/vs/workbench/parts/terminal/electron-browser/media/configure.svg b/src/vs/workbench/parts/terminal/electron-browser/media/configure.svg new file mode 100644 index 00000000000..3dec2ba50fd --- /dev/null +++ b/src/vs/workbench/parts/terminal/electron-browser/media/configure.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><g fill="#424242"><path d="M12.714 9.603c-.07.207-.15.407-.246.601l1.017 2.139c-.335.424-.718.807-1.142 1.143l-2.14-1.018c-.193.097-.394.176-.601.247l-.795 2.235c-.265.03-.534.05-.807.05-.272 0-.541-.02-.806-.05l-.795-2.235c-.207-.071-.408-.15-.602-.247l-2.14 1.017c-.424-.336-.807-.719-1.143-1.143l1.017-2.139c-.094-.193-.175-.393-.245-.6l-2.236-.796c-.03-.265-.05-.534-.05-.807s.02-.542.05-.807l2.236-.795c.07-.207.15-.407.246-.601l-1.016-2.139c.336-.423.719-.807 1.143-1.142l2.14 1.017c.193-.096.394-.176.602-.247l.793-2.236c.265-.03.534-.05.806-.05.273 0 .542.02.808.05l.795 2.236c.207.07.407.15.601.246l2.14-1.017c.424.335.807.719 1.142 1.142l-1.017 2.139c.096.194.176.394.246.601l2.236.795c.029.266.049.535.049.808s-.02.542-.05.807l-2.236.796zm-4.714-4.603c-1.657 0-3 1.343-3 3s1.343 3 3 3 3-1.343 3-3-1.343-3-3-3z"/><circle cx="8" cy="8" r="1.5"/></g></svg>
\ No newline at end of file diff --git a/src/vs/workbench/parts/terminal/electron-browser/media/terminal.css b/src/vs/workbench/parts/terminal/electron-browser/media/terminal.css index 6e777ea549f..8fc3d445adc 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/media/terminal.css +++ b/src/vs/workbench/parts/terminal/electron-browser/media/terminal.css @@ -79,4 +79,13 @@ .vs-dark .monaco-workbench.mac .panel.integrated-terminal .xterm-rows, .hc-black .monaco-workbench.mac .panel.integrated-terminal .xterm-rows { cursor: -webkit-image-set(url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAAL0lEQVQoz2NgCD3x//9/BhBYBWdhgFVAiVW4JBFKGIa4AqD0//9D3pt4I4tAdAMAHTQ/j5Zom30AAAAASUVORK5CYII=') 1x, url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAQAAADZc7J/AAAAz0lEQVRIx2NgYGBY/R8I/vx5eelX3n82IJ9FxGf6tksvf/8FiTMQAcAGQMDvSwu09abffY8QYSAScNk45G198eX//yev73/4///701eh//kZSARckrNBRvz//+8+6ZohwCzjGNjdgQxkAg7B9WADeBjIBqtJCbhRA0YNoIkBSNmaPEMoNmA0FkYNoFKhapJ6FGyAH3nauaSmPfwI0v/3OukVi0CIZ+F25KrtYcx/CTIy0e+rC7R1Z4KMICVTQQ14feVXIbR695u14+Ir4gwAAD49E54wc1kWAAAAAElFTkSuQmCC') 2x) 5 8, text; -}
\ No newline at end of file +} + +.monaco-workbench .quick-open-terminal-configure { + background-image: url('configure.svg'); +} + +.vs-dark .monaco-workbench .quick-open-terminal-configure, +.hc-black .monaco-workbench .quick-open-terminal-configure { + background-image: url('configure-inverse.svg'); +} diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts b/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts index a72ed6f9319..fe64fdb45ed 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts @@ -17,7 +17,7 @@ import { TERMINAL_DEFAULT_SHELL_LINUX, TERMINAL_DEFAULT_SHELL_OSX, TERMINAL_DEFA import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actionRegistry'; import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; -import { KillTerminalAction, CopyTerminalSelectionAction, CreateNewTerminalAction, FocusActiveTerminalAction, FocusNextTerminalAction, FocusPreviousTerminalAction, FocusTerminalAtIndexAction, SelectDefaultShellWindowsTerminalAction, RunSelectedTextInTerminalAction, RunActiveFileInTerminalAction, ScrollDownTerminalAction, ScrollDownPageTerminalAction, ScrollToBottomTerminalAction, ScrollUpTerminalAction, ScrollUpPageTerminalAction, ScrollToTopTerminalAction, TerminalPasteAction, ToggleTerminalAction, ClearTerminalAction, AllowWorkspaceShellTerminalCommand, DisallowWorkspaceShellTerminalCommand, RenameTerminalAction, SelectAllTerminalAction, FocusTerminalFindWidgetAction, HideTerminalFindWidgetAction, DeleteWordLeftTerminalAction, DeleteWordRightTerminalAction } from 'vs/workbench/parts/terminal/electron-browser/terminalActions'; +import { KillTerminalAction, CopyTerminalSelectionAction, CreateNewTerminalAction, FocusActiveTerminalAction, FocusNextTerminalAction, FocusPreviousTerminalAction, FocusTerminalAtIndexAction, SelectDefaultShellWindowsTerminalAction, RunSelectedTextInTerminalAction, RunActiveFileInTerminalAction, ScrollDownTerminalAction, ScrollDownPageTerminalAction, ScrollToBottomTerminalAction, ScrollUpTerminalAction, ScrollUpPageTerminalAction, ScrollToTopTerminalAction, TerminalPasteAction, ToggleTerminalAction, ClearTerminalAction, AllowWorkspaceShellTerminalCommand, DisallowWorkspaceShellTerminalCommand, RenameTerminalAction, SelectAllTerminalAction, FocusTerminalFindWidgetAction, HideTerminalFindWidgetAction, DeleteWordLeftTerminalAction, DeleteWordRightTerminalAction, QuickOpenActionTermContributor, QuickOpenTermAction, TERMINAL_PICKER_PREFIX } from 'vs/workbench/parts/terminal/electron-browser/terminalActions'; import { Registry } from 'vs/platform/registry/common/platform'; import { ShowAllCommandsAction } from 'vs/workbench/parts/quickopen/browser/commandsHandler'; import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; @@ -29,22 +29,39 @@ import { OpenNextRecentlyUsedEditorInGroupAction, OpenPreviousRecentlyUsedEditor import { EDITOR_FONT_DEFAULTS } from 'vs/editor/common/config/editorOptions'; import { registerColors } from './terminalColorRegistry'; import { NavigateUpAction, NavigateDownAction, NavigateLeftAction, NavigateRightAction } from "vs/workbench/electron-browser/actions"; -import { QUICKOPEN_ACTION_ID } from "vs/workbench/browser/parts/quickopen/quickopen"; +import { QUICKOPEN_ACTION_ID, getQuickNavigateHandler } from "vs/workbench/browser/parts/quickopen/quickopen"; import { IQuickOpenRegistry, Extensions as QuickOpenExtensions, QuickOpenHandlerDescriptor } from 'vs/workbench/browser/quickopen'; +import { Scope, IActionBarRegistry, Extensions as ActionBarExtensions } from 'vs/workbench/browser/actions'; +import { CommandsRegistry } from 'vs/platform/commands/common/commands'; -export const TERMINAL_PICKER_PREFIX = 'term '; const quickOpenRegistry = (<IQuickOpenRegistry>Registry.as(QuickOpenExtensions.Quickopen)); +const inTerminalsPicker = 'inTerminalPicker'; + quickOpenRegistry.registerQuickOpenHandler( new QuickOpenHandlerDescriptor( 'vs/workbench/parts/terminal/browser/terminalQuickOpen', 'TerminalPickerHandler', TERMINAL_PICKER_PREFIX, - null, + inTerminalsPicker, nls.localize('quickOpen.terminal', "Show All Opened Terminals") ) ); +const quickOpenNavigateNextInTerminalPickerId = 'workbench.action.quickOpenNavigateNextInTerminalPicker'; +CommandsRegistry.registerCommand( + quickOpenNavigateNextInTerminalPickerId, { handler: getQuickNavigateHandler(quickOpenNavigateNextInTerminalPickerId, true) }); + +const quickOpenNavigatePreviousInTerminalPickerId = 'workbench.action.quickOpenNavigatePreviousInTerminalPicker'; +CommandsRegistry.registerCommand( + quickOpenNavigatePreviousInTerminalPickerId, { handler: getQuickNavigateHandler(quickOpenNavigatePreviousInTerminalPickerId, false) }); + + +const registry = <IWorkbenchActionRegistry>Registry.as(ActionExtensions.WorkbenchActions); +registry.registerWorkbenchAction(new SyncActionDescriptor(QuickOpenTermAction, QuickOpenTermAction.ID, QuickOpenTermAction.LABEL), 'Quick Open Terminal'); +const actionBarRegistry = Registry.as<IActionBarRegistry>(ActionBarExtensions.Actionbar); +actionBarRegistry.registerActionBarContributor(Scope.VIEWER, QuickOpenActionTermContributor); + let configurationRegistry = <IConfigurationRegistry>Registry.as(Extensions.Configuration); configurationRegistry.registerConfiguration({ 'id': 'terminal', diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts index 4d3632ba2d0..9dd3a51ba85 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts @@ -18,6 +18,11 @@ import { IMessageService, Severity } from 'vs/platform/message/common/message'; import { attachSelectBoxStyler } from 'vs/platform/theme/common/styler'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; +import { ActionBarContributor } from 'vs/workbench/browser/actions'; +import { TerminalEntry } from 'vs/workbench/parts/terminal/browser/terminalQuickOpen'; +import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; + +export const TERMINAL_PICKER_PREFIX = 'term '; export class ToggleTerminalAction extends TogglePanelAction { @@ -607,14 +612,14 @@ export class RenameTerminalAction extends Action { constructor( id: string, label: string, - @IQuickOpenService private quickOpenService: IQuickOpenService, - @ITerminalService private terminalService: ITerminalService + @IQuickOpenService protected quickOpenService: IQuickOpenService, + @ITerminalService protected terminalService: ITerminalService ) { super(id, label); } - public run(): TPromise<any> { - const terminalInstance = this.terminalService.getActiveInstance(); + public run(terminal?: TerminalEntry): TPromise<any> { + const terminalInstance = terminal ? this.terminalService.getInstanceFromId(parseInt(terminal.getLabel().split(':')[0], 10)) : this.terminalService.getActiveInstance(); if (!terminalInstance) { return TPromise.as(void 0); } @@ -661,3 +666,67 @@ export class HideTerminalFindWidgetAction extends Action { return TPromise.as(this.terminalService.hideFindWidget()); } } + + +export class QuickOpenActionTermContributor extends ActionBarContributor { + + constructor( + @ITerminalService private terminalService: ITerminalService, + @IQuickOpenService private quickOpenService: IQuickOpenService, + @IInstantiationService private instantiationService: IInstantiationService + ) { + super(); + } + + public getActions(context: any): IAction[] { + let actions: Action[] = []; + if (context.element instanceof TerminalEntry) { + actions.push(this.instantiationService.createInstance(RenameTerminalQuickOpenAction, RenameTerminalQuickOpenAction.ID, RenameTerminalQuickOpenAction.LABEL, context.element)); + } + return actions; + } + + public hasActions(context: any): boolean { + return true; + } +} + +export class QuickOpenTermAction extends Action { + + public static ID = 'workbench.action.quickOpenTerm'; + public static LABEL = nls.localize('quickOpenTerm', "Switch active terminal"); + + constructor( + id: string, + label: string, + @IQuickOpenService private quickOpenService: IQuickOpenService + ) { + super(id, label); + } + + public run(): TPromise<void> { + return this.quickOpenService.show(TERMINAL_PICKER_PREFIX, null); + } +} + +export class RenameTerminalQuickOpenAction extends RenameTerminalAction { + + constructor( + id: string, label: string, + private terminal: TerminalEntry, + @IQuickOpenService quickOpenService: IQuickOpenService, + @ITerminalService terminalService: ITerminalService, + @IInstantiationService private instantiationService: IInstantiationService + ) { + super(id, label, quickOpenService, terminalService); + this.class = 'quick-open-terminal-configure'; + } + + public run(): TPromise<any> { + super.run(this.terminal) + // This timeout is needed to make sure the previous quickOpen has time to close before we show the next one + .then(() => TPromise.timeout(50)) + .then(result => this.quickOpenService.show(TERMINAL_PICKER_PREFIX, null)); + return TPromise.as(null); + } +}
\ No newline at end of file |