Skip to content

Commit

Permalink
Make status color setting theme type aware
Browse files Browse the repository at this point in the history
Fixes #1264
  • Loading branch information
PEZ committed Aug 17, 2021
1 parent 0e76a11 commit c86a7c4
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 31 deletions.
90 changes: 63 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,36 +213,72 @@
"type": "object",
"description": "Configuration for custom coloring of the statusbar.",
"properties": {
"disconnectedColor": {
"type": "string",
"default": "#c0c0c0",
"pattern": "#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})",
"description": "Foreground color for the disconnected status"
},
"launchingColor": {
"type": "string",
"default": "#fdd023",
"pattern": "#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})",
"description": "Foreground color for the launching status"
},
"connectedStatusColor": {
"type": "string",
"default": "#fdd023",
"pattern": "#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})",
"description": "Foreground color for the connected status"
"light": {
"type": "object",
"description": "Light theme colors",
"properties": {
"disconnectedColor": {
"type": "string",
"pattern": "#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})",
"description": "Foreground color for the disconnected status"
},
"launchingColor": {
"type": "string",
"pattern": "#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})",
"description": "Foreground color for the launching status"
},
"connectedStatusColor": {
"type": "string",
"pattern": "#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})",
"description": "Foreground color for the connected status"
},
"typeStatusColor": {
"type": "string",
"pattern": "#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})",
"description": "Foreground color for the type status"
}
}
},
"typeStatusColor": {
"type": "string",
"default": "#91dc47",
"pattern": "#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})",
"description": "Foreground color for the type status"
"dark": {
"type": "object",
"description": "Dark theme colors",
"properties": {
"disconnectedColor": {
"type": "string",
"pattern": "#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})",
"description": "Foreground color for the disconnected status"
},
"launchingColor": {
"type": "string",
"pattern": "#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})",
"description": "Foreground color for the launching status"
},
"connectedStatusColor": {
"type": "string",
"pattern": "#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})",
"description": "Foreground color for the connected status"
},
"typeStatusColor": {
"type": "string",
"pattern": "#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})",
"description": "Foreground color for the type status"
}
}
}
},
"default": {
"disconnectedColor": "#c0c0c0",
"launchingColor": "#fdd023",
"connectedStatusColor": "#fdd023",
"typeStatusColor": "#91dc47"
"light": {
"disconnectedColor": "#777777",
"launchingColor": "#000000",
"connectedStatusColor": "#DB9550",
"typeStatusColor": "#91dc47"
},
"dark": {
"disconnectedColor": "#aaaaaa",
"launchingColor": "#ffffff",
"connectedStatusColor": "#DB9550",
"typeStatusColor": "#91dc47"
}
}
},
"calva.customCljsRepl": {
Expand Down Expand Up @@ -2453,4 +2489,4 @@
"webpack": "^5.27.1",
"webpack-cli": "^4.5.0"
}
}
}
16 changes: 12 additions & 4 deletions src/statusbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,22 @@ const color = {
inactive: "#b3b3b3"
};

// get theme kind once
//console.log(vscode.window.activeColorTheme.kind === vscode.ColorThemeKind.Light ? 'light' : 'dark/hc');
// event
//vscode.window.onDidChangeActiveColorTheme(e => {
// console.log(e.kind === ColorThemeKind.Light ? 'light' : 'dark/hc');
//});
function colorValue(section: string, currentConf: vscode.WorkspaceConfiguration): string {
let { defaultValue, globalValue, workspaceFolderValue, workspaceValue } = currentConf.inspect(section);
return (workspaceFolderValue || workspaceValue || globalValue || defaultValue) as string;
}

function update(context = state.extensionContext) {

let currentConf = vscode.workspace.getConfiguration('calva.statusColor');
let currentConf = vscode.workspace.getConfiguration(`calva.statusColor.${
vscode.window.activeColorTheme.kind === vscode.ColorThemeKind.Light ? 'light' : 'dark'
}`);

let doc = util.getDocument({}),
fileType = util.getFileType(doc),
Expand Down Expand Up @@ -54,7 +62,7 @@ function update(context = state.extensionContext) {
cljsBuildStatus.tooltip = null;

if (getStateValue('connected')) {
connectionStatus.text = "nREPL $(zap)";
connectionStatus.text = "REPL $(zap)";
connectionStatus.color = colorValue("connectedStatusColor", currentConf);
connectionStatus.tooltip = `nrepl://${getStateValue('hostname')}:${getStateValue('port')} (Click to reset connection)`;
connectionStatus.command = "calva.startOrConnectRepl";
Expand Down Expand Up @@ -84,11 +92,11 @@ function update(context = state.extensionContext) {
connectionStatus.tooltip = "Click to interrupt jack-in or Connect to REPL Server";
connectionStatus.command = "calva.disconnect";
} else if (util.getConnectingState()) {
connectionStatus.text = "nREPL - trying to connect";
connectionStatus.text = "REPL - trying to connect";
connectionStatus.tooltip = "Click to interrupt jack-in or Connect to REPL Server";
connectionStatus.command = "calva.disconnect";
} else {
connectionStatus.text = "nREPL $(zap)";
connectionStatus.text = "REPL $(zap)";
connectionStatus.tooltip = "Click to jack-in or Connect to REPL Server";
connectionStatus.color = colorValue("disconnectedColor", currentConf);
connectionStatus.command = "calva.startOrConnectRepl";
Expand Down

0 comments on commit c86a7c4

Please sign in to comment.