macLinuxKeyboardMapper.ts ×26

Frontier kind: Code frontier

unlabeled · c_9668fd0dc7f1

83 tests · 9038 LOC · 41 files · introduces 0 tests · 125 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
26 ranges125 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1179 ranges9038 lines · 41 files · Browse complete extent
All tests (intent)
83 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: 125 introduced LOC across 26 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.ts 125 introduced LOC · 26 ranges

Open complete file

244 // Don't allow multiples
245 if (existingKeyCodeCombos && existingKeyCodeCombos.length !== 0) {
247 > }
248 }
249
434 const producesLatinLetter: boolean[] = [];
435 for (const strScanCode in rawMappings) {
436 > if (rawMappings.hasOwnProperty(strScanCode)) { macLinuxKeyboardMapper.ts
437 > const scanCode = ScanCodeUtils.toEnum(strScanCode);
438 > if (scanCode === ScanCode.None) {
439 continue;
440 }
441 > if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== KeyCode.DependsOnKbLayout) { macLinuxKeyboardMapper.ts
442 continue;
443 }
445 > const rawMapping = rawMappings[strScanCode];
446 > const value = MacLinuxKeyboardMapper.getCharCode(rawMapping.value);
447 >
448 > if (value >= CharCode.a && value <= CharCode.z) {
449 const upperCaseValue = CharCode.A + (value - CharCode.a);
450 producesLatinLetter[upperCaseValue] = true;
451 }
453 > }
454
455 const _registerLetterIfMissing = (charCode: CharCode, scanCode: ScanCode, value: string, withShift: string): void => {
496 let mappingsLen = 0;
497 for (const strScanCode in rawMappings) {
498 > if (rawMappings.hasOwnProperty(strScanCode)) { macLinuxKeyboardMapper.ts
499 > const scanCode = ScanCodeUtils.toEnum(strScanCode);
500 > if (scanCode === ScanCode.None) {
501 continue;
502 }
503 > if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== KeyCode.DependsOnKbLayout) { macLinuxKeyboardMapper.ts
504 continue;
505 }
507 > this._codeInfo[scanCode] = rawMappings[strScanCode];
508 >
509 > const rawMapping = missingLatinLettersOverride[strScanCode] || rawMappings[strScanCode];
510 > const value = MacLinuxKeyboardMapper.getCharCode(rawMapping.value);
511 > const withShift = MacLinuxKeyboardMapper.getCharCode(rawMapping.withShift);
512 > const withAltGr = MacLinuxKeyboardMapper.getCharCode(rawMapping.withAltGr);
513 > const withShiftAltGr = MacLinuxKeyboardMapper.getCharCode(rawMapping.withShiftAltGr);
514 >
515 > const mapping: IScanCodeMapping = {
516 > scanCode: scanCode,
517 > value: value,
518 > withShift: withShift,
519 > withAltGr: withAltGr,
520 > withShiftAltGr: withShiftAltGr,
521 > };
522 > mappings[mappingsLen++] = mapping;
523 >
524 > this._scanCodeToDispatch[scanCode] = `[${ScanCodeUtils.toString(scanCode)}]`;
525 >
526 > if (value >= CharCode.a && value <= CharCode.z) {
527 const upperCaseValue = CharCode.A + (value - CharCode.a);
528 this._scanCodeToLabel[scanCode] = String.fromCharCode(upperCaseValue);
529 > } else if (value >= CharCode.A && value <= CharCode.Z) { macLinuxKeyboardMapper.ts
530 this._scanCodeToLabel[scanCode] = String.fromCharCode(value);
531 > } else if (value) { macLinuxKeyboardMapper.ts
532 > this._scanCodeToLabel[scanCode] = String.fromCharCode(value);
533 > } else {
534 this._scanCodeToLabel[scanCode] = null;
535 }
537 > }
538
539 // Handle all `withShiftAltGr` entries
540 for (let i = mappings.length - 1; i >= 0; i--) {
541 > const mapping = mappings[i]; macLinuxKeyboardMapper.ts
542 > const scanCode = mapping.scanCode;
543 > const withShiftAltGr = mapping.withShiftAltGr;
544 > if (withShiftAltGr === mapping.withAltGr || withShiftAltGr === mapping.withShift || withShiftAltGr === mapping.value) {
545 > // handled below
546 > continue;
547 > }
548 const kb = MacLinuxKeyboardMapper._charCodeToKb(withShiftAltGr);
549 if (!kb) {
560 _registerIfUnknown(1, 1, 1, scanCode, 0, 0, 0, keyCode); // Ctrl+Alt+ScanCode => KeyCode
561 }
563 // Handle all `withAltGr` entries
564 for (let i = mappings.length - 1; i >= 0; i--) {
565 > const mapping = mappings[i]; macLinuxKeyboardMapper.ts
566 > const scanCode = mapping.scanCode;
567 > const withAltGr = mapping.withAltGr;
568 > if (withAltGr === mapping.withShift || withAltGr === mapping.value) {
569 // handled below
570 continue;
571 }
572 > const kb = MacLinuxKeyboardMapper._charCodeToKb(withAltGr); macLinuxKeyboardMapper.ts
573 > if (!kb) {
574 continue;
575 }
584 _registerIfUnknown(1, 0, 1, scanCode, 0, 0, 0, keyCode); // Ctrl+Alt+ScanCode => KeyCode
585 }
587 // Handle all `withShift` entries
588 for (let i = mappings.length - 1; i >= 0; i--) {
589 > const mapping = mappings[i]; macLinuxKeyboardMapper.ts
590 > const scanCode = mapping.scanCode;
591 > const withShift = mapping.withShift;
592 > if (withShift === mapping.value) {
593 // handled below
594 continue;
595 }
596 > const kb = MacLinuxKeyboardMapper._charCodeToKb(withShift); macLinuxKeyboardMapper.ts
597 > if (!kb) {
598 > continue;
599 > }
600 const kbShiftKey = kb.shiftKey;
601 const keyCode = kb.keyCode;
618 _registerIfUnknown(1, 1, 1, scanCode, 1, 1, 1, keyCode); // Ctrl+Shift+Alt+ScanCode => Ctrl+Shift+Alt+KeyCode
619 }
621 // Handle all `value` entries
622 for (let i = mappings.length - 1; i >= 0; i--) {
623 > const mapping = mappings[i]; macLinuxKeyboardMapper.ts
624 > const scanCode = mapping.scanCode;
625 > const kb = MacLinuxKeyboardMapper._charCodeToKb(mapping.value);
626 > if (!kb) {
627 continue;
628 }
629 > const kbShiftKey = kb.shiftKey; macLinuxKeyboardMapper.ts
630 > const keyCode = kb.keyCode;
631 >
632 > if (kbShiftKey) {
633 // ScanCode => Shift+KeyCode
634 _registerIfUnknown(0, 0, 0, scanCode, 0, 1, 0, keyCode); // ScanCode => Shift+KeyCode
636 _registerIfUnknown(1, 0, 0, scanCode, 1, 1, 0, keyCode); // Ctrl+ScanCode => Ctrl+Shift+KeyCode
637 _registerIfUnknown(1, 0, 1, scanCode, 1, 1, 1, keyCode); // Ctrl+Alt+ScanCode => Ctrl+Shift+Alt+KeyCode
638 > } else { macLinuxKeyboardMapper.ts
639 > // ScanCode => KeyCode
640 > _registerIfUnknown(0, 0, 0, scanCode, 0, 0, 0, keyCode); // ScanCode => KeyCode
641 > _registerIfUnknown(0, 0, 1, scanCode, 0, 0, 1, keyCode); // Alt+ScanCode => Alt+KeyCode
642 > _registerIfUnknown(0, 1, 0, scanCode, 0, 1, 0, keyCode); // Shift+ScanCode => Shift+KeyCode
643 > _registerIfUnknown(0, 1, 1, scanCode, 0, 1, 1, keyCode); // Shift+Alt+ScanCode => Shift+Alt+KeyCode
644 > _registerIfUnknown(1, 0, 0, scanCode, 1, 0, 0, keyCode); // Ctrl+ScanCode => Ctrl+KeyCode
645 > _registerIfUnknown(1, 0, 1, scanCode, 1, 0, 1, keyCode); // Ctrl+Alt+ScanCode => Ctrl+Alt+KeyCode
646 > _registerIfUnknown(1, 1, 0, scanCode, 1, 1, 0, keyCode); // Ctrl+Shift+ScanCode => Ctrl+Shift+KeyCode
647 > _registerIfUnknown(1, 1, 1, scanCode, 1, 1, 1, keyCode); // Ctrl+Shift+Alt+ScanCode => Ctrl+Shift+Alt+KeyCode
648 > }
649 > }
650 // Handle all left-over available digits
651 _registerAllCombos(0, 0, 0, ScanCode.Digit1, KeyCode.Digit1);
1012
1013 private static _redirectCharCode(charCode: number): number {
1014 > switch (charCode) { macLinuxKeyboardMapper.ts
1015 > // allow-any-unicode-next-line
1016 > // CJK: 。 「 」 【 】 ; ,
1017 > // map: . [ ] [ ] ; ,
1018 > case CharCode.U_IDEOGRAPHIC_FULL_STOP: return CharCode.Period;
1019 > case CharCode.U_LEFT_CORNER_BRACKET: return CharCode.OpenSquareBracket;
1020 > case CharCode.U_RIGHT_CORNER_BRACKET: return CharCode.CloseSquareBracket;
1021 > case CharCode.U_LEFT_BLACK_LENTICULAR_BRACKET: return CharCode.OpenSquareBracket;
1022 > case CharCode.U_RIGHT_BLACK_LENTICULAR_BRACKET: return CharCode.CloseSquareBracket;
1023 > case CharCode.U_FULLWIDTH_SEMICOLON: return CharCode.Semicolon;
1024 > case CharCode.U_FULLWIDTH_COMMA: return CharCode.Comma;
1025 > }
1026 > return charCode;
1027 > }
1028
1029 private static _charCodeToKb(charCode: number): { keyCode: KeyCode; shiftKey: boolean } | null {
1030 > charCode = this._redirectCharCode(charCode); macLinuxKeyboardMapper.ts
1031 > if (charCode < CHAR_CODE_TO_KEY_CODE.length) {
1032 > return CHAR_CODE_TO_KEY_CODE[charCode];
1033 > }
1034 > return null;
1035 > }
1036
1037 /**
1041 */
1042 public static getCharCode(char: string): number {
1043 > if (char.length === 0) { macLinuxKeyboardMapper.ts
1044 return 0;
1045 }
1046 > const charCode = char.charCodeAt(0); macLinuxKeyboardMapper.ts
1047 > switch (charCode) {
1048 > case CharCode.U_Combining_Grave_Accent: return CharCode.U_GRAVE_ACCENT;
1049 > case CharCode.U_Combining_Acute_Accent: return CharCode.U_ACUTE_ACCENT;
1050 > case CharCode.U_Combining_Circumflex_Accent: return CharCode.U_CIRCUMFLEX;
1051 > case CharCode.U_Combining_Tilde: return CharCode.U_SMALL_TILDE;
1052 > case CharCode.U_Combining_Macron: return CharCode.U_MACRON;
1053 > case CharCode.U_Combining_Overline: return CharCode.U_OVERLINE;
1054 > case CharCode.U_Combining_Breve: return CharCode.U_BREVE;
1055 > case CharCode.U_Combining_Dot_Above: return CharCode.U_DOT_ABOVE;
1056 > case CharCode.U_Combining_Diaeresis: return CharCode.U_DIAERESIS;
1057 > case CharCode.U_Combining_Ring_Above: return CharCode.U_RING_ABOVE;
1058 > case CharCode.U_Combining_Double_Acute_Accent: return CharCode.U_DOUBLE_ACUTE_ACCENT;
1059 > }
1060 > return charCode;
1061 > }
1062 }
1063