-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathstatusBar.ts
59 lines (48 loc) · 1.67 KB
/
statusBar.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import * as vscode from 'vscode';
import { ModeName } from './mode/mode';
class StatusBarImpl implements vscode.Disposable {
private _statusBarItem: vscode.StatusBarItem;
private _prevModeName: ModeName | undefined;
private _isRecordingMacro: boolean;
constructor() {
this._statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
this._prevModeName = undefined;
this._isRecordingMacro = false;
}
public SetText(
text: string,
mode: ModeName,
isRecordingMacro: boolean,
forceUpdate: boolean = false
) {
let updateStatusBar =
this._prevModeName !== mode || this._isRecordingMacro !== isRecordingMacro || forceUpdate;
this._prevModeName = mode;
this._isRecordingMacro = isRecordingMacro;
if (updateStatusBar) {
this._statusBarItem.text = text || '';
this._statusBarItem.show();
}
}
public SetColor(background: string, foreground?: string) {
const currentColorCustomizations = vscode.workspace
.getConfiguration('workbench')
.get('colorCustomizations');
const colorCustomizations = Object.assign(currentColorCustomizations || {}, {
'statusBar.background': `${background}`,
'statusBar.noFolderBackground': `${background}`,
'statusBar.debuggingBackground': `${background}`,
'statusBar.foreground': `${foreground}`,
});
if (foreground === undefined) {
delete colorCustomizations['statusBar.foreground'];
}
vscode.workspace
.getConfiguration('workbench')
.update('colorCustomizations', colorCustomizations, true);
}
dispose() {
this._statusBarItem.dispose();
}
}
export const StatusBar = new StatusBarImpl();