-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added VSCode StatusBar, floating subtree SVG
- Loading branch information
1 parent
dbe19bc
commit 8380be5
Showing
15 changed files
with
273 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import vscode from "vscode"; | ||
|
||
export type StatusBarState = | ||
| "active" | ||
| "unsaved" | ||
| "idle" | ||
| "error" | ||
| "loading" | ||
| "notfound"; | ||
|
||
interface StatusBarConfig { | ||
foreground: string; | ||
background: string; | ||
icon?: string; | ||
command: string; | ||
tooltip?: string; | ||
} | ||
|
||
const defaultConfigs: Record<StatusBarState, StatusBarConfig> = { | ||
active: { | ||
foreground: "statusBarItem.warningForeground", | ||
background: "statusBarItem.warningBackground", | ||
icon: "check", | ||
command: "argus.inspectWorkspace", | ||
}, | ||
unsaved: { | ||
foreground: "statusBarItem.foreground", | ||
background: "statusBarItem.background", | ||
icon: "circle-slash", | ||
command: "argus.inspectWorkspace", | ||
}, | ||
idle: { | ||
foreground: "statusBarItem.foreground", | ||
background: "statusBarItem.background", | ||
command: "argus.inspectWorkspace", | ||
}, | ||
error: { | ||
foreground: "statusBarItem.errorForeground", | ||
background: "statusBarItem.errorBackground", | ||
icon: "x", | ||
command: "argus.lastError", | ||
}, | ||
loading: { | ||
foreground: "statusBarItem.foreground", | ||
background: "statusBarItem.background", | ||
icon: "sync~spin", | ||
command: "argus.inspectWorkspace", | ||
}, | ||
notfound: { | ||
foreground: "statusBarItem.foreground", | ||
background: "statusBarItem.background", | ||
icon: "question", | ||
command: "argus.inspectWorkspace", | ||
tooltip: | ||
"Argus could not get Cargo to find this file (this is probably a Argus bug)", | ||
}, | ||
}; | ||
|
||
export class StatusBar { | ||
bar: vscode.StatusBarItem; | ||
state: StatusBarState = "loading"; | ||
|
||
constructor( | ||
context: vscode.ExtensionContext, | ||
readonly name: string = "argus", | ||
readonly configs: Record<StatusBarState, StatusBarConfig> = defaultConfigs | ||
) { | ||
this.bar = vscode.window.createStatusBarItem( | ||
vscode.StatusBarAlignment.Left | ||
); | ||
context.subscriptions.push(this.bar); | ||
this.bar.show(); | ||
} | ||
|
||
setState(state: StatusBarState, tooltip: string = "") { | ||
this.state = state; | ||
this.bar.tooltip = tooltip; | ||
this.render(); | ||
} | ||
|
||
render() { | ||
const config = this.configs[this.state]; | ||
this.bar.color = config.foreground; | ||
this.bar.backgroundColor = new vscode.ThemeColor(config.background); | ||
this.bar.text = `$(${config.icon}) ${this.name}`; | ||
this.bar.command = config.command; | ||
this.bar.tooltip = config.tooltip; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.