This repository has been archived by the owner on Jun 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
/
statusbar.ts
60 lines (50 loc) · 2.09 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
60
import { Disposable, StatusBarAlignment, StatusBarItem, window } from 'vscode';
import { RoiManager, RoiMode } from './roi';
import { Server } from './server';
export class LeanStatusBarItem implements Disposable {
statusBarItem: StatusBarItem;
private shown: boolean = false;
private subscriptions: Disposable[] = [];
constructor(private server: Server, private roiManager: RoiManager) {
this.statusBarItem = window.createStatusBarItem(StatusBarAlignment.Left, 10);
this.subscriptions.push(
server.restarted.on(() => this.update()),
server.statusChanged.on(() => this.update()),
);
if (roiManager) {
this.subscriptions.push(roiManager.onModeChanged(() => this.update()));
this.statusBarItem.command = 'lean.roiMode.select';
}
if (this.server.alive()) {
this.update();
}
}
update() {
let text = 'Lean: ';
const serverStatus = this.server.statusChanged.currentValue;
if (serverStatus && serverStatus.isRunning) {
text += `$(sync) ${serverStatus.numberOfTasks}`;
} else if (serverStatus && serverStatus.stopped) {
text += '$(x)';
} else {
text += '$(check)';
}
switch (this.roiManager && this.roiManager.mode) {
case RoiMode.Nothing: text += ' (checking nothing)'; break;
case RoiMode.VisibleLines: text += ' (checking visible lines)'; break;
case RoiMode.VisibleLinesAndAbove: text += ' (checking visible lines and above)'; break;
case RoiMode.VisibleFiles: text += ' (checking visible files)'; break;
case RoiMode.OpenFiles: text += ' (checking open files)'; break;
case RoiMode.ProjectFiles: text += ' (checking project files)'; break;
}
if (!this.shown) {
this.statusBarItem.show();
this.shown = true;
}
this.statusBarItem.text = text;
}
dispose() {
this.statusBarItem.dispose();
for (const s of this.subscriptions) { s.dispose(); }
}
}