From 8cf286389b05ce4bf482b246dcafd04d1c4f7e9f Mon Sep 17 00:00:00 2001 From: isidor Date: Fri, 6 Oct 2017 17:04:34 +0200 Subject: [PATCH] debug status bar fixes #31745 --- .../parts/debug/browser/debugStatus.ts | 69 +++++++++++++++++++ .../browser/media/debug.contribution.css | 14 ++++ .../electron-browser/debug.contribution.ts | 6 ++ 3 files changed, 89 insertions(+) create mode 100644 src/vs/workbench/parts/debug/browser/debugStatus.ts diff --git a/src/vs/workbench/parts/debug/browser/debugStatus.ts b/src/vs/workbench/parts/debug/browser/debugStatus.ts new file mode 100644 index 0000000000000..2220e21543260 --- /dev/null +++ b/src/vs/workbench/parts/debug/browser/debugStatus.ts @@ -0,0 +1,69 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import * as nls from 'vs/nls'; +import * as dom from 'vs/base/browser/dom'; +import * as errors from 'vs/base/common/errors'; +import { IDisposable, dispose } from 'vs/base/common/lifecycle'; +import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; +import { IThemeService } from 'vs/platform/theme/common/themeService'; +import { IStatusbarItem } from 'vs/workbench/browser/parts/statusbar/statusbar'; +import { IDebugService } from 'vs/workbench/parts/debug/common/debug'; +import { Themable, STATUS_BAR_FOREGROUND } from 'vs/workbench/common/theme'; + +const $ = dom.$; +const MAX_LABEL_LENGTH = 17; + +export class DebugStatus extends Themable implements IStatusbarItem { + private toDispose: IDisposable[]; + private label: HTMLElement; + private icon: HTMLElement; + + constructor( + @IQuickOpenService private quickOpenService: IQuickOpenService, + @IDebugService private debugService: IDebugService, + @IThemeService themeService: IThemeService + ) { + super(themeService); + this.toDispose = []; + this.toDispose.push(this.debugService.getConfigurationManager().onDidSelectConfiguration(e => { + this.setLabel(); + })); + } + + protected updateStyles(): void { + super.updateStyles(); + this.icon.style.backgroundColor = this.getColor(STATUS_BAR_FOREGROUND); + } + + public render(container: HTMLElement): IDisposable { + const statusBarItem = dom.append(container, $('.debug-statusbar-item')); + this.toDispose.push(dom.addDisposableListener(statusBarItem, 'click', () => { + this.quickOpenService.show('debug ').done(undefined, errors.onUnexpectedError); + })); + statusBarItem.title = nls.localize('debug', "Debug"); + this.icon = dom.append(statusBarItem, $('.icon')); + this.label = dom.append(statusBarItem, $('span.label')); + this.setLabel(); + this.updateStyles(); + + return this; + } + + private setLabel(): void { + if (this.label) { + let name = this.debugService.getConfigurationManager().selectedName || ''; + if (name.length > MAX_LABEL_LENGTH) { + name = name.substring(0, MAX_LABEL_LENGTH) + '...'; + } + this.label.textContent = name; + } + } + + public dispose(): void { + super.dispose(); + this.toDispose = dispose(this.toDispose); + } +} diff --git a/src/vs/workbench/parts/debug/browser/media/debug.contribution.css b/src/vs/workbench/parts/debug/browser/media/debug.contribution.css index 87918a9013a06..69bf974a45f2a 100644 --- a/src/vs/workbench/parts/debug/browser/media/debug.contribution.css +++ b/src/vs/workbench/parts/debug/browser/media/debug.contribution.css @@ -102,6 +102,20 @@ box-sizing: border-box; } +/* Debug status */ +.monaco-workbench .part.statusbar .debug-statusbar-item { + cursor: pointer; + display: flex; +} + +.monaco-workbench .part.statusbar .debug-statusbar-item .icon { + -webkit-mask: url('debug-dark.svg') no-repeat 50% 50%; + -webkit-mask-size: 18px; + display: inline-block; + padding-right: 2px; + width: 16px; +} + /* Expressions */ .monaco-workbench .monaco-tree-row .expression { diff --git a/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts b/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts index 2ee47d4318a7a..a88503d3faf10 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts @@ -15,6 +15,7 @@ import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'v import { IWorkbenchActionRegistry, Extensions as WorkbenchActionRegistryExtensions } from 'vs/workbench/common/actions'; import { ToggleViewletAction, Extensions as ViewletExtensions, ViewletRegistry, ViewletDescriptor } from 'vs/workbench/browser/viewlet'; import { TogglePanelAction, Extensions as PanelExtensions, PanelRegistry, PanelDescriptor } from 'vs/workbench/browser/panel'; +import { StatusbarItemDescriptor, StatusbarAlignment, IStatusbarRegistry, Extensions as StatusExtensions } from 'vs/workbench/browser/parts/statusbar/statusbar'; import { VariablesView, WatchExpressionsView, CallStackView, BreakpointsView } from 'vs/workbench/parts/debug/electron-browser/debugViews'; import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions'; import { @@ -44,6 +45,7 @@ import URI from 'vs/base/common/uri'; import { DebugViewlet, FocusVariablesViewAction, FocusBreakpointsViewAction, FocusCallStackViewAction, FocusWatchViewAction } from 'vs/workbench/parts/debug/browser/debugViewlet'; import { Repl } from 'vs/workbench/parts/debug/electron-browser/repl'; import { DebugQuickOpenHandler } from 'vs/workbench/parts/debug/browser/debugQuickOpen'; +import { DebugStatus } from 'vs/workbench/parts/debug/browser/debugStatus'; class OpenDebugViewletAction extends ToggleViewletAction { public static ID = VIEWLET_ID; @@ -196,6 +198,10 @@ configurationRegistry.registerConfiguration({ debugCommands.registerCommands(); +// Register Debug Status +const statusBar = Registry.as(StatusExtensions.Statusbar); +statusBar.registerStatusbarItem(new StatusbarItemDescriptor(DebugStatus, StatusbarAlignment.LEFT, 30 /* Low Priority */)); + // Touch Bar if (isMacintosh) {