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 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
	titleRange?: IRange;
	title?: 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
	valueRange: IRange;
33 34
	description: string[];
	descriptionRanges: 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
	groupsTerms: string[];
51
	getSetting(key: string): ISetting;
S
Sandeep Somavarapu 已提交
52
	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;

63 64 65
	defaultSettingsResource: URI;
	defaultKeybindingsResource: URI;

S
Sandeep Somavarapu 已提交
66
	createDefaultPreferencesEditorModel(uri: URI): TPromise<IPreferencesEditorModel>;
67
	resolvePreferencesEditorModel(uri: URI): TPromise<IPreferencesEditorModel>;
S
Sandeep Somavarapu 已提交
68

69 70 71
	openGlobalSettings(): TPromise<void>;
	openWorkspaceSettings(): TPromise<void>;
	openGlobalKeybindingSettings(): TPromise<void>;
S
Sandeep Somavarapu 已提交
72 73 74
}

export const CONTEXT_DEFAULT_SETTINGS_EDITOR = new RawContextKey<boolean>('defaultSettingsEditor', false);
75 76
export const DEFAULT_EDITOR_COMMAND_COLLAPSE_ALL = 'defaultSettingsEditor.action.collapseAllGroups';
export const DEFAULT_EDITOR_COMMAND_FOCUS_SEARCH = 'defaultSettings.action.focusSearch';