statusbar.ts 2.5 KB
Newer Older
E
Erich Gamma 已提交
1 2 3 4 5
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

6
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
J
Johannes Rieken 已提交
7
import { IDisposable } from 'vs/base/common/lifecycle';
B
Benjamin Pasero 已提交
8
import { ThemeColor } from 'vs/platform/theme/common/themeService';
9
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
E
Erich Gamma 已提交
10

11
export const IStatusbarService = createDecorator<IStatusbarService>('statusbarService');
E
Erich Gamma 已提交
12

13
export const enum StatusbarAlignment {
14 15 16 17 18 19 20
	LEFT,
	RIGHT
}

export interface IStatusbarEntryCategory {
	id: string;
	label: string;
21 22
}

E
Erich Gamma 已提交
23 24 25 26 27
/**
 * A declarative way of describing a status bar entry
 */
export interface IStatusbarEntry {

28 29 30 31 32
	/**
	 * The category of the entry is needed to allow users to hide entries via settings.
	 */
	readonly category: IStatusbarEntryCategory;

E
Erich Gamma 已提交
33 34 35 36 37
	/**
	 * The text to show for the entry. You can embed icons in the text by leveraging the syntax:
	 *
	 * `My text ${icon name} contains icons like ${icon name} this one.`
	 */
M
Matt Bierner 已提交
38
	readonly text: string;
E
Erich Gamma 已提交
39 40 41 42

	/**
	 * An optional tooltip text to show when you hover over the entry
	 */
M
Matt Bierner 已提交
43
	readonly tooltip?: string;
E
Erich Gamma 已提交
44 45 46 47

	/**
	 * An optional color to use for the entry
	 */
M
Matt Bierner 已提交
48
	readonly color?: string | ThemeColor;
E
Erich Gamma 已提交
49

50 51 52 53 54
	/**
	 * An optional background color to use for the entry
	 */
	readonly backgroundColor?: string | ThemeColor;

E
Erich Gamma 已提交
55 56 57
	/**
	 * An optional id of a command that is known to the workbench to execute on click
	 */
M
Matt Bierner 已提交
58
	readonly command?: string;
59

J
Joao Moreno 已提交
60 61 62
	/**
	 * Optional arguments for the command.
	 */
M
Matt Bierner 已提交
63
	readonly arguments?: any[];
J
Joao Moreno 已提交
64

65 66 67
	/**
	 * An optional extension ID if this entry is provided from an extension.
	 */
68
	readonly extensionId?: ExtensionIdentifier;
69 70 71 72

	/**
	 * Wether to show a beak above the status bar entry.
	 */
M
Matt Bierner 已提交
73
	readonly showBeak?: boolean;
E
Erich Gamma 已提交
74 75 76
}

export interface IStatusbarService {
B
polish  
Benjamin Pasero 已提交
77

78
	_serviceBrand: ServiceIdentifier<IStatusbarService>;
E
Erich Gamma 已提交
79 80

	/**
B
Benjamin Pasero 已提交
81 82
	 * Adds an entry to the statusbar with the given alignment and priority. Use the returned accessor
	 * to update or remove the statusbar entry.
E
Erich Gamma 已提交
83
	 */
B
Benjamin Pasero 已提交
84 85 86 87 88 89 90 91 92
	addEntry(entry: IStatusbarEntry, alignment: StatusbarAlignment, priority?: number): IStatusbarEntryAccessor;
}

export interface IStatusbarEntryAccessor extends IDisposable {

	/**
	 * Allows to update an existing status bar entry.
	 */
	update(properties: IStatusbarEntry): void;
E
Erich Gamma 已提交
93
}