提交 a89447cc 编写于 作者: D Daniel Imms

Add focus terminal command

Fixes #7189
上级 282fc4ba
......@@ -10,7 +10,7 @@ import {SyncActionDescriptor} from 'vs/platform/actions/common/actions';
import {registerSingleton} from 'vs/platform/instantiation/common/extensions';
import {IWorkbenchActionRegistry, Extensions as ActionExtensions} from 'vs/workbench/common/actionRegistry';
import {TerminalService} from 'vs/workbench/parts/terminal/electron-browser/terminalService';
import {ToggleTerminalAction} from 'vs/workbench/parts/terminal/electron-browser/terminalActions';
import {FocusTerminalAction, ToggleTerminalAction} from 'vs/workbench/parts/terminal/electron-browser/terminalActions';
import {ITerminalService, TERMINAL_PANEL_ID, TERMINAL_DEFAULT_SHELL_LINUX, TERMINAL_DEFAULT_SHELL_OSX, TERMINAL_DEFAULT_SHELL_WINDOWS} from 'vs/workbench/parts/terminal/electron-browser/terminal';
import * as panel from 'vs/workbench/browser/panel';
import {Registry} from 'vs/platform/platform';
......@@ -53,10 +53,8 @@ configurationRegistry.registerConfiguration({
}
});
// Register Service
registerSingleton(ITerminalService, TerminalService);
// Register Output Panel
(<panel.PanelRegistry>Registry.as(panel.Extensions.Panels)).registerPanel(new panel.PanelDescriptor(
'vs/workbench/parts/terminal/electron-browser/terminalPanel',
'TerminalPanel',
......@@ -65,10 +63,10 @@ registerSingleton(ITerminalService, TerminalService);
'terminal'
));
// Register toggle output action globally
let actionRegistry = <IWorkbenchActionRegistry>Registry.as(ActionExtensions.WorkbenchActions);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ToggleTerminalAction, ToggleTerminalAction.ID, ToggleTerminalAction.LABEL, {
primary: KeyMod.CtrlCmd | KeyCode.US_BACKTICK,
// on mac cmd+` is reserved to cycle between windows
mac: { primary: KeyMod.WinCtrl | KeyCode.US_BACKTICK }
}), 'View: ' + ToggleTerminalAction.LABEL, nls.localize('viewCategory', "View"));
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(FocusTerminalAction, FocusTerminalAction.ID, FocusTerminalAction.LABEL), FocusTerminalAction.LABEL);
......@@ -37,5 +37,6 @@ export interface ITerminalConfiguration {
export interface ITerminalService {
serviceId: ServiceIdentifier<any>;
focus(): TPromise<any>;
toggle(): TPromise<any>;
}
......@@ -23,4 +23,21 @@ export class ToggleTerminalAction extends Action {
public run(event?: any): TPromise<any> {
return this.terminalService.toggle();
}
}
export class FocusTerminalAction extends Action {
public static ID = 'workbench.action.terminal.focus';
public static LABEL = nls.localize('focusTerminal', "Focus Integrated Terminal");
constructor(
id: string, label: string,
@ITerminalService private terminalService: ITerminalService
) {
super(id, label);
}
public run(event?: any): TPromise<any> {
return this.terminalService.focus();
}
}
\ No newline at end of file
......@@ -17,6 +17,10 @@ export class TerminalService implements ITerminalService {
) {
}
public focus(): TPromise<any> {
return this.panelService.openPanel(TERMINAL_PANEL_ID, true);
}
public toggle(): TPromise<any> {
const panel = this.panelService.getActivePanel();
if (panel && panel.getId() === TERMINAL_PANEL_ID) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册