diff options
Diffstat (limited to 'editors/code/src/commands/watch_status.ts')
-rw-r--r-- | editors/code/src/commands/watch_status.ts | 41 |
1 files changed, 41 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..f027d7bbc --- /dev/null +++ b/editors/code/src/commands/watch_status.ts | |||
@@ -0,0 +1,41 @@ | |||
1 | import * as vscode from 'vscode'; | ||
2 | |||
3 | const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']; | ||
4 | |||
5 | export class StatusDisplay { | ||
6 | private i = 0; | ||
7 | private statusBarItem: vscode.StatusBarItem; | ||
8 | private timer?: NodeJS.Timeout; | ||
9 | |||
10 | constructor(subscriptions: vscode.Disposable[]) { | ||
11 | this.statusBarItem = vscode.window.createStatusBarItem( | ||
12 | vscode.StatusBarAlignment.Left, | ||
13 | 10 | ||
14 | ); | ||
15 | subscriptions.push(this.statusBarItem); | ||
16 | this.statusBarItem.hide(); | ||
17 | } | ||
18 | |||
19 | public show() { | ||
20 | this.timer = | ||
21 | this.timer || | ||
22 | setInterval(() => { | ||
23 | this.statusBarItem!.text = 'cargo check ' + this.frame(); | ||
24 | }, 300); | ||
25 | |||
26 | this.statusBarItem!.show(); | ||
27 | } | ||
28 | |||
29 | public hide() { | ||
30 | if (this.timer) { | ||
31 | clearInterval(this.timer); | ||
32 | this.timer = undefined; | ||
33 | } | ||
34 | |||
35 | this.statusBarItem!.hide(); | ||
36 | } | ||
37 | |||
38 | private frame() { | ||
39 | return spinnerFrames[(this.i = ++this.i % spinnerFrames.length)]; | ||
40 | } | ||
41 | } | ||