當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript keybinding.KeybindingLabels類代碼示例

本文整理匯總了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();
	});
開發者ID:diarmaidm,項目名稱:vscode,代碼行數:54,代碼來源:abstractKeybindingService.test.ts

示例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');
	});
開發者ID:StateFarmIns,項目名稱:vscode,代碼行數:39,代碼來源:standaloneBase.test.ts

示例3: getElectronAcceleratorFor

	public getElectronAcceleratorFor(keybinding: Keybinding): string {
		return KeybindingLabels._toElectronAccelerator(keybinding);
	}
開發者ID:StateFarmIns,項目名稱:vscode,代碼行數:3,代碼來源:mockKeybindingService.ts

示例4: getAriaLabelFor

	public getAriaLabelFor(keybinding: Keybinding): string {
		return KeybindingLabels._toUSAriaLabel(keybinding);
	}
開發者ID:StateFarmIns,項目名稱:vscode,代碼行數:3,代碼來源:mockKeybindingService.ts

示例5: getHTMLLabelFor

	public getHTMLLabelFor(keybinding: Keybinding): IHTMLContentElement[] {
		return KeybindingLabels._toUSHTMLLabel(keybinding);
	}
開發者ID:StateFarmIns,項目名稱:vscode,代碼行數:3,代碼來源:mockKeybindingService.ts


注:本文中的vs/base/common/keybinding.KeybindingLabels類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。