Skip to content

Commit

Permalink
Merge pull request #1200 from SchweizS/statusbar-update_212_952_1189
Browse files Browse the repository at this point in the history
Statusbar update 212 952 1189
  • Loading branch information
bobbrow authored May 11, 2020
2 parents 15acf99 + 9e2736b commit e21a430
Show file tree
Hide file tree
Showing 6 changed files with 643 additions and 202 deletions.
164 changes: 164 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,170 @@
],
"scope": "window"
},
"cmake.statusbar.visibility": {
"type": "string",
"default": "default",
"description": "%cmake-tools.configuration.cmake.statusbar.visibility.description%",
"enum": [
"default",
"compact",
"icon",
"hidden"
],
"scope": "window"
},
"cmake.statusbar.advanced": {
"type": "object",
"default": {},
"description": "%cmake-tools.configuration.cmake.statusbar.advanced.description%",
"properties": {
"kit": {
"type": "object",
"properties": {
"visibility": {
"type": "string",
"description": "%cmake-tools.configuration.cmake.statusbar.advanced.visibility.description%",
"enum": [
"default",
"compact",
"icon",
"hidden"
]
},
"length": {
"description": "%cmake-tools.configuration.cmake.statusbar.advanced.length.description%",
"type": "integer",
"default": 20
}
}
},
"status": {
"type": "object",
"properties": {
"visibility": {
"type": "string",
"description": "%cmake-tools.configuration.cmake.statusbar.advanced.visibility.description%",
"enum": [
"default",
"compact",
"icon",
"hidden"
]
}
}
},
"workspace": {
"type": "object",
"properties": {
"visibility": {
"type": "string",
"description": "%cmake-tools.configuration.cmake.statusbar.advanced.visibility.description%",
"enum": [
"default",
"compact",
"icon",
"hidden"
]
}
}
},
"buildTarget": {
"type": "object",
"properties": {
"visibility": {
"type": "string",
"description": "%cmake-tools.configuration.cmake.statusbar.advanced.visibility.description%",
"enum": [
"default",
"compact",
"icon",
"hidden"
]
}
}
},
"build": {
"type": "object",
"properties": {
"visibility": {
"type": "string",
"description": "%cmake-tools.configuration.cmake.statusbar.advanced.visibility.description%",
"enum": [
"default",
"compact",
"icon",
"hidden"
]
}
}
},
"launchTarget": {
"type": "object",
"properties": {
"visibility": {
"type": "string",
"description": "%cmake-tools.configuration.cmake.statusbar.advanced.visibility.description%",
"enum": [
"default",
"compact",
"icon",
"hidden"
]
}
}
},
"debug": {
"type": "object",
"properties": {
"visibility": {
"type": "string",
"description": "%cmake-tools.configuration.cmake.statusbar.advanced.visibility.description%",
"enum": [
"default",
"compact",
"icon",
"hidden"
]
}
}
},
"launch": {
"type": "object",
"properties": {
"visibility": {
"type": "string",
"description": "%cmake-tools.configuration.cmake.statusbar.advanced.visibility.description%",
"enum": [
"default",
"compact",
"icon",
"hidden"
]
}
}
},
"ctest": {
"type": "object",
"properties": {
"visibility": {
"type": "string",
"description": "%cmake-tools.configuration.cmake.statusbar.advanced.visibility.description%",
"enum": [
"default",
"compact",
"icon",
"hidden"
]
},
"color": {
"type":"boolean",
"default": false,
"description": "%cmake-tools.configuration.cmake.statusbar.advanced.ctest.color.description%"
}
}
}
}
},
"cmake.revealLog": {
"type": "string",
"default": "always",
Expand Down
5 changes: 5 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@
"cmake-tools.configuration.cmake.outputLogEncoding.description": "Encoding of the output from external commands (eg.cmake -- build).",
"cmake-tools.configuration.cmake.enableTraceLogging.description": "Enable trace logging to file and console (very noisy).",
"cmake-tools.configuration.cmake.autoSelectActiveFolder.description": "Select active folder automatically",
"cmake-tools.configuration.cmake.statusbar.visibility.description": "Configures how the extension displays the buttons in the status bar",
"cmake-tools.configuration.cmake.statusbar.advanced.description": "Configures the settings for individual status bar buttons. These settings overwrite the more general 'cmake.statusbar.visibility' setting.",
"cmake-tools.configuration.cmake.statusbar.advanced.visibility.description": "Configures how the extension displays this button in the status bar",
"cmake-tools.configuration.cmake.statusbar.advanced.ctest.color.description": "Enables a change in color for this button depending on test results",
"cmake-tools.configuration.cmake.statusbar.advanced.length.description": "Configures the maximum length of visible text in 'compact' mode.",
"cmake-tools.configuration.views.cmake.folders.description": "Folders",
"cmake-tools.configuration.views.cmake.outline.description": "Project Outline"
}
43 changes: 43 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,48 @@ export type LogLevelKey = 'trace'|'debug'|'info'|'note'|'warning'|'error'|'fatal

export type CMakeCommunicationMode = 'legacy'|'serverApi'|'fileApi'|'automatic';

export type StatusBarButtonVisibility = "default" | "compact" | "icon" | "hidden";

interface HardEnv {
[key: string]: string;
}

