Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/platform/keyboardLayout/common/keyboardConfig.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import * as nls from '../../../nls.js';
7
import { IConfigurationService } from '../../configuration/common/configuration.js';
8
import { OS, OperatingSystem } from '../../../base/common/platform.js';
9
import { ConfigurationScope, Extensions as ConfigExtensions, IConfigurationNode, IConfigurationRegistry } from '../../configuration/common/configurationRegistry.js';
10
import { Registry } from '../../registry/common/platform.js';
11
12
export const enum DispatchConfig {
13
Code,
14
KeyCode
15
}
16
17
export interface IKeyboardConfig {
18
dispatch: DispatchConfig;
19
mapAltGrToCtrlAlt: boolean;
20
}
21
22
export function readKeyboardConfig(configurationService: IConfigurationService): IKeyboardConfig {
23
const keyboard = configurationService.getValue<{ dispatch: any; mapAltGrToCtrlAlt: any } | undefined>('keyboard');
24
const dispatch = (keyboard?.dispatch === 'keyCode' ? DispatchConfig.KeyCode : DispatchConfig.Code);
25
const mapAltGrToCtrlAlt = Boolean(keyboard?.mapAltGrToCtrlAlt);
26
return { dispatch, mapAltGrToCtrlAlt };
27
}
28
29
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigExtensions.Configuration);
30
const keyboardConfiguration: IConfigurationNode = {
31
'id': 'keyboard',
32
'order': 15,
33
'type': 'object',
34
'title': nls.localize('keyboardConfigurationTitle', "Keyboard"),
35
'properties': {
36
'keyboard.dispatch': {
37
scope: ConfigurationScope.APPLICATION,
38
type: 'string',
39
enum: ['code', 'keyCode'],
40
default: 'code',
41
markdownDescription: nls.localize('dispatch', "Controls the dispatching logic for key presses to use either `code` (recommended) or `keyCode`."),
42
included: OS === OperatingSystem.Macintosh || OS === OperatingSystem.Linux
43
},
44
'keyboard.mapAltGrToCtrlAlt': {
45
scope: ConfigurationScope.APPLICATION,
46
type: 'boolean',
47
default: false,
48
markdownDescription: nls.localize('mapAltGrToCtrlAlt', "Controls if the AltGraph+ modifier should be treated as Ctrl+Alt+."),
49
included: OS === OperatingSystem.Windows
50
}
51
}
52
};
53
54
configurationRegistry.registerConfiguration(keyboardConfiguration);
55
56