-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
96 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import vscode from 'vscode'; | ||
|
||
export class GlobalState { | ||
private static _instance: GlobalState; | ||
|
||
/** instance */ | ||
public static get i(): GlobalState { | ||
if (!GlobalState._instance) { | ||
throw new Error('GlobalState not initialized'); | ||
} | ||
|
||
return GlobalState._instance; | ||
} | ||
|
||
public static init(vscodeContext: vscode.ExtensionContext) { | ||
GlobalState._instance = new GlobalState(vscodeContext); | ||
} | ||
|
||
private constructor(private readonly vscodeContext: vscode.ExtensionContext) {} | ||
|
||
get isHiddenMode() { | ||
return this.vscodeContext.globalState.get('isHiddenMode', true); | ||
} | ||
set isHiddenMode(value: boolean) { | ||
this.vscodeContext.globalState.update('isHiddenMode', value); | ||
} | ||
} |
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,38 @@ | ||
import vscode from 'vscode'; | ||
|
||
export class StatusBar { | ||
private static _instance: StatusBar; | ||
|
||
/** instance */ | ||
public static get i(): StatusBar { | ||
if (!StatusBar._instance) { | ||
throw new Error('StatusBar not initialized'); | ||
} | ||
|
||
return StatusBar._instance; | ||
} | ||
|
||
public static init(vscodeContext: vscode.ExtensionContext) { | ||
StatusBar._instance = new StatusBar(vscodeContext); | ||
} | ||
|
||
private statusBarItem: vscode.StatusBarItem; | ||
|
||
constructor(vscodeContext: vscode.ExtensionContext) { | ||
const isHiddenMode = vscodeContext.globalState.get('isHiddenMode', true); | ||
this.statusBarItem = vscode.window.createStatusBarItem(); | ||
this.statusBarItem.command = 'ts-type-hidden.toogle'; | ||
this.statusBarItem.show(); | ||
this.changeStatus(isHiddenMode); | ||
vscodeContext.subscriptions.push(this.statusBarItem); | ||
} | ||
|
||
changeStatus(isHiddenMode: boolean) { | ||
this.statusBarItem.text = isHiddenMode ? 'TH ✅' : 'TH ❌'; | ||
|
||
this.statusBarItem.tooltip = | ||
'[TS Type Hidden] - Click to toggle hidden mode (Current mode: ' + | ||
(isHiddenMode ? 'On' : 'Off') + | ||
')'; | ||
} | ||
} |
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