preferences.ts 2.3 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 11
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
S
Sandeep Somavarapu 已提交
12 13

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

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

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

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

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

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

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

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

59
export interface IPreferencesService {
60 61
	_serviceBrand: any;

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

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

69
	updateSetting(setting: ISetting, value: any): void;
S
Sandeep Somavarapu 已提交
70 71 72
}

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