aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands/watch_status.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/commands/watch_status.ts')
-rw-r--r--editors/code/src/commands/watch_status.ts51
1 files changed, 51 insertions, 0 deletions
diff --git a/editors/code/src/commands/watch_status.ts b/editors/code/src/commands/watch_status.ts
new file mode 100644
index 000000000..86ae821de
--- /dev/null
+++ b/editors/code/src/commands/watch_status.ts
@@ -0,0 +1,51 @@
1import * as vscode from 'vscode';
2
3const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
4
5export class StatusDisplay {
6 public packageName?: string;
7
8 private i = 0;
9 private statusBarItem: vscode.StatusBarItem;
10 private timer?: NodeJS.Timeout;
11
12 constructor(subscriptions: vscode.Disposable[]) {
13 this.statusBarItem = vscode.window.createStatusBarItem(
14 vscode.StatusBarAlignment.Left,
15 10
16 );
17 subscriptions.push(this.statusBarItem);
18 this.statusBarItem.hide();
19 }
20
21 public show() {
22 this.packageName = undefined;
23
24 this.timer =
25 this.timer ||
26 setInterval(() => {
27 if (this.packageName) {
28 this.statusBarItem!.text = `cargo check [${
29 this.packageName
30 }] ${this.frame()}`;
31 } else {
32 this.statusBarItem!.text = `cargo check ${this.frame()}`;
33 }
34 }, 300);
35
36 this.statusBarItem!.show();
37 }
38
39 public hide() {
40 if (this.timer) {
41 clearInterval(this.timer);
42 this.timer = undefined;
43 }
44
45 this.statusBarItem!.hide();
46 }
47
48 private frame() {
49 return spinnerFrames[(this.i = ++this.i % spinnerFrames.length)];
50 }
51}