preferences.ts 2.4 KB
Newer Older
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.
 *--------------------------------------------------------------------------------------------*/

S
Sandeep Somavarapu 已提交
6
import URI from 'vs/base/common/uri';
7
import { TPromise } from 'vs/base/common/winjs.base';
S
Sandeep Somavarapu 已提交
8
import { LinkedMap as Map } from 'vs/base/common/map';
S
Sandeep Somavarapu 已提交
9
import { IRange } from 'vs/editor/common/editorCommon';
S
Sandeep Somavarapu 已提交
10
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
S
Sandeep Somavarapu 已提交
11
import { IConfigurationValue } from 'vs/workbench/services/configuration/common/configurationEditing';
S
Sandeep Somavarapu 已提交
12
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
S
Sandeep Somavarapu 已提交
13 14

export interface ISettingsGroup {
S
Sandeep Somavarapu 已提交
15
	id: string;
16
	range: IRange;
S
Sandeep Somavarapu 已提交
17
	title: string;
18
	titleRange: IRange;
S
Sandeep Somavarapu 已提交
19 20 21 22
	sections: ISettingsSection[];
}

export interface ISettingsSection {
23 24
	descriptionRange?: IRange;
	description?: string;
S
Sandeep Somavarapu 已提交
25 26 27 28
	settings: ISetting[];
}

export interface ISetting {
29
	range: IRange;
S
Sandeep Somavarapu 已提交
30
	key: string;
S
Sandeep Somavarapu 已提交
31
	keyRange: IRange;
S
Sandeep Somavarapu 已提交
32
	value: any;
33 34
	valueRange: IRange;
	description: string;
35
	descriptionRange: IRange;
S
Sandeep Somavarapu 已提交
36 37
}

S
Sandeep Somavarapu 已提交
38 39 40 41 42 43
export interface IFilterResult {
	filteredGroups: ISettingsGroup[];
	allGroups: ISettingsGroup[];
	matches: Map<string, IRange[]>;
}

44
export interface IPreferencesEditorModel {
S
Sandeep Somavarapu 已提交
45 46
	uri: URI;
	content: string;
47 48 49
}

export interface ISettingsEditorModel extends IPreferencesEditorModel {
50
	settingsGroups: ISettingsGroup[];
S
Sandeep Somavarapu 已提交
51 52
	groupsTerms: string[];
	filterSettings(filter: string): IFilterResult;
S
Sandeep Somavarapu 已提交
53 54
}

55
export interface IKeybindingsEditorModel extends IPreferencesEditorModel {
S
Sandeep Somavarapu 已提交
56
}
57

58
export const IPreferencesService = createDecorator<IPreferencesService>('preferencesService');
59

60
export interface IPreferencesService {
61 62
	_serviceBrand: any;

S
Sandeep Somavarapu 已提交
63
	createDefaultPreferencesEditorModel(uri: URI): TPromise<IPreferencesEditorModel>;
64
	resolvePreferencesEditorModel(uri: URI): TPromise<IPreferencesEditorModel>;
S
Sandeep Somavarapu 已提交
65

66 67 68
	openGlobalSettings(): TPromise<void>;
	openWorkspaceSettings(): TPromise<void>;
	openGlobalKeybindingSettings(): TPromise<void>;
S
Sandeep Somavarapu 已提交
69

S
Sandeep Somavarapu 已提交
70
	copyConfiguration(configurationValue: IConfigurationValue): void;
S
Sandeep Somavarapu 已提交
71 72 73
}

export const CONTEXT_DEFAULT_SETTINGS_EDITOR = new RawContextKey<boolean>('defaultSettingsEditor', false);
S
Sandeep Somavarapu 已提交
74
export const DEFAULT_EDITOR_COMMAND_COLLAPSE_ALL = 'defaultSettingsEditor.action.collapseAllGroups';