Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/label/common/label.ts
3294 views
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 { Event } from '../../../base/common/event.js';
7
import { IDisposable } from '../../../base/common/lifecycle.js';
8
import { URI } from '../../../base/common/uri.js';
9
import { createDecorator } from '../../instantiation/common/instantiation.js';
10
import { IWorkspace, ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from '../../workspace/common/workspace.js';
11
12
export const ILabelService = createDecorator<ILabelService>('labelService');
13
14
export interface ILabelService {
15
16
readonly _serviceBrand: undefined;
17
18
/**
19
* Gets the human readable label for a uri.
20
* If `relative` is passed returns a label relative to the workspace root that the uri belongs to.
21
* If `noPrefix` is passed does not tildify the label and also does not prepand the root name for relative labels in a multi root scenario.
22
* If `separator` is passed, will use that over the defined path separator of the formatter.
23
* If `appendWorkspaceSuffix` is passed, will append the name of the workspace to the label.
24
*/
25
getUriLabel(resource: URI, options?: { relative?: boolean; noPrefix?: boolean; separator?: '/' | '\\'; appendWorkspaceSuffix?: boolean }): string;
26
getUriBasenameLabel(resource: URI): string;
27
getWorkspaceLabel(workspace: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI | IWorkspace), options?: { verbose: Verbosity }): string;
28
getHostLabel(scheme: string, authority?: string): string;
29
getHostTooltip(scheme: string, authority?: string): string | undefined;
30
getSeparator(scheme: string, authority?: string): '/' | '\\';
31
32
registerFormatter(formatter: ResourceLabelFormatter): IDisposable;
33
onDidChangeFormatters: Event<IFormatterChangeEvent>;
34
35
/**
36
* Registers a formatter that's cached for the machine beyond the lifecycle
37
* of the current window. Disposing the formatter _will not_ remove it from
38
* the cache.
39
*/
40
registerCachedFormatter(formatter: ResourceLabelFormatter): IDisposable;
41
}
42
43
export const enum Verbosity {
44
SHORT,
45
MEDIUM,
46
LONG
47
}
48
49
export interface IFormatterChangeEvent {
50
scheme: string;
51
}
52
53
export interface ResourceLabelFormatter {
54
scheme: string;
55
authority?: string;
56
priority?: boolean;
57
formatting: ResourceLabelFormatting;
58
}
59
60
export interface ResourceLabelFormatting {
61
label: string; // myLabel:/${path}
62
separator: '/' | '\\' | '';
63
tildify?: boolean;
64
normalizeDriveLetter?: boolean;
65
workspaceSuffix?: string;
66
workspaceTooltip?: string;
67
authorityPrefix?: string;
68
stripPathStartingSeparator?: boolean;
69
}
70
71