mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 18:49:00 +01:00
Split up ext host <-> main thread communication to separate files
This commit is contained in:
37
src/vs/workbench/api/node/mainThreadStatusBar.ts
Normal file
37
src/vs/workbench/api/node/mainThreadStatusBar.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 {IStatusbarService, StatusbarAlignment as MainThreadStatusBarAlignment} from 'vs/platform/statusbar/common/statusbar';
|
||||
import {IDisposable} from 'vs/base/common/lifecycle';
|
||||
|
||||
export class MainThreadStatusBar {
|
||||
private mapIdToDisposable: { [id: number]: IDisposable };
|
||||
|
||||
constructor(
|
||||
@IStatusbarService private statusbarService: IStatusbarService
|
||||
) {
|
||||
this.mapIdToDisposable = Object.create(null);
|
||||
}
|
||||
|
||||
setEntry(id: number, text: string, tooltip: string, command: string, color: string, alignment: MainThreadStatusBarAlignment, priority: number): void {
|
||||
|
||||
// Dispose any old
|
||||
this.dispose(id);
|
||||
|
||||
// Add new
|
||||
let disposeable = this.statusbarService.addEntry({ text, tooltip, command, color }, alignment, priority);
|
||||
this.mapIdToDisposable[id] = disposeable;
|
||||
}
|
||||
|
||||
dispose(id: number) {
|
||||
let disposeable = this.mapIdToDisposable[id];
|
||||
if (disposeable) {
|
||||
disposeable.dispose();
|
||||
}
|
||||
|
||||
delete this.mapIdToDisposable[id];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user