Skip to content

Commit 8cf2863

Browse files
committed
debug status bar
fixes #31745
1 parent da37034 commit 8cf2863

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import * as nls from 'vs/nls';
7+
import * as dom from 'vs/base/browser/dom';
8+
import * as errors from 'vs/base/common/errors';
9+
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
10+
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
11+
import { IThemeService } from 'vs/platform/theme/common/themeService';
12+
import { IStatusbarItem } from 'vs/workbench/browser/parts/statusbar/statusbar';
13+
import { IDebugService } from 'vs/workbench/parts/debug/common/debug';
14+
import { Themable, STATUS_BAR_FOREGROUND } from 'vs/workbench/common/theme';
15+
16+
const $ = dom.$;
17+
const MAX_LABEL_LENGTH = 17;
18+
19+
export class DebugStatus extends Themable implements IStatusbarItem {
20+
private toDispose: IDisposable[];
21+
private label: HTMLElement;
22+
private icon: HTMLElement;
23+
24+
constructor(
25+
@IQuickOpenService private quickOpenService: IQuickOpenService,
26+
@IDebugService private debugService: IDebugService,
27+
@IThemeService themeService: IThemeService
28+
) {
29+
super(themeService);
30+
this.toDispose = [];
31+
this.toDispose.push(this.debugService.getConfigurationManager().onDidSelectConfiguration(e => {
32+
this.setLabel();
33+
}));
34+
}
35+
36+
protected updateStyles(): void {
37+
super.updateStyles();
38+
this.icon.style.backgroundColor = this.getColor(STATUS_BAR_FOREGROUND);
39+
}
40+
41+
public render(container: HTMLElement): IDisposable {
42+
const statusBarItem = dom.append(container, $('.debug-statusbar-item'));
43+
this.toDispose.push(dom.addDisposableListener(statusBarItem, 'click', () => {
44+
this.quickOpenService.show('debug ').done(undefined, errors.onUnexpectedError);
45+
}));
46+
statusBarItem.title = nls.localize('debug', "Debug");
47+
this.icon = dom.append(statusBarItem, $('.icon'));
48+
this.label = dom.append(statusBarItem, $('span.label'));
49+
this.setLabel();
50+
this.updateStyles();
51+
52+
return this;
53+
}
54+
55+
private setLabel(): void {
56+
if (this.label) {
57+
let name = this.debugService.getConfigurationManager().selectedName || '';
58+
if (name.length > MAX_LABEL_LENGTH) {
59+
name = name.substring(0, MAX_LABEL_LENGTH) + '...';
60+
}
61+
this.label.textContent = name;
62+
}
63+
}
64+
65+
public dispose(): void {
66+
super.dispose();
67+
this.toDispose = dispose(this.toDispose);
68+
}
69+
}

src/vs/workbench/parts/debug/browser/media/debug.contribution.css

+14
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,20 @@
102102
box-sizing: border-box;
103103
}
104104

105+
/* Debug status */
106+
.monaco-workbench .part.statusbar .debug-statusbar-item {
107+
cursor: pointer;
108+
display: flex;
109+
}
110+
111+
.monaco-workbench .part.statusbar .debug-statusbar-item .icon {
112+
-webkit-mask: url('debug-dark.svg') no-repeat 50% 50%;
113+
-webkit-mask-size: 18px;
114+
display: inline-block;
115+
padding-right: 2px;
116+
width: 16px;
117+
}
118+
105119
/* Expressions */
106120

107121
.monaco-workbench .monaco-tree-row .expression {

src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'v
1515
import { IWorkbenchActionRegistry, Extensions as WorkbenchActionRegistryExtensions } from 'vs/workbench/common/actions';
1616
import { ToggleViewletAction, Extensions as ViewletExtensions, ViewletRegistry, ViewletDescriptor } from 'vs/workbench/browser/viewlet';
1717
import { TogglePanelAction, Extensions as PanelExtensions, PanelRegistry, PanelDescriptor } from 'vs/workbench/browser/panel';
18+
import { StatusbarItemDescriptor, StatusbarAlignment, IStatusbarRegistry, Extensions as StatusExtensions } from 'vs/workbench/browser/parts/statusbar/statusbar';
1819
import { VariablesView, WatchExpressionsView, CallStackView, BreakpointsView } from 'vs/workbench/parts/debug/electron-browser/debugViews';
1920
import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
2021
import {
@@ -44,6 +45,7 @@ import URI from 'vs/base/common/uri';
4445
import { DebugViewlet, FocusVariablesViewAction, FocusBreakpointsViewAction, FocusCallStackViewAction, FocusWatchViewAction } from 'vs/workbench/parts/debug/browser/debugViewlet';
4546
import { Repl } from 'vs/workbench/parts/debug/electron-browser/repl';
4647
import { DebugQuickOpenHandler } from 'vs/workbench/parts/debug/browser/debugQuickOpen';
48+
import { DebugStatus } from 'vs/workbench/parts/debug/browser/debugStatus';
4749

4850
class OpenDebugViewletAction extends ToggleViewletAction {
4951
public static ID = VIEWLET_ID;
@@ -196,6 +198,10 @@ configurationRegistry.registerConfiguration({
196198

197199
debugCommands.registerCommands();
198200

201+
// Register Debug Status
202+
const statusBar = Registry.as<IStatusbarRegistry>(StatusExtensions.Statusbar);
203+
statusBar.registerStatusbarItem(new StatusbarItemDescriptor(DebugStatus, StatusbarAlignment.LEFT, 30 /* Low Priority */));
204+
199205
// Touch Bar
200206
if (isMacintosh) {
201207

0 commit comments

Comments
 (0)