macLinuxKeyboardMapper.ts ×11

Frontier kind: Code frontier

unlabeled · c_63790234cc56

8 tests · 9747 LOC · 41 files · introduces 0 tests · 117 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
11 ranges117 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1415 ranges9747 lines · 41 files · Browse complete extent
All tests (intent)
8 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: 117 introduced LOC across 11 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.ts 117 introduced LOC · 11 ranges

Open complete file

108
109 public toString(): string {
110 > return `${this.ctrlKey ? 'Ctrl+' : ''}${this.shiftKey ? 'Shift+' : ''}${this.altKey ? 'Alt+' : ''}${ScanCodeUtils.toString(this.scanCode)}`; macLinuxKeyboardMapper.ts
111 > }
112
113 public equals(other: ScanCodeCombo): boolean {
121
122 private getProducedCharCode(mapping: IMacLinuxKeyMapping): string {
123 > if (!mapping) { macLinuxKeyboardMapper.ts
124 > return '';
125 > }
126 > if (this.ctrlKey && this.shiftKey && this.altKey) {
127 > return mapping.withShiftAltGr;
128 > }
129 > if (this.ctrlKey && this.altKey) {
130 > return mapping.withAltGr;
131 > }
132 > if (this.shiftKey) {
133 > return mapping.withShift;
134 > }
135 > return mapping.value;
136 > }
137
138 public getProducedChar(mapping: IMacLinuxKeyMapping): string {
139 > const charCode = MacLinuxKeyboardMapper.getCharCode(this.getProducedCharCode(mapping)); macLinuxKeyboardMapper.ts
140 > if (charCode === 0) {
141 > return ' --- ';
142 > }
143 > if (charCode >= CharCode.U_Combining_Grave_Accent && charCode <= CharCode.U_Combining_Latin_Small_Letter_X) {
144 // combining
145 return 'U+' + charCode.toString(16);
146 }
147 > return ' ' + String.fromCharCode(charCode) + ' '; macLinuxKeyboardMapper.ts
148 > }
149 }
150
163
164 public toString(): string {
165 > return `${this.ctrlKey ? 'Ctrl+' : ''}${this.shiftKey ? 'Shift+' : ''}${this.altKey ? 'Alt+' : ''}${KeyCodeUtils.toString(this.keyCode)}`; macLinuxKeyboardMapper.ts
166 > }
167 }
168
664
665 public dumpDebugInfo(): string {
666 > const result: string[] = []; macLinuxKeyboardMapper.ts
667 >
668 > const immutableSamples = [
669 > ScanCode.ArrowUp,
670 > ScanCode.Numpad0
671 > ];
672 >
673 > let cnt = 0;
674 > result.push(`isUSStandard: ${this._isUSStandard}`);
675 > result.push(`----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------`);
676 > for (let scanCode = ScanCode.None; scanCode < ScanCode.MAX_VALUE; scanCode++) {
677 > if (IMMUTABLE_CODE_TO_KEY_CODE[scanCode] !== KeyCode.DependsOnKbLayout) {
678 > if (immutableSamples.indexOf(scanCode) === -1) {
679 > continue;
680 > }
681 > }
682 >
683 > if (cnt % 4 === 0) {
684 > result.push(`| HW Code combination | Key | KeyCode combination | Pri | UI label | User settings | Electron accelerator | Dispatching string | WYSIWYG |`);
685 > result.push(`----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------`);
686 > }
687 > cnt++;
688 >
689 > const mapping = this._codeInfo[scanCode];
690 >
691 > for (let mod = 0; mod < 8; mod++) {
692 > const hwCtrlKey = (mod & 0b001) ? true : false;
693 > const hwShiftKey = (mod & 0b010) ? true : false;
694 > const hwAltKey = (mod & 0b100) ? true : false;
695 > const scanCodeCombo = new ScanCodeCombo(hwCtrlKey, hwShiftKey, hwAltKey, scanCode);
696 > const resolvedKb = this.resolveKeyboardEvent({
697 > _standardKeyboardEventBrand: true,
698 > ctrlKey: scanCodeCombo.ctrlKey,
699 > shiftKey: scanCodeCombo.shiftKey,
700 > altKey: scanCodeCombo.altKey,
701 > metaKey: false,
702 > altGraphKey: false,
703 > keyCode: KeyCode.DependsOnKbLayout,
704 > code: ScanCodeUtils.toString(scanCode)
705 > });
706 >
707 > const outScanCodeCombo = scanCodeCombo.toString();
708 > const outKey = scanCodeCombo.getProducedChar(mapping);
709 > const ariaLabel = resolvedKb.getAriaLabel();
710 > const outUILabel = (ariaLabel ? ariaLabel.replace(/Control\+/, 'Ctrl+') : null);
711 > const outUserSettings = resolvedKb.getUserSettingsLabel();
712 > const outElectronAccelerator = resolvedKb.getElectronAccelerator();
713 > const outDispatchStr = resolvedKb.getDispatchChords()[0];
714 >
715 > const isWYSIWYG = (resolvedKb ? resolvedKb.isWYSIWYG() : false);
716 > const outWYSIWYG = (isWYSIWYG ? ' ' : ' NO ');
717 >
718 > const kbCombos = this._scanCodeKeyCodeMapper.lookupScanCodeCombo(scanCodeCombo);
719 > if (kbCombos.length === 0) {
720 > result.push(`| ${this._leftPad(outScanCodeCombo, 30)} | ${outKey} | ${this._leftPad('', 25)} | ${this._leftPad('', 3)} | ${this._leftPad(outUILabel, 25)} | ${this._leftPad(outUserSettings, 30)} | ${this._leftPad(outElectronAccelerator, 25)} | ${this._leftPad(outDispatchStr, 30)} | ${outWYSIWYG} |`);
721 > } else {
722 > for (let i = 0, len = kbCombos.length; i < len; i++) {
723 > const kbCombo = kbCombos[i];
724 > // find out the priority of this scan code for this key code
725 > let colPriority: string;
726 >
727 > const scanCodeCombos = this._scanCodeKeyCodeMapper.lookupKeyCodeCombo(kbCombo);
728 > if (scanCodeCombos.length === 1) {
729 > // no need for priority, this key code combo maps to precisely this scan code combo
730 > colPriority = '';
731 > } else {
732 let priority = -1;
733 for (let j = 0; j < scanCodeCombos.length; j++) {
739 colPriority = String(priority);
740 }
742 > const outKeybinding = kbCombo.toString();
743 > if (i === 0) {
744 > result.push(`| ${this._leftPad(outScanCodeCombo, 30)} | ${outKey} | ${this._leftPad(outKeybinding, 25)} | ${this._leftPad(colPriority, 3)} | ${this._leftPad(outUILabel, 25)} | ${this._leftPad(outUserSettings, 30)} | ${this._leftPad(outElectronAccelerator, 25)} | ${this._leftPad(outDispatchStr, 30)} | ${outWYSIWYG} |`);
745 > } else {
746 // secondary keybindings
747 result.push(`| ${this._leftPad('', 30)} | | ${this._leftPad(outKeybinding, 25)} | ${this._leftPad(colPriority, 3)} | ${this._leftPad('', 25)} | ${this._leftPad('', 30)} | ${this._leftPad('', 25)} | ${this._leftPad('', 30)} | |`);
748 }
750 > }
751 >
752 > }
753 > result.push(`----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------`);
754 > }
755 >
756 > return result.join('\n');
757 > }
758
759 private _leftPad(str: string | null, cnt: number): string {
760 > if (str === null) { macLinuxKeyboardMapper.ts
761 > str = 'null';
762 > }
763 > while (str.length < cnt) {
764 > str = ' ' + str;
765 > }
766 > return str;
767 > }
768
769 public keyCodeChordToScanCodeChord(chord: KeyCodeChord): ScanCodeChord[] {