Skip to content

Commit

Permalink
debug status bar
Browse files Browse the repository at this point in the history
fixes #31745
  • Loading branch information
isidorn committed Oct 6, 2017
1 parent da37034 commit 8cf2863
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
69 changes: 69 additions & 0 deletions src/vs/workbench/parts/debug/browser/debugStatus.ts
Original file line number Diff line number Diff line change
@@ -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);
}
}
14 changes: 14 additions & 0 deletions src/vs/workbench/parts/debug/browser/media/debug.contribution.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -196,6 +198,10 @@ configurationRegistry.registerConfiguration({

debugCommands.registerCommands();

// Register Debug Status
const statusBar = Registry.as<IStatusbarRegistry>(StatusExtensions.Statusbar);
statusBar.registerStatusbarItem(new StatusbarItemDescriptor(DebugStatus, StatusbarAlignment.LEFT, 30 /* Low Priority */));

// Touch Bar
if (isMacintosh) {

Expand Down

0 comments on commit 8cf2863

Please sign in to comment.