usLayoutResolvedKeybinding.ts ×14

Frontier kind: Code frontier

unlabeled · c_fd7ee7c284c1

699 tests · 4594 LOC · 24 files · introduces 0 tests · 45 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
14 ranges45 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
545 ranges4594 lines · 24 files · Browse complete extent
All tests (intent)
699 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 45 introduced LOC across 14 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/keybinding/common/usLayoutResolvedKeybinding.ts 45 introduced LOC · 14 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- usLayoutResolvedKeybinding.ts
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 { KeyCode, KeyCodeUtils, IMMUTABLE_CODE_TO_KEY_CODE, ScanCode } from '../../../base/common/keyCodes.js';
7 > import { SingleModifierChord, Chord, KeyCodeChord, Keybinding } from '../../../base/common/keybindings.js';
8 > import { OperatingSystem } from '../../../base/common/platform.js';
9 > import { BaseResolvedKeybinding } from './baseResolvedKeybinding.js';
10 > import { toEmptyArrayIfContainsNull } from './resolvedKeybindingItem.js';
11 >
12 > /**
13 > * Do not instantiate. Use KeybindingService to get a ResolvedKeybinding seeded with information about the current kb layout.
14 > */
15 > export class USLayoutResolvedKeybinding extends BaseResolvedKeybinding<KeyCodeChord> {
16 >
17 > constructor(chords: KeyCodeChord[], os: OperatingSystem) {
18 super(os, chords);
19 }
21 > private _keyCodeToUILabel(keyCode: KeyCode): string {
22 if (this._os === OperatingSystem.Macintosh) {
23 switch (keyCode) {
34 return KeyCodeUtils.toString(keyCode);
35 }
37 > protected _getLabel(chord: KeyCodeChord): string | null {
38 if (chord.isDuplicateModifierCase()) {
39 return '';
41 return this._keyCodeToUILabel(chord.keyCode);
42 }
44 > protected _getAriaLabel(chord: KeyCodeChord): string | null {
45 if (chord.isDuplicateModifierCase()) {
46 return '';
48 return KeyCodeUtils.toString(chord.keyCode);
49 }
51 > protected _getElectronAccelerator(chord: KeyCodeChord): string | null {
52 return KeyCodeUtils.toElectronAccelerator(chord.keyCode);
53 }
55 > protected _getUserSettingsLabel(chord: KeyCodeChord): string | null {
56 if (chord.isDuplicateModifierCase()) {
57 return '';
60 return (result ? result.toLowerCase() : result);
61 }
63 > protected _isWYSIWYG(): boolean {
64 return true;
65 }
67 > protected _getChordDispatch(chord: KeyCodeChord): string | null {
68 return USLayoutResolvedKeybinding.getDispatchStr(chord);
69 }
71 > public static getDispatchStr(chord: KeyCodeChord): string | null {
72 if (chord.isModifierKey()) {
73 return null;
91 return result;
92 }
94 > protected _getSingleModifierChordDispatch(keybinding: KeyCodeChord): SingleModifierChord | null {
95 if (keybinding.keyCode === KeyCode.Ctrl && !keybinding.shiftKey && !keybinding.altKey && !keybinding.metaKey) {
96 return 'ctrl';
107 return null;
108 }
110 > /**
111 > * *NOTE*: Check return value for `KeyCode.Unknown`.
112 > */
113 > private static _scanCodeToKeyCode(scanCode: ScanCode): KeyCode {
114 const immutableKeyCode = IMMUTABLE_CODE_TO_KEY_CODE[scanCode];
115 if (immutableKeyCode !== KeyCode.DependsOnKbLayout) {
170 return KeyCode.Unknown;
171 }
173 > private static _toKeyCodeChord(chord: Chord | null): KeyCodeChord | null {
174 if (!chord) {
175 return null;
184 return new KeyCodeChord(chord.ctrlKey, chord.shiftKey, chord.altKey, chord.metaKey, keyCode);
185 }
187 > public static resolveKeybinding(keybinding: Keybinding, os: OperatingSystem): USLayoutResolvedKeybinding[] {
188 const chords: KeyCodeChord[] = toEmptyArrayIfContainsNull(keybinding.chords.map(chord => this._toKeyCodeChord(chord)));
189 if (chords.length > 0) {