本文整理匯總了TypeScript中vs/base/common/keybinding.KeybindingLabels類的典型用法代碼示例。如果您正苦於以下問題:TypeScript KeybindingLabels類的具體用法?TypeScript KeybindingLabels怎麽用?TypeScript KeybindingLabels使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了KeybindingLabels類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('issue #16498: chord mode is quit for invalid chords', () => {
let kbService = createTestKeybindingService([
kbItem(KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_X), 'chordCommand'),
kbItem(KeyCode.Backspace, 'simpleCommand'),
]);
// send Ctrl/Cmd + K
let shouldPreventDefault = kbService.dispatch(new Keybinding(KeyMod.CtrlCmd | KeyCode.KEY_K));
assert.equal(shouldPreventDefault, true);
assert.deepEqual(executeCommandCalls, []);
assert.deepEqual(showMessageCalls, []);
assert.deepEqual(statusMessageCalls, [
`(${KeybindingLabels._toUSLabel(new Keybinding(KeyMod.CtrlCmd | KeyCode.KEY_K))}) was pressed. Waiting for second key of chord...`
]);
assert.deepEqual(statusMessageCallsDisposed, []);
executeCommandCalls = [];
showMessageCalls = [];
statusMessageCalls = [];
statusMessageCallsDisposed = [];
// send backspace
shouldPreventDefault = kbService.dispatch(new Keybinding(KeyCode.Backspace));
assert.equal(shouldPreventDefault, true);
assert.deepEqual(executeCommandCalls, []);
assert.deepEqual(showMessageCalls, []);
assert.deepEqual(statusMessageCalls, [
`The key combination (${KeybindingLabels._toUSLabel(new Keybinding(KeyMod.CtrlCmd | KeyCode.KEY_K))}, ${KeybindingLabels._toUSLabel(new Keybinding(KeyCode.Backspace))}) is not a command.`
]);
assert.deepEqual(statusMessageCallsDisposed, [
`(${KeybindingLabels._toUSLabel(new Keybinding(KeyMod.CtrlCmd | KeyCode.KEY_K))}) was pressed. Waiting for second key of chord...`
]);
executeCommandCalls = [];
showMessageCalls = [];
statusMessageCalls = [];
statusMessageCallsDisposed = [];
// send backspace
shouldPreventDefault = kbService.dispatch(new Keybinding(KeyCode.Backspace));
assert.equal(shouldPreventDefault, true);
assert.deepEqual(executeCommandCalls, [{
commandId: 'simpleCommand',
args: [{}]
}]);
assert.deepEqual(showMessageCalls, []);
assert.deepEqual(statusMessageCalls, []);
assert.deepEqual(statusMessageCallsDisposed, []);
executeCommandCalls = [];
showMessageCalls = [];
statusMessageCalls = [];
statusMessageCallsDisposed = [];
kbService.dispose();
});
示例2: test
test('getUserSettingsKeybindingRegex', () => {
let regex = new RegExp(KeybindingLabels.getUserSettingsKeybindingRegex());
function testIsGood(userSettingsLabel: string, message: string = userSettingsLabel): void {
let userSettings = '"' + userSettingsLabel.replace(/\\/g, '\\\\') + '"';
let isGood = regex.test(userSettings);
assert.ok(isGood, message);
}
// check that all key codes are covered by the regex
let ignore: boolean[] = [];
ignore[RuntimeKeyCode.Shift] = true;
ignore[RuntimeKeyCode.Ctrl] = true;
ignore[RuntimeKeyCode.Alt] = true;
ignore[RuntimeKeyCode.Meta] = true;
for (let keyCode = RuntimeKeyCode.Unknown + 1; keyCode < RuntimeKeyCode.MAX_VALUE; keyCode++) {
if (ignore[keyCode]) {
continue;
}
let userSettings = KeybindingLabels.toUserSettingsLabel(keyCode);
testIsGood(userSettings, keyCode + ' - ' + StandaloneKeyCode[keyCode] + ' - ' + userSettings);
}
// one modifier
testIsGood('ctrl+a');
testIsGood('shift+a');
testIsGood('alt+a');
testIsGood('cmd+a');
testIsGood('meta+a');
testIsGood('win+a');
// more modifiers
testIsGood('ctrl+shift+a');
testIsGood('shift+alt+a');
testIsGood('ctrl+shift+alt+a');
// chords
testIsGood('ctrl+a ctrl+a');
});
示例3: getElectronAcceleratorFor
public getElectronAcceleratorFor(keybinding: Keybinding): string {
return KeybindingLabels._toElectronAccelerator(keybinding);
}
示例4: getAriaLabelFor
public getAriaLabelFor(keybinding: Keybinding): string {
return KeybindingLabels._toUSAriaLabel(keybinding);
}
示例5: getHTMLLabelFor
public getHTMLLabelFor(keybinding: Keybinding): IHTMLContentElement[] {
return KeybindingLabels._toUSHTMLLabel(keybinding);
}