mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 02:58:56 +01:00
Split up ext host <-> main thread communication to separate files
This commit is contained in:
59
src/vs/workbench/api/node/mainThreadOutputService.ts
Normal file
59
src/vs/workbench/api/node/mainThreadOutputService.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {Registry} from 'vs/platform/platform';
|
||||
import {IOutputService, IOutputChannel, OUTPUT_PANEL_ID, Extensions, IOutputChannelRegistry} from 'vs/workbench/parts/output/common/output';
|
||||
import {IPartService} from 'vs/workbench/services/part/common/partService';
|
||||
import {IPanelService} from 'vs/workbench/services/panel/common/panelService';
|
||||
|
||||
export class MainThreadOutputService {
|
||||
|
||||
private _outputService: IOutputService;
|
||||
private _partService: IPartService;
|
||||
private _panelService: IPanelService;
|
||||
|
||||
constructor(@IOutputService outputService: IOutputService,
|
||||
@IPartService partService: IPartService,
|
||||
@IPanelService panelService: IPanelService
|
||||
) {
|
||||
this._outputService = outputService;
|
||||
this._partService = partService;
|
||||
this._panelService = panelService;
|
||||
}
|
||||
|
||||
public append(channelId: string, label: string, value: string): TPromise<void> {
|
||||
this._getChannel(channelId, label).append(value);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public clear(channelId: string, label: string): TPromise<void> {
|
||||
this._getChannel(channelId, label).clear();
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public reveal(channelId: string, label: string, preserveFocus: boolean): TPromise<void> {
|
||||
this._getChannel(channelId, label).show(preserveFocus);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private _getChannel(channelId: string, label: string): IOutputChannel {
|
||||
if (Registry.as<IOutputChannelRegistry>(Extensions.OutputChannels).getChannels().every(channel => channel.id !== channelId)) {
|
||||
Registry.as<IOutputChannelRegistry>(Extensions.OutputChannels).registerChannel(channelId, label);
|
||||
}
|
||||
|
||||
return this._outputService.getChannel(channelId);
|
||||
}
|
||||
|
||||
public close(channelId: string): TPromise<void> {
|
||||
const panel = this._panelService.getActivePanel();
|
||||
if (panel && panel.getId() === OUTPUT_PANEL_ID && channelId === this._outputService.getActiveChannel().id ) {
|
||||
this._partService.setPanelHidden(true);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user