-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
core-preferences.ts
163 lines (157 loc) · 7.45 KB
/
core-preferences.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/********************************************************************************
* Copyright (C) 2018 Google and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { interfaces } from 'inversify';
import { createPreferenceProxy, PreferenceProxy, PreferenceService, PreferenceContribution, PreferenceSchema } from './preferences';
import { SUPPORTED_ENCODINGS } from './supported-encodings';
import { FrontendApplicationConfigProvider } from './frontend-application-config-provider';
import { isOSX } from '../common/os';
export const corePreferenceSchema: PreferenceSchema = {
'type': 'object',
properties: {
'application.confirmExit': {
type: 'string',
enum: [
'never',
'ifRequired',
'always',
],
default: 'ifRequired',
description: 'When to confirm before closing the application window.',
},
'breadcrumbs.enabled': {
'type': 'boolean',
'default': true,
'description': 'Enable/disable navigation breadcrumbs.',
'scope': 'application'
},
'files.encoding': {
'type': 'string',
'enum': Object.keys(SUPPORTED_ENCODINGS),
'default': 'utf8',
'description': 'The default character set encoding to use when reading and writing files. This setting can also be configured per language.',
'scope': 'language-overridable',
'enumDescriptions': Object.keys(SUPPORTED_ENCODINGS).map(key => SUPPORTED_ENCODINGS[key].labelLong),
'included': Object.keys(SUPPORTED_ENCODINGS).length > 1
},
'keyboard.dispatch': {
type: 'string',
enum: [
'code',
'keyCode',
],
default: 'code',
description: 'Whether to interpret keypresses by the `code` of the physical key, or by the `keyCode` provided by the OS.'
},
'window.menuBarVisibility': {
type: 'string',
enum: ['classic', 'visible', 'hidden', 'compact'],
markdownEnumDescriptions: [
'Menu is displayed at the top of the window and only hidden in full screen mode.',
'Menu is always visible at the top of the window even in full screen mode.',
'Menu is always hidden.',
'Menu is displayed as a compact button in the sidebar.'
],
default: 'classic',
scope: 'application',
markdownDescription: `Control the visibility of the menu bar.
A setting of 'compact' will move the menu into the sidebar.`,
included: !isOSX
},
'workbench.list.openMode': {
type: 'string',
enum: [
'singleClick',
'doubleClick'
],
default: 'singleClick',
description: 'Controls how to open items in trees using the mouse.'
},
'workbench.editor.highlightModifiedTabs': {
'type': 'boolean',
'description': 'Controls whether a top border is drawn on modified (dirty) editor tabs or not.',
'default': false
},
'workbench.editor.closeOnFileDelete': {
'type': 'boolean',
// eslint-disable-next-line max-len
'description': 'Controls whether editors showing a file that was opened during the session should close automatically when getting deleted or renamed by some other process. Disabling this will keep the editor open on such an event. Note that deleting from within the application will always close the editor and that dirty files will never close to preserve your data.',
'default': false
},
'workbench.commandPalette.history': {
type: 'number',
default: 50,
minimum: 0,
description: 'Controls the number of recently used commands to keep in history for the command palette. Set to 0 to disable command history.'
},
'workbench.colorTheme': {
type: 'string',
default: FrontendApplicationConfigProvider.get().defaultTheme,
description: 'Specifies the color theme used in the workbench.'
},
'workbench.iconTheme': {
type: ['string', 'null'],
default: FrontendApplicationConfigProvider.get().defaultIconTheme,
description: "Specifies the icon theme used in the workbench or 'null' to not show any file icons."
},
'workbench.silentNotifications': {
type: 'boolean',
default: false,
description: 'Controls whether to suppress notification popups.'
},
'workbench.statusBar.visible': {
type: 'boolean',
default: true,
description: 'Controls the visibility of the status bar at the bottom of the workbench.'
},
'workbench.tree.renderIndentGuides': {
type: 'string',
enum: ['onHover', 'none', 'always'],
default: 'onHover',
description: 'Controls whether the tree should render indent guides.'
},
}
};
export interface CoreConfiguration {
'application.confirmExit': 'never' | 'ifRequired' | 'always';
'breadcrumbs.enabled': boolean;
'files.encoding': string
'keyboard.dispatch': 'code' | 'keyCode';
'window.menuBarVisibility': 'classic' | 'visible' | 'hidden' | 'compact';
'workbench.list.openMode': 'singleClick' | 'doubleClick';
'workbench.commandPalette.history': number;
'workbench.editor.highlightModifiedTabs': boolean;
'workbench.editor.closeOnFileDelete': boolean;
'workbench.colorTheme': string;
'workbench.iconTheme': string | null;
'workbench.silentNotifications': boolean;
'workbench.statusBar.visible': boolean;
'workbench.tree.renderIndentGuides': 'onHover' | 'none' | 'always';
}
export const CorePreferenceContribution = Symbol('CorePreferenceContribution');
export const CorePreferences = Symbol('CorePreferences');
export type CorePreferences = PreferenceProxy<CoreConfiguration>;
export function createCorePreferences(preferences: PreferenceService, schema: PreferenceSchema = corePreferenceSchema): CorePreferences {
return createPreferenceProxy(preferences, schema);
}
export function bindCorePreferences(bind: interfaces.Bind): void {
bind(CorePreferences).toDynamicValue(ctx => {
const preferences = ctx.container.get<PreferenceService>(PreferenceService);
const contribution = ctx.container.get<PreferenceContribution>(CorePreferenceContribution);
return createCorePreferences(preferences, contribution.schema);
}).inSingletonScope();
bind(CorePreferenceContribution).toConstantValue({ schema: corePreferenceSchema });
bind(PreferenceContribution).toService(CorePreferenceContribution);
}