Add tests, some renames & refactorings

上级 c9a7425b
......@@ -611,8 +611,8 @@ export abstract class ResolvedKeybinding {
/**
* Returns the parts that should be used for dispatching.
* Returns null for parts consisting of only modifier keys
* @example keybind "Shift" -> null
* @example keybind ("D" with shift == true) -> "shift+D"
* @example keybinding "Shift" -> null
* @example keybinding ("D" with shift == true) -> "shift+D"
*/
public abstract getDispatchParts(): (string | null)[];
......@@ -620,8 +620,8 @@ export abstract class ResolvedKeybinding {
* Returns the parts that should be used for dispatching modfier keys
* Does not return null for parts consisting of only modifier keys
* Useful for keybinding time sensitive double presses of a modifier key
* @example keybind "Shift" -> "shift"
* @example keybind ("D" with shift == true") -> "D"
* @example keybinding "Shift" -> "shift"
* @example keybinding ("D" with shift == true") -> null
*/
public abstract getModifierDispatchString(): (string | null)[];
public abstract getSingleModifierDispatchParts(): (string | null)[];
}
......@@ -180,26 +180,7 @@ export abstract class AbstractKeybindingService extends Disposable implements IK
}
protected _doublePressDispatch(e: IKeyboardEvent, target: IContextKeyServiceTarget): boolean {
const shouldPreventDefault = this._doDoublePressDispatch(this.resolveKeyboardEvent(e), target);
return shouldPreventDefault;
}
// stores the pressed key, and then clears it in 300ms
private _doublePressStart(singlekeyDispatchString: string) {
this._doublePressStop();
this._currentDoublePressKey = singlekeyDispatchString;
this._currentDoublePressKeyClearTimeout.cancelAndSet(() => {
this._currentDoublePressKey = null;
}, 300);
}
private _doublePressStop() {
this._currentDoublePressKeyClearTimeout.cancel();
this._currentDoublePressKey = null;
}
private _doDoublePressCheck(keybinding: ResolvedKeybinding): boolean {
const keybinding = this.resolveKeyboardEvent(e);
const parts = keybinding.getParts();
// for UI responsiveness we disable other keys
......@@ -214,30 +195,31 @@ export abstract class AbstractKeybindingService extends Disposable implements IK
}
// searches a keymap array to get the dispatch string
const [singlekeyDispatchString,] = keybinding.getModifierDispatchString();
const [singlekeyDispatchString,] = keybinding.getSingleModifierDispatchParts();
// we have a valid singlekeyDispatchString, store it for next keypress
if (this._currentDoublePressKey === null && singlekeyDispatchString !== null) {
this._doublePressStart(singlekeyDispatchString); // start
this._doublePressStop();
// stores the pressed key, and then clears it in 300ms
this._currentDoublePressKey = singlekeyDispatchString;
this._currentDoublePressKeyClearTimeout.cancelAndSet(() => {
this._currentDoublePressKey = null;
}, 300);
return false;
}
if (this._currentDoublePressKey !== null && singlekeyDispatchString === this._currentDoublePressKey) {
this._doublePressStop();
return true;
return this._doDispatch(keybinding, target, true);
}
this._doublePressStop();
return false;
}
private _doDoublePressDispatch(keybinding: ResolvedKeybinding, target: IContextKeyServiceTarget) {
const isDoublePress = this._doDoublePressCheck(keybinding);
if (isDoublePress) {
return this._doDispatch(keybinding, target, isDoublePress);
}
return false;
private _doublePressStop() {
this._currentDoublePressKeyClearTimeout.cancel();
this._currentDoublePressKey = null;
}
private _doDispatch(keybinding: ResolvedKeybinding, target: IContextKeyServiceTarget, isDoublePress = false): boolean {
......@@ -248,14 +230,14 @@ export abstract class AbstractKeybindingService extends Disposable implements IK
return false;
}
let firstPart = null; // the first keybind i.e. Ctrl+K
let currentChord = null;// the "second" keybind i.e. Ctrl+K "Ctrl+D"
let firstPart = null; // the first keybinding i.e. Ctrl+K
let currentChord = null;// the "second" keybinding i.e. Ctrl+K "Ctrl+D"
if (!isDoublePress) {
[firstPart,] = keybinding.getDispatchParts();
currentChord = this._currentChord ? this._currentChord.keypress : null;
} else {
const [dispatchKeyname,] = keybinding.getModifierDispatchString();
const [dispatchKeyname,] = keybinding.getSingleModifierDispatchParts();
firstPart = dispatchKeyname;
currentChord = dispatchKeyname;
}
......
......@@ -70,8 +70,8 @@ export abstract class BaseResolvedKeybinding<T extends Modifiers> extends Resolv
}
// for double press, same key keybindings, we need get the dispatch string
public getModifierDispatchString(): (string | null)[] {
return this._parts.map((keybinding) => this._keybindingToDispatchString(keybinding));
public getSingleModifierDispatchParts(): (string | null)[] {
return this._parts.map((keybinding) => this._getSingleModifierDispatchPart(keybinding));
}
protected abstract _getLabel(keybinding: T): string | null;
......@@ -80,5 +80,5 @@ export abstract class BaseResolvedKeybinding<T extends Modifiers> extends Resolv
protected abstract _getUserSettingsLabel(keybinding: T): string | null;
protected abstract _isWYSIWYG(keybinding: T): boolean;
protected abstract _getDispatchPart(keybinding: T): string | null;
protected abstract _keybindingToDispatchString(keybinding: T): string | null;
protected abstract _getSingleModifierDispatchPart(keybinding: T): string | null;
}
......@@ -26,12 +26,12 @@ export class ResolvedKeybindingItem {
let dispatchParts: string[] = [];
if (resolvedKeybinding) {
// normal keybind
// normal keybinding
dispatchParts = removeElementsAfterNulls(resolvedKeybinding.getDispatchParts());
// modifier only keybind
// modifier only keybinding
if (dispatchParts.length === 0) {
dispatchParts = removeElementsAfterNulls(resolvedKeybinding.getModifierDispatchString());
dispatchParts = removeElementsAfterNulls(resolvedKeybinding.getSingleModifierDispatchParts());
}
}
......
......@@ -112,7 +112,19 @@ export class USLayoutResolvedKeybinding extends BaseResolvedKeybinding<SimpleKey
return result;
}
protected _keybindingToDispatchString(keybinding: SimpleKeybinding): string | null {
return KeyCodeUtils.toString(keybinding.keyCode) || null;
protected _getSingleModifierDispatchPart(keybinding: SimpleKeybinding): string | null {
if (keybinding.keyCode === KeyCode.Ctrl && !keybinding.shiftKey && !keybinding.altKey && !keybinding.metaKey) {
return 'ctrl';
}
if (keybinding.keyCode === KeyCode.Shift && !keybinding.ctrlKey && !keybinding.altKey && !keybinding.metaKey) {
return 'shift';
}
if (keybinding.keyCode === KeyCode.Alt && !keybinding.ctrlKey && !keybinding.shiftKey && !keybinding.metaKey) {
return 'alt';
}
if (keybinding.keyCode === KeyCode.Meta && !keybinding.ctrlKey && !keybinding.shiftKey && !keybinding.altKey) {
return 'meta';
}
return null;
}
}
......@@ -251,7 +251,7 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
this.updateSchema();
this._register(extensionService.onDidRegisterExtensions(() => this.updateSchema()));
// for standard keybinds
// for standard keybindings
this._register(dom.addDisposableListener(window, dom.EventType.KEY_DOWN, (e: KeyboardEvent) => {
this.isComposingGlobalContextKey.set(e.isComposing);
const keyEvent = new StandardKeyboardEvent(e);
......@@ -264,7 +264,7 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
this.isComposingGlobalContextKey.set(false);
}));
// for double press keybinds
// for double modifier keybindings
this._register(dom.addDisposableListener(window, dom.EventType.KEY_UP, (e: KeyboardEvent) => {
this.isComposingGlobalContextKey.set(e.isComposing);
const keyEvent = new StandardKeyboardEvent(e);
......
......@@ -92,8 +92,20 @@ export class NativeResolvedKeybinding extends BaseResolvedKeybinding<ScanCodeBin
return result;
}
protected _keybindingToDispatchString(keybinding: ScanCodeBinding): string | null {
return this._mapper.getDispatchString(keybinding);
protected _getSingleModifierDispatchPart(keybinding: ScanCodeBinding): string | null {
if ((keybinding.scanCode === ScanCode.ControlLeft || keybinding.scanCode === ScanCode.ControlRight) && !keybinding.shiftKey && !keybinding.altKey && !keybinding.metaKey) {
return 'ctrl';
}
if ((keybinding.scanCode === ScanCode.AltLeft || keybinding.scanCode === ScanCode.AltRight) && !keybinding.ctrlKey && !keybinding.shiftKey && !keybinding.metaKey) {
return 'alt';
}
if ((keybinding.scanCode === ScanCode.ShiftLeft || keybinding.scanCode === ScanCode.ShiftRight) && !keybinding.ctrlKey && !keybinding.altKey && !keybinding.metaKey) {
return 'shift';
}
if ((keybinding.scanCode === ScanCode.MetaLeft || keybinding.scanCode === ScanCode.MetaRight) && !keybinding.ctrlKey && !keybinding.shiftKey && !keybinding.altKey) {
return 'meta';
}
return null;
}
}
......
......@@ -122,8 +122,20 @@ export class WindowsNativeResolvedKeybinding extends BaseResolvedKeybinding<Simp
return result;
}
protected _keybindingToDispatchString(keybinding: SimpleKeybinding): string | null {
return KeyCodeUtils.toString(keybinding.keyCode) || null;
protected _getSingleModifierDispatchPart(keybinding: SimpleKeybinding): string | null {
if (keybinding.keyCode === KeyCode.Ctrl && !keybinding.shiftKey && !keybinding.altKey && !keybinding.metaKey) {
return 'ctrl';
}
if (keybinding.keyCode === KeyCode.Shift && !keybinding.ctrlKey && !keybinding.altKey && !keybinding.metaKey) {
return 'shift';
}
if (keybinding.keyCode === KeyCode.Alt && !keybinding.ctrlKey && !keybinding.shiftKey && !keybinding.metaKey) {
return 'alt';
}
if (keybinding.keyCode === KeyCode.Meta && !keybinding.ctrlKey && !keybinding.shiftKey && !keybinding.altKey) {
return 'meta';
}
return null;
}
private static getProducedCharCode(kb: ScanCodeBinding, mapping: IScanCodeMapping): string | null {
......
......@@ -20,6 +20,7 @@ export interface IResolvedKeybinding {
isWYSIWYG: boolean;
isChord: boolean;
dispatchParts: (string | null)[];
singleModifierDispatchParts: (string | null)[];
}
function toIResolvedKeybinding(kb: ResolvedKeybinding): IResolvedKeybinding {
......@@ -31,6 +32,7 @@ function toIResolvedKeybinding(kb: ResolvedKeybinding): IResolvedKeybinding {
isWYSIWYG: kb.isWYSIWYG(),
isChord: kb.isChord(),
dispatchParts: kb.getDispatchParts(),
singleModifierDispatchParts: kb.getSingleModifierDispatchParts()
};
}
......
......@@ -28,6 +28,7 @@ suite('keyboardMapper - MAC fallback', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['meta+Z'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -43,6 +44,7 @@ suite('keyboardMapper - MAC fallback', () => {
isWYSIWYG: true,
isChord: true,
dispatchParts: ['meta+K', 'meta+='],
singleModifierDispatchParts: [null, null],
}]
);
});
......@@ -67,6 +69,7 @@ suite('keyboardMapper - MAC fallback', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['meta+Z'],
singleModifierDispatchParts: [null],
}
);
});
......@@ -89,11 +92,12 @@ suite('keyboardMapper - MAC fallback', () => {
isWYSIWYG: true,
isChord: true,
dispatchParts: ['meta+,', 'meta+/'],
singleModifierDispatchParts: [null, null],
}]
);
});
test('resolveKeyboardEvent Modifier only Meta+', () => {
test('resolveKeyboardEvent Single Modifier Meta+', () => {
assertResolveKeyboardEvent(
mapper,
{
......@@ -113,6 +117,107 @@ suite('keyboardMapper - MAC fallback', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['meta'],
}
);
});
test('resolveKeyboardEvent Single Modifier Shift+', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: true,
altKey: false,
metaKey: false,
keyCode: KeyCode.Shift,
code: null!
},
{
label: '',
ariaLabel: 'Shift',
electronAccelerator: null,
userSettingsLabel: 'shift',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['shift'],
}
);
});
test('resolveKeyboardEvent Single Modifier Alt+', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: false,
altKey: true,
metaKey: false,
keyCode: KeyCode.Alt,
code: null!
},
{
label: '',
ariaLabel: 'Alt',
electronAccelerator: null,
userSettingsLabel: 'alt',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['alt'],
}
);
});
test('resolveKeyboardEvent Single Modifier Meta+', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: false,
altKey: false,
metaKey: true,
keyCode: KeyCode.Meta,
code: null!
},
{
label: '',
ariaLabel: 'Command',
electronAccelerator: null,
userSettingsLabel: 'cmd',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['meta'],
}
);
});
test('resolveKeyboardEvent Only Modifiers Ctrl+Shift+', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: true,
altKey: false,
metaKey: false,
keyCode: KeyCode.Shift,
code: null!
},
{
label: '⌃⇧',
ariaLabel: 'Control+Shift',
electronAccelerator: null,
userSettingsLabel: 'ctrl+shift',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: [null],
}
);
});
......@@ -137,6 +242,7 @@ suite('keyboardMapper - LINUX fallback', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+Z'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -152,6 +258,7 @@ suite('keyboardMapper - LINUX fallback', () => {
isWYSIWYG: true,
isChord: true,
dispatchParts: ['ctrl+K', 'ctrl+='],
singleModifierDispatchParts: [null, null],
}]
);
});
......@@ -176,6 +283,7 @@ suite('keyboardMapper - LINUX fallback', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+Z'],
singleModifierDispatchParts: [null],
}
);
});
......@@ -194,6 +302,7 @@ suite('keyboardMapper - LINUX fallback', () => {
isWYSIWYG: true,
isChord: true,
dispatchParts: ['ctrl+,', 'ctrl+/'],
singleModifierDispatchParts: [null, null],
}]
);
});
......@@ -211,11 +320,12 @@ suite('keyboardMapper - LINUX fallback', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+,'],
singleModifierDispatchParts: [null],
}]
);
});
test('resolveKeyboardEvent Modifier only Ctrl+', () => {
test('resolveKeyboardEvent Single Modifier Ctrl+', () => {
assertResolveKeyboardEvent(
mapper,
{
......@@ -235,6 +345,7 @@ suite('keyboardMapper - LINUX fallback', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['ctrl'],
}
);
});
......
......@@ -67,6 +67,7 @@ suite('keyboardMapper - MAC de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['meta+[KeyA]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -82,6 +83,7 @@ suite('keyboardMapper - MAC de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['meta+[KeyB]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -97,6 +99,7 @@ suite('keyboardMapper - MAC de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['meta+[KeyY]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -121,6 +124,7 @@ suite('keyboardMapper - MAC de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['meta+[KeyY]'],
singleModifierDispatchParts: [null],
}
);
});
......@@ -136,6 +140,7 @@ suite('keyboardMapper - MAC de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+alt+meta+[Digit6]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -160,6 +165,7 @@ suite('keyboardMapper - MAC de_ch', () => {
isWYSIWYG: false,
isChord: false,
dispatchParts: ['meta+[BracketRight]'],
singleModifierDispatchParts: [null],
}
);
});
......@@ -175,6 +181,7 @@ suite('keyboardMapper - MAC de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+alt+[Digit9]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -190,6 +197,7 @@ suite('keyboardMapper - MAC de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['shift+meta+[Digit7]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -205,6 +213,7 @@ suite('keyboardMapper - MAC de_ch', () => {
isWYSIWYG: false,
isChord: false,
dispatchParts: ['shift+meta+[Minus]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -220,6 +229,7 @@ suite('keyboardMapper - MAC de_ch', () => {
isWYSIWYG: true,
isChord: true,
dispatchParts: ['meta+[KeyK]', 'ctrl+shift+alt+meta+[Digit7]'],
singleModifierDispatchParts: [null, null],
}]
);
});
......@@ -235,6 +245,7 @@ suite('keyboardMapper - MAC de_ch', () => {
isWYSIWYG: true,
isChord: true,
dispatchParts: ['meta+[KeyK]', 'shift+meta+[Digit0]'],
singleModifierDispatchParts: [null, null],
}]
);
});
......@@ -250,6 +261,7 @@ suite('keyboardMapper - MAC de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['meta+[ArrowDown]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -265,6 +277,7 @@ suite('keyboardMapper - MAC de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['meta+[Numpad0]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -280,6 +293,7 @@ suite('keyboardMapper - MAC de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['meta+[Home]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -304,6 +318,7 @@ suite('keyboardMapper - MAC de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['meta+[Home]'],
singleModifierDispatchParts: [null],
}
);
});
......@@ -327,11 +342,12 @@ suite('keyboardMapper - MAC de_ch', () => {
isWYSIWYG: false,
isChord: true,
dispatchParts: ['meta+[Comma]', 'shift+meta+[Digit7]'],
singleModifierDispatchParts: [null, null],
}]
);
});
test('resolveKeyboardEvent Modifier only MetaLeft+', () => {
test('resolveKeyboardEvent Single Modifier MetaLeft+', () => {
assertResolveKeyboardEvent(
mapper,
{
......@@ -351,11 +367,12 @@ suite('keyboardMapper - MAC de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['meta'],
}
);
});
test('resolveKeyboardEvent Modifier only MetaRight+', () => {
test('resolveKeyboardEvent Single Modifier MetaRight+', () => {
assertResolveKeyboardEvent(
mapper,
{
......@@ -375,6 +392,7 @@ suite('keyboardMapper - MAC de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['meta'],
}
);
});
......@@ -408,11 +426,12 @@ suite('keyboardMapper - MAC en_us', () => {
isWYSIWYG: true,
isChord: true,
dispatchParts: ['meta+[Comma]', 'meta+[Slash]'],
singleModifierDispatchParts: [null, null],
}]
);
});
test('resolveKeyboardEvent Modifier only MetaLeft+', () => {
test('resolveKeyboardEvent Single Modifier MetaLeft+', () => {
assertResolveKeyboardEvent(
mapper,
{
......@@ -432,11 +451,12 @@ suite('keyboardMapper - MAC en_us', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['meta'],
}
);
});
test('resolveKeyboardEvent Modifier only MetaRight+', () => {
test('resolveKeyboardEvent Single Modifier MetaRight+', () => {
assertResolveKeyboardEvent(
mapper,
{
......@@ -456,6 +476,7 @@ suite('keyboardMapper - MAC en_us', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['meta'],
}
);
});
......@@ -508,6 +529,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[KeyA]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -523,6 +545,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[KeyY]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -547,6 +570,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[KeyY]'],
singleModifierDispatchParts: [null],
}
);
});
......@@ -578,6 +602,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
isWYSIWYG: false,
isChord: false,
dispatchParts: ['ctrl+[BracketRight]'],
singleModifierDispatchParts: [null],
}
);
});
......@@ -593,6 +618,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+alt+[Digit0]'],
singleModifierDispatchParts: [null],
}, {
label: 'Ctrl+Alt+$',
ariaLabel: 'Control+Alt+$',
......@@ -601,6 +627,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
isWYSIWYG: false,
isChord: false,
dispatchParts: ['ctrl+alt+[Backslash]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -616,6 +643,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+shift+[Digit7]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -631,6 +659,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
isWYSIWYG: false,
isChord: false,
dispatchParts: ['ctrl+shift+[Minus]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -653,6 +682,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
isWYSIWYG: true,
isChord: true,
dispatchParts: ['ctrl+[KeyK]', 'ctrl+shift+[Digit0]'],
singleModifierDispatchParts: [null, null],
}]
);
});
......@@ -668,6 +698,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[ArrowDown]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -683,6 +714,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[Numpad0]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -698,6 +730,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[Home]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -722,6 +755,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[Home]'],
singleModifierDispatchParts: [null],
}
);
});
......@@ -746,6 +780,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[KeyX]'],
singleModifierDispatchParts: [null],
}
);
});
......@@ -764,11 +799,12 @@ suite('keyboardMapper - LINUX de_ch', () => {
isWYSIWYG: false,
isChord: true,
dispatchParts: ['ctrl+[Comma]', 'ctrl+shift+[Digit7]'],
singleModifierDispatchParts: [null, null],
}]
);
});
test('resolveKeyboardEvent Modifier only ControlLeft+', () => {
test('resolveKeyboardEvent Single Modifier ControlLeft+', () => {
assertResolveKeyboardEvent(
mapper,
{
......@@ -788,11 +824,12 @@ suite('keyboardMapper - LINUX de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['ctrl'],
}
);
});
test('resolveKeyboardEvent Modifier only ControlRight+', () => {
test('resolveKeyboardEvent Single Modifier ControlRight+', () => {
assertResolveKeyboardEvent(
mapper,
{
......@@ -812,6 +849,7 @@ suite('keyboardMapper - LINUX de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['ctrl'],
}
);
});
......@@ -845,6 +883,7 @@ suite('keyboardMapper - LINUX en_us', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[KeyA]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -860,6 +899,7 @@ suite('keyboardMapper - LINUX en_us', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[KeyZ]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -884,6 +924,7 @@ suite('keyboardMapper - LINUX en_us', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[KeyZ]'],
singleModifierDispatchParts: [null],
}
);
});
......@@ -899,6 +940,7 @@ suite('keyboardMapper - LINUX en_us', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[BracketRight]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -923,6 +965,7 @@ suite('keyboardMapper - LINUX en_us', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[BracketRight]'],
singleModifierDispatchParts: [null],
}
);
});
......@@ -938,6 +981,7 @@ suite('keyboardMapper - LINUX en_us', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['shift+[BracketRight]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -953,6 +997,7 @@ suite('keyboardMapper - LINUX en_us', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[Slash]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -968,6 +1013,7 @@ suite('keyboardMapper - LINUX en_us', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+shift+[Slash]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -983,6 +1029,7 @@ suite('keyboardMapper - LINUX en_us', () => {
isWYSIWYG: true,
isChord: true,
dispatchParts: ['ctrl+[KeyK]', 'ctrl+[Backslash]'],
singleModifierDispatchParts: [null, null],
}]
);
});
......@@ -998,6 +1045,7 @@ suite('keyboardMapper - LINUX en_us', () => {
isWYSIWYG: true,
isChord: true,
dispatchParts: ['ctrl+[KeyK]', 'ctrl+[Equal]'],
singleModifierDispatchParts: [null, null],
}]
);
});
......@@ -1013,6 +1061,7 @@ suite('keyboardMapper - LINUX en_us', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[ArrowDown]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -1028,6 +1077,7 @@ suite('keyboardMapper - LINUX en_us', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[Numpad0]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -1043,6 +1093,7 @@ suite('keyboardMapper - LINUX en_us', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[Home]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -1067,6 +1118,7 @@ suite('keyboardMapper - LINUX en_us', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[Home]'],
singleModifierDispatchParts: [null],
}
);
});
......@@ -1082,6 +1134,7 @@ suite('keyboardMapper - LINUX en_us', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+shift+[Comma]'],
singleModifierDispatchParts: [null],
}, {
label: 'Ctrl+<',
ariaLabel: 'Control+<',
......@@ -1090,6 +1143,7 @@ suite('keyboardMapper - LINUX en_us', () => {
isWYSIWYG: false,
isChord: false,
dispatchParts: ['ctrl+[IntlBackslash]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -1105,6 +1159,7 @@ suite('keyboardMapper - LINUX en_us', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[Enter]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -1129,6 +1184,7 @@ suite('keyboardMapper - LINUX en_us', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[Enter]'],
singleModifierDispatchParts: [null],
}
);
});
......@@ -1147,6 +1203,7 @@ suite('keyboardMapper - LINUX en_us', () => {
isWYSIWYG: true,
isChord: true,
dispatchParts: ['ctrl+[Comma]', 'ctrl+[Slash]'],
singleModifierDispatchParts: [null, null],
}]
);
});
......@@ -1164,11 +1221,12 @@ suite('keyboardMapper - LINUX en_us', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[Comma]'],
singleModifierDispatchParts: [null],
}]
);
});
test('resolveKeyboardEvent Modifier only ControlLeft+', () => {
test('resolveKeyboardEvent Single Modifier ControlLeft+', () => {
assertResolveKeyboardEvent(
mapper,
{
......@@ -1188,11 +1246,12 @@ suite('keyboardMapper - LINUX en_us', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['ctrl'],
}
);
});
test('resolveKeyboardEvent Modifier only ControlRight+', () => {
test('resolveKeyboardEvent Single Modifier ControlRight+', () => {
assertResolveKeyboardEvent(
mapper,
{
......@@ -1212,6 +1271,182 @@ suite('keyboardMapper - LINUX en_us', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['ctrl'],
}
);
});
test('resolveKeyboardEvent Single Modifier ShiftLeft+', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: true,
altKey: false,
metaKey: false,
keyCode: -1,
code: 'ShiftLeft'
},
{
label: 'Shift',
ariaLabel: 'Shift',
electronAccelerator: null,
userSettingsLabel: 'shift',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['shift'],
}
);
});
test('resolveKeyboardEvent Single Modifier ShiftRight+', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: true,
altKey: false,
metaKey: false,
keyCode: -1,
code: 'ShiftRight'
},
{
label: 'Shift',
ariaLabel: 'Shift',
electronAccelerator: null,
userSettingsLabel: 'shift',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['shift'],
}
);
});
test('resolveKeyboardEvent Single Modifier AltLeft+', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: false,
altKey: true,
metaKey: false,
keyCode: -1,
code: 'AltLeft'
},
{
label: 'Alt',
ariaLabel: 'Alt',
electronAccelerator: null,
userSettingsLabel: 'alt',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['alt'],
}
);
});
test('resolveKeyboardEvent Single Modifier AltRight+', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: false,
altKey: true,
metaKey: false,
keyCode: -1,
code: 'AltRight'
},
{
label: 'Alt',
ariaLabel: 'Alt',
electronAccelerator: null,
userSettingsLabel: 'alt',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['alt'],
}
);
});
test('resolveKeyboardEvent Single Modifier MetaLeft+', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: false,
altKey: false,
metaKey: true,
keyCode: -1,
code: 'MetaLeft'
},
{
label: 'Super',
ariaLabel: 'Super',
electronAccelerator: null,
userSettingsLabel: 'meta',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['meta'],
}
);
});
test('resolveKeyboardEvent Single Modifier MetaRight+', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: false,
altKey: false,
metaKey: true,
keyCode: -1,
code: 'MetaRight'
},
{
label: 'Super',
ariaLabel: 'Super',
electronAccelerator: null,
userSettingsLabel: 'meta',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['meta'],
}
);
});
test('resolveKeyboardEvent Only Modifiers Ctrl+Shift+', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: true,
altKey: false,
metaKey: false,
keyCode: -1,
code: 'ShiftLeft'
},
{
label: 'Ctrl+Shift',
ariaLabel: 'Control+Shift',
electronAccelerator: null,
userSettingsLabel: 'ctrl+shift',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: [null],
}
);
});
......@@ -1248,6 +1483,7 @@ suite('keyboardMapper', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[Backquote]'],
singleModifierDispatchParts: [null],
}
);
});
......@@ -1275,6 +1511,7 @@ suite('keyboardMapper', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: [dispatch],
singleModifierDispatchParts: [null],
}
);
}
......@@ -1315,6 +1552,7 @@ suite('keyboardMapper', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: [dispatch],
singleModifierDispatchParts: [null],
}
);
}
......@@ -1373,6 +1611,7 @@ suite('keyboardMapper - LINUX ru', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+[KeyS]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -1411,6 +1650,7 @@ suite('keyboardMapper - LINUX en_uk', () => {
isWYSIWYG: false,
isChord: false,
dispatchParts: ['ctrl+alt+[Minus]'],
singleModifierDispatchParts: [null],
}
);
});
......@@ -1444,6 +1684,7 @@ suite('keyboardMapper - MAC zh_hant', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['meta+[KeyC]'],
singleModifierDispatchParts: [null],
}]
);
});
......
......@@ -46,6 +46,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+A'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -62,6 +63,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+Z'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -86,6 +88,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+Z'],
singleModifierDispatchParts: [null],
}
);
});
......@@ -102,6 +105,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
isWYSIWYG: false,
isChord: false,
dispatchParts: ['ctrl+]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -126,6 +130,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
isWYSIWYG: false,
isChord: false,
dispatchParts: ['ctrl+]'],
singleModifierDispatchParts: [null],
}
);
});
......@@ -142,6 +147,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
isWYSIWYG: false,
isChord: false,
dispatchParts: ['shift+]'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -158,6 +164,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
isWYSIWYG: false,
isChord: false,
dispatchParts: ['ctrl+/'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -174,6 +181,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
isWYSIWYG: false,
isChord: false,
dispatchParts: ['ctrl+shift+/'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -190,6 +198,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
isWYSIWYG: false,
isChord: true,
dispatchParts: ['ctrl+K', 'ctrl+\\'],
singleModifierDispatchParts: [null, null],
}]
);
});
......@@ -214,6 +223,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+DownArrow'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -230,6 +240,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+NumPad0'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -246,6 +257,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+Home'],
singleModifierDispatchParts: [null],
}]
);
});
......@@ -270,6 +282,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+Home'],
singleModifierDispatchParts: [null],
}
);
});
......@@ -292,11 +305,12 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
isWYSIWYG: false,
isChord: true,
dispatchParts: ['ctrl+,', 'ctrl+/'],
singleModifierDispatchParts: [null, null],
}]
);
});
test('resolveKeyboardEvent Modifier only Ctrl+', () => {
test('resolveKeyboardEvent Single Modifier Ctrl+', () => {
assertResolveKeyboardEvent(
mapper,
{
......@@ -316,6 +330,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['ctrl'],
}
);
});
......@@ -345,6 +360,7 @@ suite('keyboardMapper - WINDOWS en_us', () => {
isWYSIWYG: true,
isChord: true,
dispatchParts: ['ctrl+K', 'ctrl+\\'],
singleModifierDispatchParts: [null, null],
}]
);
});
......@@ -363,6 +379,7 @@ suite('keyboardMapper - WINDOWS en_us', () => {
isWYSIWYG: true,
isChord: true,
dispatchParts: ['ctrl+,', 'ctrl+/'],
singleModifierDispatchParts: [null, null],
}]
);
});
......@@ -380,11 +397,12 @@ suite('keyboardMapper - WINDOWS en_us', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+,'],
singleModifierDispatchParts: [null],
}]
);
});
test('resolveKeyboardEvent Modifier only Ctrl+', () => {
test('resolveKeyboardEvent Single Modifier Ctrl+', () => {
assertResolveKeyboardEvent(
mapper,
{
......@@ -404,6 +422,107 @@ suite('keyboardMapper - WINDOWS en_us', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['ctrl'],
}
);
});
test('resolveKeyboardEvent Single Modifier Shift+', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: true,
altKey: false,
metaKey: false,
keyCode: KeyCode.Shift,
code: null!
},
{
label: 'Shift',
ariaLabel: 'Shift',
electronAccelerator: null,
userSettingsLabel: 'shift',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['shift'],
}
);
});
test('resolveKeyboardEvent Single Modifier Alt+', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: false,
altKey: true,
metaKey: false,
keyCode: KeyCode.Alt,
code: null!
},
{
label: 'Alt',
ariaLabel: 'Alt',
electronAccelerator: null,
userSettingsLabel: 'alt',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['alt'],
}
);
});
test('resolveKeyboardEvent Single Modifier Meta+', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: false,
shiftKey: false,
altKey: false,
metaKey: true,
keyCode: KeyCode.Meta,
code: null!
},
{
label: 'Windows',
ariaLabel: 'Windows',
electronAccelerator: null,
userSettingsLabel: 'win',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: ['meta'],
}
);
});
test('resolveKeyboardEvent Only Modifiers Ctrl+Shift+', () => {
assertResolveKeyboardEvent(
mapper,
{
_standardKeyboardEventBrand: true,
ctrlKey: true,
shiftKey: true,
altKey: false,
metaKey: false,
keyCode: KeyCode.Shift,
code: null!
},
{
label: 'Ctrl+Shift',
ariaLabel: 'Control+Shift',
electronAccelerator: null,
userSettingsLabel: 'ctrl+shift',
isWYSIWYG: true,
isChord: false,
dispatchParts: [null],
singleModifierDispatchParts: [null],
}
);
});
......@@ -441,6 +560,7 @@ suite('keyboardMapper - WINDOWS por_ptb', () => {
isWYSIWYG: false,
isChord: false,
dispatchParts: ['ctrl+ABNT_C1'],
singleModifierDispatchParts: [null],
}
);
});
......@@ -465,6 +585,7 @@ suite('keyboardMapper - WINDOWS por_ptb', () => {
isWYSIWYG: false,
isChord: false,
dispatchParts: ['ctrl+ABNT_C2'],
singleModifierDispatchParts: [null],
}
);
});
......@@ -494,6 +615,7 @@ suite('keyboardMapper - WINDOWS ru', () => {
isWYSIWYG: true,
isChord: true,
dispatchParts: ['ctrl+K', 'ctrl+K'],
singleModifierDispatchParts: [null, null],
}]
);
});
......@@ -529,6 +651,7 @@ suite('keyboardMapper - misc', () => {
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+B'],
singleModifierDispatchParts: [null],
}]
);
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册