diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index cd1041bfee4..0f21f29d6d8 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -2971,6 +2971,10 @@ declare namespace vscode { dispose(): void; } + export interface Terminal { + name: string + } + /** * Represents an extension. * @@ -3429,6 +3433,8 @@ declare namespace vscode { * @return A new status bar item. */ export function createStatusBarItem(alignment?: StatusBarAlignment, priority?: number): StatusBarItem; + + export function createTerminal(name?: string): Terminal; } /** diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 00ff2824eca..850200fc065 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -18,6 +18,7 @@ import {ExtHostQuickOpen} from 'vs/workbench/api/node/extHostQuickOpen'; import {ExtHostStatusBar} from 'vs/workbench/api/node/extHostStatusBar'; import {ExtHostCommands} from 'vs/workbench/api/node/extHostCommands'; import {ExtHostOutputService} from 'vs/workbench/api/node/extHostOutputService'; +import {ExtHostTerminalService} from 'vs/workbench/api/node/extHostTerminalService'; import {ExtHostMessageService} from 'vs/workbench/api/node/extHostMessageService'; import {ExtHostEditors} from 'vs/workbench/api/node/extHostEditors'; import {ExtHostLanguages} from 'vs/workbench/api/node/extHostLanguages'; @@ -117,6 +118,7 @@ export class ExtHostAPIImplementation { const extHostMessageService = new ExtHostMessageService(threadService); const extHostStatusBar = new ExtHostStatusBar(threadService); const extHostOutputService = new ExtHostOutputService(threadService); + const extHostTerminalService = new ExtHostTerminalService(threadService); const workspacePath = contextService.getWorkspace() ? contextService.getWorkspace().resource.fsPath : undefined; const extHostWorkspace = new ExtHostWorkspace(threadService, workspacePath); const languages = new ExtHostLanguages(threadService); @@ -253,6 +255,9 @@ export class ExtHostAPIImplementation { }, createOutputChannel(name: string): vscode.OutputChannel { return extHostOutputService.createOutputChannel(name); + }, + createTerminal(name?: string): vscode.Terminal { + return extHostTerminalService.createTerminal(name); } }; diff --git a/src/vs/workbench/api/node/extHost.contribution.ts b/src/vs/workbench/api/node/extHost.contribution.ts index 406944d016f..bb86e048df3 100644 --- a/src/vs/workbench/api/node/extHost.contribution.ts +++ b/src/vs/workbench/api/node/extHost.contribution.ts @@ -28,6 +28,7 @@ import {MainThreadQuickOpen} from './mainThreadQuickOpen'; import {MainThreadStatusBar} from './mainThreadStatusBar'; import {MainThreadStorage} from './mainThreadStorage'; import {MainThreadTelemetry} from './mainThreadTelemetry'; +import {MainThreadTerminalService} from './mainThreadTerminalService'; import {MainThreadWorkspace} from './mainThreadWorkspace'; import {MainProcessExtensionService} from './mainThreadExtensionService'; import {MainThreadFileSystemEventService} from './mainThreadFileSystemEventService'; @@ -72,6 +73,7 @@ export class ExtHostContribution implements IWorkbenchContribution { col.define(MainContext.MainThreadStatusBar).set(create(MainThreadStatusBar)); col.define(MainContext.MainThreadStorage).set(create(MainThreadStorage)); col.define(MainContext.MainThreadTelemetry).set(create(MainThreadTelemetry)); + col.define(MainContext.MainThreadTerminalService).set(create(MainThreadTerminalService)); col.define(MainContext.MainThreadWorkspace).set(create(MainThreadWorkspace)); if (this.extensionService instanceof MainProcessExtensionService) { col.define(MainContext.MainProcessExtensionService).set(this.extensionService); diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index c2c8b8f6137..b3f9a11a011 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -146,6 +146,10 @@ export abstract class MainThreadOutputServiceShape { $close(channelId: string): TPromise { throw ni(); } } +export abstract class MainThreadTerminalServiceShape { + $createTerminal(name?: string) { throw ni(); } +} + export interface MyQuickPickItems extends IPickOpenEntry { handle: number; } @@ -294,6 +298,7 @@ export const MainContext = { MainThreadStatusBar: createMainId('MainThreadStatusBar', MainThreadStatusBarShape), MainThreadStorage: createMainId('MainThreadStorage', MainThreadStorageShape), MainThreadTelemetry: createMainId('MainThreadTelemetry', MainThreadTelemetryShape), + MainThreadTerminalService: createMainId('MainThreadTerminalService', MainThreadTerminalServiceShape), MainThreadWorkspace: createMainId('MainThreadWorkspace', MainThreadWorkspaceShape), MainProcessExtensionService: createMainId('MainProcessExtensionService', MainProcessExtensionServiceShape), }; diff --git a/src/vs/workbench/api/node/extHostTerminalService.ts b/src/vs/workbench/api/node/extHostTerminalService.ts new file mode 100644 index 00000000000..0c8f0718971 --- /dev/null +++ b/src/vs/workbench/api/node/extHostTerminalService.ts @@ -0,0 +1,34 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; + +import {IThreadService} from 'vs/workbench/services/thread/common/threadService'; +import vscode = require('vscode'); +import {MainContext, MainThreadTerminalServiceShape} from './extHost.protocol'; + +export class ExtHostTerminal implements vscode.Terminal { + + public name: string; + + private _proxy: MainThreadTerminalServiceShape; + + constructor(proxy: MainThreadTerminalServiceShape, name?: string) { + this.name = name; + this._proxy = proxy; + } +} + +export class ExtHostTerminalService { + + private _proxy: MainThreadTerminalServiceShape; + + constructor(threadService: IThreadService) { + this._proxy = threadService.get(MainContext.MainThreadTerminalService); + } + + createTerminal(name?: string): vscode.Terminal { + return new ExtHostTerminal(this._proxy, name); + } +} diff --git a/src/vs/workbench/api/node/mainThreadTerminalService.ts b/src/vs/workbench/api/node/mainThreadTerminalService.ts new file mode 100644 index 00000000000..ba7db07b989 --- /dev/null +++ b/src/vs/workbench/api/node/mainThreadTerminalService.ts @@ -0,0 +1,20 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; + +import {ITerminalService} from 'vs/workbench/parts/terminal/electron-browser/terminal'; +import {MainThreadTerminalServiceShape} from './extHost.protocol'; + +export class MainThreadTerminalService extends MainThreadTerminalServiceShape { + + private _terminalService: ITerminalService; + + constructor( + @ITerminalService terminalService: ITerminalService + ) { + super(); + this._terminalService = terminalService; + } +}