Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/media-preview/src/ownedStatusBarEntry.ts
4772 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import * as vscode from 'vscode';
7
import { Disposable } from './util/dispose';
8
9
export abstract class PreviewStatusBarEntry extends Disposable {
10
private _showOwner: unknown | undefined;
11
12
protected readonly entry: vscode.StatusBarItem;
13
14
constructor(id: string, name: string, alignment: vscode.StatusBarAlignment, priority: number) {
15
super();
16
this.entry = this._register(vscode.window.createStatusBarItem(id, alignment, priority));
17
this.entry.name = name;
18
}
19
20
protected showItem(owner: unknown, text: string) {
21
this._showOwner = owner;
22
this.entry.text = text;
23
this.entry.show();
24
}
25
26
public hide(owner: unknown) {
27
if (owner === this._showOwner) {
28
this.entry.hide();
29
this._showOwner = undefined;
30
}
31
}
32
}
33
34