export interface AdvancedStatusBarConfig {
kit?: {
visibility?: StatusBarButtonVisibility;
length?: number;
};
status?: {
visibility?: StatusBarButtonVisibility;
};
workspace?: {
visibility?: StatusBarButtonVisibility;
};
buildTarget?: {
visibility?: StatusBarButtonVisibility;
};
build?: {
visibility?: StatusBarButtonVisibility;
};
launchTarget?: {
visibility?: StatusBarButtonVisibility;
};
debug?: {
visibility?: StatusBarButtonVisibility;
};
launch?: {
visibility?: StatusBarButtonVisibility;
};
ctest?: {
color?: boolean;
visibility?: StatusBarButtonVisibility;
};
}
export interface StatusBarConfig {
advanced?: AdvancedStatusBarConfig;
visibility: StatusBarButtonVisibility;
}

export interface ExtensionConfigurationSettings {
autoSelectActiveFolder: boolean;
cmakePath: string;
Expand Down Expand Up @@ -65,6 +103,7 @@ export interface ExtensionConfigurationSettings {
outputLogEncoding: string;
enableTraceLogging: boolean;
loggingLevel: LogLevelKey;
statusbar: StatusBarConfig;
}

type EmittersOf<T> = {
Expand All @@ -85,6 +124,8 @@ export class ConfigurationReader implements vscode.Disposable {

get configData() { return this._configData; }

get statusbar() { return this._configData.statusbar; }

dispose() {
if (this._updateSubscription) {
this._updateSubscription.dispose();
Expand Down Expand Up @@ -290,6 +331,8 @@ export class ConfigurationReader implements vscode.Disposable {
outputLogEncoding: new vscode.EventEmitter<string>(),
enableTraceLogging: new vscode.EventEmitter<boolean>(),
loggingLevel: new vscode.EventEmitter<LogLevelKey>(),
statusbar: new vscode.EventEmitter<StatusBarConfig>()

};

/**
Expand Down
13 changes: 7 additions & 6 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type CMakeToolsQueryMapFn = (cmt: CMakeTools) => Thenable<string | string[] | nu
class ExtensionManager implements vscode.Disposable {
constructor(public readonly extensionContext: vscode.ExtensionContext) {
telemetry.activate();
this._statusBar.targetName = 'all';
this._statusBar.setBuildTargetName('all');
this._folders.onAfterAddFolder(async cmtFolder => {
console.assert(this._folders.size === vscode.workspace.workspaceFolders?.length);
if (this._folders.size === 1) {
Expand Down Expand Up @@ -183,7 +183,7 @@ class ExtensionManager implements vscode.Disposable {
/**
* The status bar controller
*/
private readonly _statusBar = new StatusBar();
private readonly _statusBar = new StatusBar(this._workspaceConfig);
// Subscriptions for status bar items:
private _statusMessageSub: vscode.Disposable = new DummyDisposable();
private _targetNameSub: vscode.Disposable = new DummyDisposable();
Expand Down Expand Up @@ -389,7 +389,7 @@ class ExtensionManager implements vscode.Disposable {
} else if (!ws) {
// When adding a folder but the focus is on somewhere else
// Do nothing but make sure we are showing the active folder correctly
this._statusBar.reloadVisibility();
this._statusBar.update();
}
}
}
Expand Down Expand Up @@ -520,14 +520,14 @@ class ExtensionManager implements vscode.Disposable {
this._statusBar.setVisible(true);
this._statusMessageSub = cmt.onStatusMessageChanged(FireNow, s => this._statusBar.setStatusMessage(s));
this._targetNameSub = cmt.onTargetNameChanged(FireNow, t => {
this._statusBar.targetName = t;
this._statusBar.setBuildTargetName(t);
});
this._buildTypeSub = cmt.onBuildTypeChanged(FireNow, bt => this._statusBar.setBuildTypeLabel(bt));
this._launchTargetSub = cmt.onLaunchTargetNameChanged(FireNow, t => {
this._statusBar.setLaunchTargetName(t || '');
});
this._ctestEnabledSub = cmt.onCTestEnabledChanged(FireNow, e => this._statusBar.ctestEnabled = e);
this._testResultsSub = cmt.onTestResultsChanged(FireNow, r => this._statusBar.testResults = r);
this._ctestEnabledSub = cmt.onCTestEnabledChanged(FireNow, e => this._statusBar.setCTestEnabled(e));
this._testResultsSub = cmt.onTestResultsChanged(FireNow, r => this._statusBar.setTestResults(r));
this._isBusySub = cmt.onIsBusyChanged(FireNow, b => this._statusBar.setIsBusy(b));
this._statusBar.setActiveKitName(cmt.activeKit ? cmt.activeKit.name : '');
}
Expand Down Expand Up @@ -877,6 +877,7 @@ class ExtensionManager implements vscode.Disposable {

async hideLaunchCommand(shouldHide: boolean = true) {
// Don't hide command selectLaunchTarget here since the target can still be useful, one example is ${command:cmake.launchTargetPath} in launch.json
this._statusBar.hideLaunchButton(shouldHide);
await util.setContextValue(HIDE_LAUNCH_COMMAND_KEY, shouldHide);
}

Expand Down
Loading

0 comments on commit e21a430

Please sign in to comment.