forked from microsoft/vscode-python-environments
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpythonStatusBar.ts
More file actions
42 lines (37 loc) · 1.56 KB
/
pythonStatusBar.ts
File metadata and controls
42 lines (37 loc) · 1.56 KB
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
import { Disposable, StatusBarAlignment, StatusBarItem, ThemeColor } from 'vscode';
import { PythonEnvironment } from '../../api';
import { createStatusBarItem } from '../../common/window.apis';
export interface PythonStatusBar extends Disposable {
show(env?: PythonEnvironment): void;
hide(): void;
}
export class PythonStatusBarImpl implements Disposable {
private disposables: Disposable[] = [];
private readonly statusBarItem: StatusBarItem;
constructor() {
this.statusBarItem = createStatusBarItem('python.interpreterDisplay', StatusBarAlignment.Right, 100);
this.statusBarItem.command = 'python-envs.set';
this.statusBarItem.name = 'Python Interpreter';
this.statusBarItem.tooltip = 'Select Python Interpreter';
this.statusBarItem.text = '$(loading~spin)';
this.statusBarItem.show();
this.disposables.push(this.statusBarItem);
}
public show(env?: PythonEnvironment) {
if (env) {
this.statusBarItem.text = env.displayName ?? 'Select Python Interpreter';
this.statusBarItem.tooltip = env.environmentPath?.fsPath ?? '';
} else {
this.statusBarItem.text = 'Select Python Interpreter';
this.statusBarItem.tooltip = 'Select Python Interpreter';
}
this.statusBarItem.backgroundColor = env ? undefined : new ThemeColor('statusBarItem.warningBackground');
this.statusBarItem.show();
}
public hide() {
this.statusBarItem.hide();
}
dispose() {
this.disposables.forEach((d) => d.dispose());
}
}