-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
core-preferences.ts
343 lines (336 loc) · 19.2 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
// *****************************************************************************
// 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-only WITH Classpath-exception-2.0
// *****************************************************************************
import { interfaces } from 'inversify';
import { environment } from '@theia/application-package/lib/environment';
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';
import { nls } from '../common/nls';
import { DefaultTheme } from '@theia/application-package/lib/application-props';
/* eslint-disable max-len */
const windowTitleDescription = [
nls.localizeByDefault('Controls the window title based on the current context such as the opened workspace or active editor. Variables are substituted based on the context:'),
nls.localizeByDefault('`${activeEditorShort}`: the file name (e.g. myFile.txt).'),
nls.localizeByDefault('`${activeEditorMedium}`: the path of the file relative to the workspace folder (e.g. myFolder/myFileFolder/myFile.txt).'),
nls.localizeByDefault('`${activeEditorLong}`: the full path of the file (e.g. /Users/Development/myFolder/myFileFolder/myFile.txt).'),
nls.localizeByDefault('`${activeFolderShort}`: the name of the folder the file is contained in (e.g. myFileFolder).'),
nls.localizeByDefault('`${activeFolderMedium}`: the path of the folder the file is contained in, relative to the workspace folder (e.g. myFolder/myFileFolder).'),
nls.localizeByDefault('`${activeFolderLong}`: the full path of the folder the file is contained in (e.g. /Users/Development/myFolder/myFileFolder).'),
nls.localizeByDefault('`${folderName}`: name of the workspace folder the file is contained in (e.g. myFolder).'),
nls.localizeByDefault('`${folderPath}`: file path of the workspace folder the file is contained in (e.g. /Users/Development/myFolder).'),
nls.localizeByDefault('`${rootName}`: name of the workspace with optional remote name and workspace indicator if applicable (e.g. myFolder, myRemoteFolder [SSH] or myWorkspace (Workspace)).'),
nls.localizeByDefault('`${rootPath}`: file path of the opened workspace or folder (e.g. /Users/Development/myWorkspace).'),
nls.localizeByDefault('`${appName}`: e.g. VS Code.'),
nls.localizeByDefault('`${remoteName}`: e.g. SSH'),
nls.localizeByDefault('`${dirty}`: an indicator for when the active editor has unsaved changes.'),
nls.localizeByDefault('`${separator}`: a conditional separator (" - ") that only shows when surrounded by variables with values or static text.')
].join('\n- ');
export const corePreferenceSchema: PreferenceSchema = {
'type': 'object',
properties: {
'application.confirmExit': {
type: 'string',
enum: [
'never',
'ifRequired',
'always',
],
default: 'ifRequired',
description: nls.localizeByDefault('Controls whether to show a confirmation dialog before closing the browser tab or window. Note that even if enabled, browsers may still decide to close a tab or window without confirmation and that this setting is only a hint that may not work in all cases.'),
},
'breadcrumbs.enabled': {
'type': 'boolean',
'default': true,
'description': nls.localizeByDefault('Enable/disable navigation breadcrumbs.'),
'scope': 'application'
},
'files.encoding': {
'type': 'string',
'enum': Object.keys(SUPPORTED_ENCODINGS),
'default': 'utf8',
'description': nls.localizeByDefault(
'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',
markdownDescription: nls.localizeByDefault('Controls the dispatching logic for key presses to use either `code` (recommended) or `keyCode`.')
},
'window.tabbar.enhancedPreview': {
type: 'string',
enum: ['classic', 'enhanced', 'visual'],
markdownEnumDescriptions: [
nls.localize('theia/core/enhancedPreview/classic', 'Display a simple preview of the tab with basic information.'),
nls.localize('theia/core/enhancedPreview/enhanced', 'Display an enhanced preview of the tab with additional information.'),
nls.localize('theia/core/enhancedPreview/visual', 'Display a visual preview of the tab.'),
],
default: 'classic',
description: nls.localize('theia/core/enhancedPreview', 'Controls what information about the tab should be displayed in horizontal tab bars, when hovering.')
},
'window.menuBarVisibility': {
type: 'string',
enum: ['classic', 'visible', 'hidden', 'compact'],
markdownEnumDescriptions: [
nls.localizeByDefault('Menu is displayed at the top of the window and only hidden in full screen mode.'),
nls.localizeByDefault('Menu is always visible at the top of the window even in full screen mode.'),
nls.localizeByDefault('Menu is always hidden.'),
nls.localizeByDefault('Menu is displayed as a compact button in the side bar. This value is ignored when {0} is {1}.', '`#window.titleBarStyle#`', '`native`')
],
default: 'classic',
scope: 'application',
markdownDescription: nls.localizeByDefault("Control the visibility of the menu bar. A setting of 'toggle' means that the menu bar is hidden and a single press of the Alt key will show it. A setting of 'compact' will move the menu into the side bar."),
included: !(isOSX && environment.electron.is())
},
'window.title': {
type: 'string',
default: isOSX
? '${activeEditorShort}${separator}${rootName}'
: '${dirty} ${activeEditorShort}${separator}${rootName}${separator}${appName}',
scope: 'application',
markdownDescription: windowTitleDescription
},
'window.titleSeparator': {
type: 'string',
default: ' - ',
scope: 'application',
markdownDescription: nls.localizeByDefault('Separator used by {0}.', '`#window.title#`')
},
'window.secondaryWindowPlacement': {
type: 'string',
enum: ['originalSize', 'halfWidth', 'fullSize'],
enumDescriptions: [
nls.localize('theia/core/secondaryWindow/originalSize', 'The position and size of the extracted widget will be the same as the original widget.'),
nls.localize('theia/core/secondaryWindow/halfWidth', 'The position and size of the extracted widget will be half the width of the running Theia application.'),
nls.localize('theia/core/secondaryWindow/fullSize', 'The position and size of the extracted widget will be the same as the running Theia application.'),
],
default: 'originalSize',
description: nls.localize('theia/core/secondaryWindow/description', 'Sets the initial position and size of the extracted secondary window.'),
},
'window.secondaryWindowAlwaysOnTop': {
type: 'boolean',
default: false,
description: nls.localize('theia/core/secondaryWindow/alwaysOnTop', 'When enabled, the secondary window stays above all other windows, including those of different applications.'),
},
'http.proxy': {
type: 'string',
pattern: '^https?://([^:]*(:[^@]*)?@)?([^:]+|\\[[:0-9a-fA-F]+\\])(:\\d+)?/?$|^$',
markdownDescription: nls.localizeByDefault('The proxy setting to use. If not set, will be inherited from the `http_proxy` and `https_proxy` environment variables.'),
scope: 'application'
},
'http.proxyStrictSSL': {
type: 'boolean',
default: true,
description: nls.localizeByDefault('Controls whether the proxy server certificate should be verified against the list of supplied CAs.'),
scope: 'application'
},
'http.proxyAuthorization': {
type: 'string',
markdownDescription: nls.localizeByDefault('The value to send as the `Proxy-Authorization` header for every network request.'),
scope: 'application'
},
'http.proxySupport': {
type: 'string',
enum: ['off', 'on', 'fallback', 'override'],
enumDescriptions: [
nls.localizeByDefault('Disable proxy support for extensions.'),
nls.localizeByDefault('Enable proxy support for extensions.'),
nls.localizeByDefault('Enable proxy support for extensions, fall back to request options, when no proxy found.'),
nls.localizeByDefault('Enable proxy support for extensions, override request options.'),
],
default: 'override',
description: nls.localizeByDefault('Use the proxy support for extensions.'),
scope: 'application'
},
'http.systemCertificates': {
type: 'boolean',
default: true,
description: nls.localizeByDefault('Controls whether CA certificates should be loaded from the OS. (On Windows and macOS, a reload of the window is required after turning this off.)'),
scope: 'application'
},
'workbench.list.openMode': {
type: 'string',
enum: [
'singleClick',
'doubleClick'
],
default: 'singleClick',
description: nls.localizeByDefault('Controls how to open items in trees and lists using the mouse (if supported). Note that some trees and lists might choose to ignore this setting if it is not applicable.')
},
'workbench.editor.highlightModifiedTabs': {
'type': 'boolean',
'markdownDescription': nls.localize('theia/core/highlightModifiedTabs', 'Controls whether a top border is drawn on modified (dirty) editor tabs or not.'),
'default': false
},
'workbench.editor.closeOnFileDelete': {
'type': 'boolean',
'description': nls.localizeByDefault('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 editors with unsaved changes will never close to preserve your data.'),
'default': false
},
'workbench.editor.mouseBackForwardToNavigate': {
'type': 'boolean',
'description': nls.localizeByDefault("Enables the use of mouse buttons four and five for commands 'Go Back' and 'Go Forward'."),
'default': true
},
'workbench.editor.revealIfOpen': {
'type': 'boolean',
'description': nls.localizeByDefault('Controls whether an editor is revealed in any of the visible groups if opened. If disabled, an editor will prefer to open in the currently active editor group. If enabled, an already opened editor will be revealed instead of opened again in the currently active editor group. Note that there are some cases where this setting is ignored, such as when forcing an editor to open in a specific group or to the side of the currently active group.'),
'default': false
},
'workbench.editor.decorations.badges': {
'type': 'boolean',
'description': nls.localizeByDefault('Controls whether editor file decorations should use badges.'),
'default': true
},
'workbench.commandPalette.history': {
type: 'number',
default: 50,
minimum: 0,
description: nls.localizeByDefault('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',
enum: ['dark', 'light', 'hc-theia'],
enumItemLabels: ['Dark (Theia)', 'Light (Theia)', 'High Contrast (Theia)'],
default: DefaultTheme.defaultForOSTheme(FrontendApplicationConfigProvider.get().defaultTheme),
description: nls.localizeByDefault('Specifies the color theme used in the workbench when {0} is not enabled.', '`#window.autoDetectColorScheme#`')
},
'workbench.iconTheme': {
type: ['string'],
enum: ['none', 'theia-file-icons'],
enumItemLabels: [nls.localizeByDefault('None'), 'File Icons (Theia)'],
default: FrontendApplicationConfigProvider.get().defaultIconTheme,
description: nls.localizeByDefault("Specifies the file icon theme used in the workbench or 'null' to not show any file icons.")
},
'workbench.silentNotifications': {
type: 'boolean',
default: false,
description: nls.localize('theia/core/silentNotifications', 'Controls whether to suppress notification popups.')
},
'workbench.statusBar.visible': {
type: 'boolean',
default: true,
description: nls.localizeByDefault('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: nls.localizeByDefault('Controls whether the tree should render indent guides.')
},
'workbench.hover.delay': {
type: 'number',
default: isOSX ? 1500 : 500,
description: nls.localizeByDefault('Controls the delay in milliseconds after which the hover is shown.')
},
'workbench.sash.hoverDelay': {
type: 'number',
default: 300,
minimum: 0,
maximum: 2000,
description: nls.localizeByDefault('Controls the hover feedback delay in milliseconds of the dragging area in between views/editors.')
},
'workbench.sash.size': {
type: 'number',
default: 4,
minimum: 1,
maximum: 20,
description: nls.localizeByDefault('Controls the feedback area size in pixels of the dragging area in between views/editors. Set it to a larger value if you feel it\'s hard to resize views using the mouse.')
},
'workbench.tab.maximize': {
type: 'boolean',
default: false,
description: nls.localize('theia/core/tabMaximize', 'Controls whether to maximize tabs on double click.')
},
'workbench.tab.shrinkToFit.enabled': {
type: 'boolean',
default: false,
description: nls.localize('theia/core/tabShrinkToFit', 'Shrink tabs to fit available space.')
},
'workbench.tab.shrinkToFit.minimumSize': {
type: 'number',
default: 50,
minimum: 10,
description: nls.localize('theia/core/tabMinimumSize', 'Specifies the minimum size for tabs.')
},
'workbench.tab.shrinkToFit.defaultSize': {
type: 'number',
default: 200,
minimum: 10,
description: nls.localize('theia/core/tabDefaultSize', 'Specifies the default size for tabs.')
},
'workbench.editorAssociations': {
type: 'object',
markdownDescription: nls.localizeByDefault('Configure [glob patterns](https://aka.ms/vscode-glob-patterns) to editors (for example `"*.hex": "hexEditor.hexedit"`). These have precedence over the default behavior.'),
patternProperties: {
'.*': {
type: 'string'
}
}
}
}
};
export interface CoreConfiguration {
'application.confirmExit': 'never' | 'ifRequired' | 'always';
'breadcrumbs.enabled': boolean;
'files.encoding': string;
'keyboard.dispatch': 'code' | 'keyCode';
'window.tabbar.enhancedPreview': 'classic' | 'enhanced' | 'visual';
'window.menuBarVisibility': 'classic' | 'visible' | 'hidden' | 'compact';
'window.title': string;
'window.titleSeparator': string;
'workbench.list.openMode': 'singleClick' | 'doubleClick';
'workbench.commandPalette.history': number;
'workbench.editor.highlightModifiedTabs': boolean;
'workbench.editor.mouseBackForwardToNavigate': boolean;
'workbench.editor.closeOnFileDelete': boolean;
'workbench.editor.revealIfOpen': boolean;
'workbench.editor.decorations.badges': boolean;
'workbench.colorTheme': string;
'workbench.iconTheme': string;
'workbench.silentNotifications': boolean;
'workbench.statusBar.visible': boolean;
'workbench.tree.renderIndentGuides': 'onHover' | 'none' | 'always';
'workbench.hover.delay': number;
'workbench.sash.hoverDelay': number;
'workbench.sash.size': number;
'workbench.tab.maximize': boolean;
'workbench.tab.shrinkToFit.enabled': boolean;
'workbench.tab.shrinkToFit.minimumSize': number;
'workbench.tab.shrinkToFit.defaultSize': number;
}
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);
}