diff --git a/src/vs/platform/statusbar/common/statusbar.ts b/src/vs/platform/statusbar/common/statusbar.ts index 6e45f806115..d42f792b801 100644 --- a/src/vs/platform/statusbar/common/statusbar.ts +++ b/src/vs/platform/statusbar/common/statusbar.ts @@ -7,6 +7,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { IDisposable } from 'vs/base/common/lifecycle'; +import { ThemeColor } from 'vs/editor/common/editorCommon'; export var IStatusbarService = createDecorator('statusbarService'); @@ -34,7 +35,7 @@ export interface IStatusbarEntry { /** * An optional color to use for the entry */ - color?: string; + color?: string | ThemeColor; /** * An optional id of a command that is known to the workbench to execute on click diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 4850740fec1..35a6a58cc03 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -3301,7 +3301,7 @@ declare module 'vscode' { /** * The foreground color for this entry. */ - color: string | undefined; + color: string | ThemeColor | undefined; /** * The identifier of a command to run on click. The command must be diff --git a/src/vs/workbench/api/electron-browser/mainThreadStatusBar.ts b/src/vs/workbench/api/electron-browser/mainThreadStatusBar.ts index d64d9d3ac2b..d16e17cda09 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadStatusBar.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadStatusBar.ts @@ -7,6 +7,7 @@ import { IStatusbarService, StatusbarAlignment as MainThreadStatusBarAlignment } from 'vs/platform/statusbar/common/statusbar'; import { IDisposable } from 'vs/base/common/lifecycle'; import { MainThreadStatusBarShape } from '../node/extHost.protocol'; +import { ThemeColor } from 'vs/editor/common/editorCommon'; export class MainThreadStatusBar extends MainThreadStatusBarShape { private mapIdToDisposable: { [id: number]: IDisposable }; @@ -18,7 +19,7 @@ export class MainThreadStatusBar extends MainThreadStatusBarShape { this.mapIdToDisposable = Object.create(null); } - $setEntry(id: number, extensionId: string, text: string, tooltip: string, command: string, color: string, alignment: MainThreadStatusBarAlignment, priority: number): void { + $setEntry(id: number, extensionId: string, text: string, tooltip: string, command: string, color: string | ThemeColor, alignment: MainThreadStatusBarAlignment, priority: number): void { // Dispose any old this.$dispose(id); diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index 1dbe9058048..f9c02d01d8c 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -277,7 +277,7 @@ export abstract class MainThreadQuickOpenShape { } export abstract class MainThreadStatusBarShape { - $setEntry(id: number, extensionId: string, text: string, tooltip: string, command: string, color: string, alignment: MainThreadStatusBarAlignment, priority: number): void { throw ni(); } + $setEntry(id: number, extensionId: string, text: string, tooltip: string, command: string, color: string | editorCommon.ThemeColor, alignment: MainThreadStatusBarAlignment, priority: number): void { throw ni(); } $dispose(id: number) { throw ni(); } } diff --git a/src/vs/workbench/api/node/extHostStatusBar.ts b/src/vs/workbench/api/node/extHostStatusBar.ts index 97c917caf51..6e91e7dbf9a 100644 --- a/src/vs/workbench/api/node/extHostStatusBar.ts +++ b/src/vs/workbench/api/node/extHostStatusBar.ts @@ -6,7 +6,7 @@ import { IThreadService } from 'vs/workbench/services/thread/common/threadService'; import { StatusbarAlignment as MainThreadStatusBarAlignment } from 'vs/platform/statusbar/common/statusbar'; -import { StatusBarAlignment as ExtHostStatusBarAlignment, Disposable } from './extHostTypes'; +import { StatusBarAlignment as ExtHostStatusBarAlignment, Disposable, ThemeColor } from './extHostTypes'; import { StatusBarItem, StatusBarAlignment } from 'vscode'; import { MainContext, MainThreadStatusBarShape } from './extHost.protocol'; @@ -21,7 +21,7 @@ export class ExtHostStatusBarEntry implements StatusBarItem { private _text: string; private _tooltip: string; - private _color: string; + private _color: string | ThemeColor; private _command: string; private _timeoutHandle: number; @@ -57,7 +57,7 @@ export class ExtHostStatusBarEntry implements StatusBarItem { return this._tooltip; } - public get color(): string { + public get color(): string | ThemeColor { return this._color; } @@ -75,7 +75,7 @@ export class ExtHostStatusBarEntry implements StatusBarItem { this.update(); } - public set color(color: string) { + public set color(color: string | ThemeColor) { this._color = color; this.update(); } diff --git a/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts b/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts index 123f0f5d26e..fd2fd574fb4 100644 --- a/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts +++ b/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts @@ -30,6 +30,8 @@ import { IThemeService, registerThemingParticipant, ITheme, ICssStyleCollector } import { STATUS_BAR_BACKGROUND, STATUS_BAR_FOREGROUND, STATUS_BAR_NO_FOLDER_BACKGROUND, STATUS_BAR_ITEM_HOVER_BACKGROUND, STATUS_BAR_ITEM_ACTIVE_BACKGROUND, STATUS_BAR_PROMINENT_ITEM_BACKGROUND, STATUS_BAR_PROMINENT_ITEM_HOVER_BACKGROUND, STATUS_BAR_BORDER, STATUS_BAR_NO_FOLDER_FOREGROUND } from 'vs/workbench/common/theme'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { contrastBorder } from 'vs/platform/theme/common/colorRegistry'; +import { isThemeColor } from "vs/editor/common/editorCommon"; +import { Color } from 'vs/base/common/color'; export class StatusbarPart extends Part implements IStatusbarService { @@ -217,7 +219,8 @@ class StatusBarEntryItem implements IStatusbarItem { @IMessageService private messageService: IMessageService, @ITelemetryService private telemetryService: ITelemetryService, @IContextMenuService private contextMenuService: IContextMenuService, - @IWorkbenchEditorService private editorService: IWorkbenchEditorService + @IWorkbenchEditorService private editorService: IWorkbenchEditorService, + @IThemeService private themeService: IThemeService ) { this.entry = entry; @@ -249,8 +252,17 @@ class StatusBarEntryItem implements IStatusbarItem { } // Color - if (this.entry.color) { - $(textContainer).color(this.entry.color); + let color = this.entry.color; + if (color) { + if (isThemeColor(color)) { + let colorId = color.id; + color = (this.themeService.getTheme().getColor(colorId) || Color.transparent).toString(); + toDispose.push(this.themeService.onThemeChange(theme => { + let colorValue = (this.themeService.getTheme().getColor(colorId) || Color.transparent).toString(); + $(textContainer).color(colorValue); + })); + } + $(textContainer).color(color); } // Context Menu