Keep keyCodes.ts lean and mean
This commit is contained in:
parent
ce099db9fb
commit
81bb89dec6
23 changed files with 541 additions and 525 deletions
|
@ -15,7 +15,7 @@ import {EventEmitter} from 'vs/base/common/eventEmitter';
|
|||
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
|
||||
import {IContextViewProvider} from 'vs/base/browser/ui/contextview/contextview';
|
||||
import {IMenuOptions} from 'vs/base/browser/ui/menu/menu';
|
||||
import {Keybinding} from 'vs/base/common/keyCodes';
|
||||
import {Keybinding} from 'vs/base/common/keybinding';
|
||||
|
||||
export interface ILabelRenderer {
|
||||
(container: HTMLElement): IDisposable;
|
||||
|
|
|
@ -11,7 +11,7 @@ import {$} from 'vs/base/browser/builder';
|
|||
import {IActionRunner, IAction} from 'vs/base/common/actions';
|
||||
import {ActionBar, IActionItemProvider, ActionsOrientation} from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import {EventEmitter} from 'vs/base/common/eventEmitter';
|
||||
import {Keybinding} from 'vs/base/common/keyCodes';
|
||||
import {Keybinding} from 'vs/base/common/keybinding';
|
||||
|
||||
export interface IMenuOptions {
|
||||
context?: any;
|
||||
|
|
|
@ -14,7 +14,7 @@ import types = require('vs/base/common/types');
|
|||
import {Action, IActionRunner, IAction} from 'vs/base/common/actions';
|
||||
import {ActionBar, ActionsOrientation, IActionItemProvider, BaseActionItem} from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import {IContextMenuProvider, DropdownMenu, IActionProvider, ILabelRenderer, IDropdownMenuOptions} from 'vs/base/browser/ui/dropdown/dropdown';
|
||||
import {Keybinding} from 'vs/base/common/keyCodes';
|
||||
import {Keybinding} from 'vs/base/common/keybinding';
|
||||
|
||||
export const CONTEXT = 'context.toolbar';
|
||||
|
||||
|
|
|
@ -5,15 +5,6 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import * as defaultPlatform from 'vs/base/common/platform';
|
||||
import {IHTMLContentElement} from 'vs/base/common/htmlContent';
|
||||
|
||||
export interface ISimplifiedPlatform {
|
||||
isMacintosh: boolean;
|
||||
isWindows: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Virtual Key Codes, the value does not hold any inherent meaning.
|
||||
* Inspired somewhat from https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
|
||||
|
@ -199,11 +190,11 @@ export const enum KeyCode {
|
|||
MAX_VALUE
|
||||
}
|
||||
|
||||
interface IReverseMap {
|
||||
export interface IReverseMap {
|
||||
[str:string]:KeyCode;
|
||||
}
|
||||
|
||||
class Mapping {
|
||||
export class Mapping {
|
||||
|
||||
_fromKeyCode: string[];
|
||||
_toKeyCode: IReverseMap;
|
||||
|
@ -380,7 +371,7 @@ let STRING = createMapping((TO_STRING_MAP) => {
|
|||
});
|
||||
|
||||
|
||||
let USER_SETTINGS = createMapping((TO_USER_SETTINGS_MAP) => {
|
||||
export let USER_SETTINGS = createMapping((TO_USER_SETTINGS_MAP) => {
|
||||
for (let i = 0, len = STRING._fromKeyCode.length; i < len; i++) {
|
||||
TO_USER_SETTINGS_MAP[i] = STRING._fromKeyCode[i];
|
||||
}
|
||||
|
@ -472,495 +463,3 @@ export class BinaryKeybindings {
|
|||
return (keybinding & BinaryKeybindingsMask.KeyCode);
|
||||
}
|
||||
}
|
||||
|
||||
export class Keybinding {
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
private static _toUSLabel(value:number, Platform:ISimplifiedPlatform): string {
|
||||
return _asString(value, (Platform.isMacintosh ? MacUIKeyLabelProvider.INSTANCE : ClassicUIKeyLabelProvider.INSTANCE), Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for placing in an aria-label.
|
||||
*/
|
||||
private static _toUSAriaLabel(value:number, Platform:ISimplifiedPlatform): string {
|
||||
return _asString(value, AriaKeyLabelProvider.INSTANCE, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
private static _toUSHTMLLabel(value:number, Platform:ISimplifiedPlatform): IHTMLContentElement[] {
|
||||
return _asHTML(value, (Platform.isMacintosh ? MacUIKeyLabelProvider.INSTANCE : ClassicUIKeyLabelProvider.INSTANCE), Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
private static _toCustomLabel(value:number, labelProvider:IKeyBindingLabelProvider, Platform:ISimplifiedPlatform): string {
|
||||
return _asString(value, labelProvider, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
private static _toCustomHTMLLabel(value:number, labelProvider:IKeyBindingLabelProvider, Platform:ISimplifiedPlatform): IHTMLContentElement[] {
|
||||
return _asHTML(value, labelProvider, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* This prints the binding in a format suitable for electron's accelerators.
|
||||
* See https://github.com/electron/electron/blob/master/docs/api/accelerator.md
|
||||
*/
|
||||
private static _toElectronAccelerator(value:number, Platform:ISimplifiedPlatform): string {
|
||||
if (BinaryKeybindings.hasChord(value)) {
|
||||
// Electron cannot handle chords
|
||||
return null;
|
||||
}
|
||||
return _asString(value, ElectronAcceleratorLabelProvider.INSTANCE, Platform);
|
||||
}
|
||||
|
||||
private static _cachedKeybindingRegex: string = null;
|
||||
public static getUserSettingsKeybindingRegex(): string {
|
||||
if (!this._cachedKeybindingRegex) {
|
||||
let numpadKey = 'numpad(0|1|2|3|4|5|6|7|8|9|_multiply|_add|_subtract|_decimal|_divide|_separator)';
|
||||
let oemKey = '`|\\-|=|\\[|\\]|\\\\\\\\|;|\'|,|\\.|\\/|oem_8|oem_102';
|
||||
let specialKey = 'left|up|right|down|pageup|pagedown|end|home|tab|enter|escape|space|backspace|delete|pausebreak|capslock|insert|contextmenu|numlock|scrolllock';
|
||||
let casualKey = '[a-z]|[0-9]|f(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19)';
|
||||
let key = '((' + [numpadKey, oemKey, specialKey, casualKey].join(')|(') + '))';
|
||||
let mod = '((ctrl|shift|alt|cmd|win|meta)\\+)*';
|
||||
let keybinding = '(' + mod + key + ')';
|
||||
|
||||
this._cachedKeybindingRegex = '"\\s*(' + keybinding + '(\\s+' + keybinding +')?' + ')\\s*"';
|
||||
}
|
||||
return this._cachedKeybindingRegex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for the user settings file.
|
||||
*/
|
||||
public static toUserSettingsLabel(value:number, Platform:ISimplifiedPlatform = defaultPlatform): string {
|
||||
let result = _asString(value, UserSettingsKeyLabelProvider.INSTANCE, Platform);
|
||||
result = result.toLowerCase();
|
||||
|
||||
if (Platform.isMacintosh) {
|
||||
result = result.replace(/meta/g, 'cmd');
|
||||
} else if (Platform.isWindows) {
|
||||
result = result.replace(/meta/g, 'win');
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static fromUserSettingsLabel(input: string, Platform: ISimplifiedPlatform = defaultPlatform): number {
|
||||
if (!input) {
|
||||
return null;
|
||||
}
|
||||
input = input.toLowerCase().trim();
|
||||
|
||||
let ctrlCmd = false,
|
||||
shift = false,
|
||||
alt = false,
|
||||
winCtrl = false,
|
||||
key:string = '';
|
||||
|
||||
while (/^(ctrl|shift|alt|meta|win|cmd)(\+|\-)/.test(input)) {
|
||||
if (/^ctrl(\+|\-)/.test(input)) {
|
||||
if (Platform.isMacintosh) {
|
||||
winCtrl = true;
|
||||
} else {
|
||||
ctrlCmd = true;
|
||||
}
|
||||
input = input.substr('ctrl-'.length);
|
||||
}
|
||||
if (/^shift(\+|\-)/.test(input)) {
|
||||
shift = true;
|
||||
input = input.substr('shift-'.length);
|
||||
}
|
||||
if (/^alt(\+|\-)/.test(input)) {
|
||||
alt = true;
|
||||
input = input.substr('alt-'.length);
|
||||
}
|
||||
if (/^meta(\+|\-)/.test(input)) {
|
||||
if (Platform.isMacintosh) {
|
||||
ctrlCmd = true;
|
||||
} else {
|
||||
winCtrl = true;
|
||||
}
|
||||
input = input.substr('meta-'.length);
|
||||
}
|
||||
if (/^win(\+|\-)/.test(input)) {
|
||||
if (Platform.isMacintosh) {
|
||||
ctrlCmd = true;
|
||||
} else {
|
||||
winCtrl = true;
|
||||
}
|
||||
input = input.substr('win-'.length);
|
||||
}
|
||||
if (/^cmd(\+|\-)/.test(input)) {
|
||||
if (Platform.isMacintosh) {
|
||||
ctrlCmd = true;
|
||||
} else {
|
||||
winCtrl = true;
|
||||
}
|
||||
input = input.substr('cmd-'.length);
|
||||
}
|
||||
}
|
||||
|
||||
let chord: number = 0;
|
||||
|
||||
let firstSpaceIdx = input.indexOf(' ');
|
||||
if (firstSpaceIdx > 0) {
|
||||
key = input.substring(0, firstSpaceIdx);
|
||||
chord = Keybinding.fromUserSettingsLabel(input.substring(firstSpaceIdx), Platform);
|
||||
} else {
|
||||
key = input;
|
||||
}
|
||||
|
||||
let keyCode = USER_SETTINGS.toKeyCode(key);
|
||||
|
||||
let result = 0;
|
||||
if (ctrlCmd) {
|
||||
result |= KeyMod.CtrlCmd;
|
||||
}
|
||||
if (shift) {
|
||||
result |= KeyMod.Shift;
|
||||
}
|
||||
if (alt) {
|
||||
result |= KeyMod.Alt;
|
||||
}
|
||||
if (winCtrl) {
|
||||
result |= KeyMod.WinCtrl;
|
||||
}
|
||||
result |= keyCode;
|
||||
return KeyChord(result, chord);
|
||||
}
|
||||
|
||||
public value:number;
|
||||
|
||||
constructor(keybinding:number) {
|
||||
this.value = keybinding;
|
||||
}
|
||||
|
||||
public hasCtrlCmd(): boolean {
|
||||
return BinaryKeybindings.hasCtrlCmd(this.value);
|
||||
}
|
||||
|
||||
public hasShift(): boolean {
|
||||
return BinaryKeybindings.hasShift(this.value);
|
||||
}
|
||||
|
||||
public hasAlt(): boolean {
|
||||
return BinaryKeybindings.hasAlt(this.value);
|
||||
}
|
||||
|
||||
public hasWinCtrl(): boolean {
|
||||
return BinaryKeybindings.hasWinCtrl(this.value);
|
||||
}
|
||||
|
||||
public extractKeyCode(): KeyCode {
|
||||
return BinaryKeybindings.extractKeyCode(this.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
public _toUSLabel(Platform:ISimplifiedPlatform = defaultPlatform): string {
|
||||
return Keybinding._toUSLabel(this.value, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for placing in an aria-label.
|
||||
*/
|
||||
public _toUSAriaLabel(Platform:ISimplifiedPlatform = defaultPlatform): string {
|
||||
return Keybinding._toUSAriaLabel(this.value, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
public _toUSHTMLLabel(Platform:ISimplifiedPlatform = defaultPlatform): IHTMLContentElement[] {
|
||||
return Keybinding._toUSHTMLLabel(this.value, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
public toCustomLabel(labelProvider:IKeyBindingLabelProvider, Platform:ISimplifiedPlatform = defaultPlatform): string {
|
||||
return Keybinding._toCustomLabel(this.value, labelProvider, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
public toCustomHTMLLabel(labelProvider:IKeyBindingLabelProvider, Platform:ISimplifiedPlatform = defaultPlatform): IHTMLContentElement[] {
|
||||
return Keybinding._toCustomHTMLLabel(this.value, labelProvider, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* This prints the binding in a format suitable for electron's accelerators.
|
||||
* See https://github.com/electron/electron/blob/master/docs/api/accelerator.md
|
||||
*/
|
||||
public _toElectronAccelerator(Platform:ISimplifiedPlatform = defaultPlatform): string {
|
||||
return Keybinding._toElectronAccelerator(this.value, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for the user settings file.
|
||||
*/
|
||||
public toUserSettingsLabel(Platform:ISimplifiedPlatform = defaultPlatform): string {
|
||||
return Keybinding.toUserSettingsLabel(this.value, Platform);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export interface IKeyBindingLabelProvider {
|
||||
ctrlKeyLabel:string;
|
||||
shiftKeyLabel:string;
|
||||
altKeyLabel:string;
|
||||
cmdKeyLabel:string;
|
||||
windowsKeyLabel:string;
|
||||
modifierSeparator:string;
|
||||
getLabelForKey(keyCode:KeyCode): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print for Electron
|
||||
*/
|
||||
export class ElectronAcceleratorLabelProvider implements IKeyBindingLabelProvider {
|
||||
public static INSTANCE = new ElectronAcceleratorLabelProvider();
|
||||
|
||||
public ctrlKeyLabel = 'Ctrl';
|
||||
public shiftKeyLabel = 'Shift';
|
||||
public altKeyLabel = 'Alt';
|
||||
public cmdKeyLabel = 'Cmd';
|
||||
public windowsKeyLabel = 'Super';
|
||||
public modifierSeparator = '+';
|
||||
|
||||
public getLabelForKey(keyCode:KeyCode): string {
|
||||
switch (keyCode) {
|
||||
case KeyCode.UpArrow:
|
||||
return 'Up';
|
||||
case KeyCode.DownArrow:
|
||||
return 'Down';
|
||||
case KeyCode.LeftArrow:
|
||||
return 'Left';
|
||||
case KeyCode.RightArrow:
|
||||
return 'Right';
|
||||
}
|
||||
|
||||
return KeyCodeUtils.toString(keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print for Mac UI
|
||||
*/
|
||||
export class MacUIKeyLabelProvider implements IKeyBindingLabelProvider {
|
||||
public static INSTANCE = new MacUIKeyLabelProvider();
|
||||
|
||||
private static leftArrowUnicodeLabel = String.fromCharCode(8592);
|
||||
private static upArrowUnicodeLabel = String.fromCharCode(8593);
|
||||
private static rightArrowUnicodeLabel = String.fromCharCode(8594);
|
||||
private static downArrowUnicodeLabel = String.fromCharCode(8595);
|
||||
|
||||
public ctrlKeyLabel = '\u2303';
|
||||
public shiftKeyLabel = '\u21E7';
|
||||
public altKeyLabel = '\u2325';
|
||||
public cmdKeyLabel = '\u2318';
|
||||
public windowsKeyLabel = nls.localize('windowsKey', "Windows");
|
||||
public modifierSeparator = '';
|
||||
|
||||
public getLabelForKey(keyCode:KeyCode): string {
|
||||
switch (keyCode) {
|
||||
case KeyCode.LeftArrow:
|
||||
return MacUIKeyLabelProvider.leftArrowUnicodeLabel;
|
||||
case KeyCode.UpArrow:
|
||||
return MacUIKeyLabelProvider.upArrowUnicodeLabel;
|
||||
case KeyCode.RightArrow:
|
||||
return MacUIKeyLabelProvider.rightArrowUnicodeLabel;
|
||||
case KeyCode.DownArrow:
|
||||
return MacUIKeyLabelProvider.downArrowUnicodeLabel;
|
||||
}
|
||||
|
||||
return KeyCodeUtils.toString(keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Aria label provider for Mac.
|
||||
*/
|
||||
export class AriaKeyLabelProvider implements IKeyBindingLabelProvider {
|
||||
public static INSTANCE = new MacUIKeyLabelProvider();
|
||||
|
||||
public ctrlKeyLabel = nls.localize('ctrlKey.long', "Control");
|
||||
public shiftKeyLabel = nls.localize('shiftKey.long', "Shift");
|
||||
public altKeyLabel = nls.localize('altKey.long', "Alt");
|
||||
public cmdKeyLabel = nls.localize('cmdKey.long', "Command");
|
||||
public windowsKeyLabel = nls.localize('windowsKey.long', "Windows");
|
||||
public modifierSeparator = '+';
|
||||
|
||||
public getLabelForKey(keyCode:KeyCode): string {
|
||||
return KeyCodeUtils.toString(keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print for Windows, Linux UI
|
||||
*/
|
||||
export class ClassicUIKeyLabelProvider implements IKeyBindingLabelProvider {
|
||||
public static INSTANCE = new ClassicUIKeyLabelProvider();
|
||||
|
||||
public ctrlKeyLabel = nls.localize('ctrlKey', "Ctrl");
|
||||
public shiftKeyLabel = nls.localize('shiftKey', "Shift");
|
||||
public altKeyLabel = nls.localize('altKey', "Alt");
|
||||
public cmdKeyLabel = nls.localize('cmdKey', "Command");
|
||||
public windowsKeyLabel = nls.localize('windowsKey', "Windows");
|
||||
public modifierSeparator = '+';
|
||||
|
||||
public getLabelForKey(keyCode:KeyCode): string {
|
||||
return KeyCodeUtils.toString(keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print for the user settings file.
|
||||
*/
|
||||
class UserSettingsKeyLabelProvider implements IKeyBindingLabelProvider {
|
||||
public static INSTANCE = new UserSettingsKeyLabelProvider();
|
||||
|
||||
public ctrlKeyLabel = 'Ctrl';
|
||||
public shiftKeyLabel = 'Shift';
|
||||
public altKeyLabel = 'Alt';
|
||||
public cmdKeyLabel = 'Meta';
|
||||
public windowsKeyLabel = 'Meta';
|
||||
|
||||
public modifierSeparator = '+';
|
||||
|
||||
public getLabelForKey(keyCode:KeyCode): string {
|
||||
return USER_SETTINGS.fromKeyCode(keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
function _asString(keybinding:number, labelProvider:IKeyBindingLabelProvider, Platform:ISimplifiedPlatform): string {
|
||||
let result:string[] = [],
|
||||
ctrlCmd = BinaryKeybindings.hasCtrlCmd(keybinding),
|
||||
shift = BinaryKeybindings.hasShift(keybinding),
|
||||
alt = BinaryKeybindings.hasAlt(keybinding),
|
||||
winCtrl = BinaryKeybindings.hasWinCtrl(keybinding),
|
||||
keyCode = BinaryKeybindings.extractKeyCode(keybinding);
|
||||
|
||||
let keyLabel = labelProvider.getLabelForKey(keyCode);
|
||||
if (!keyLabel) {
|
||||
// cannot trigger this key code under this kb layout
|
||||
return '';
|
||||
}
|
||||
|
||||
// translate modifier keys: Ctrl-Shift-Alt-Meta
|
||||
if ((ctrlCmd && !Platform.isMacintosh) || (winCtrl && Platform.isMacintosh)) {
|
||||
result.push(labelProvider.ctrlKeyLabel);
|
||||
}
|
||||
|
||||
if (shift) {
|
||||
result.push(labelProvider.shiftKeyLabel);
|
||||
}
|
||||
|
||||
if (alt) {
|
||||
result.push(labelProvider.altKeyLabel);
|
||||
}
|
||||
|
||||
if (ctrlCmd && Platform.isMacintosh) {
|
||||
result.push(labelProvider.cmdKeyLabel);
|
||||
}
|
||||
|
||||
if (winCtrl && !Platform.isMacintosh) {
|
||||
result.push(labelProvider.windowsKeyLabel);
|
||||
}
|
||||
|
||||
// the actual key
|
||||
result.push(keyLabel);
|
||||
|
||||
var actualResult = result.join(labelProvider.modifierSeparator);
|
||||
|
||||
if (BinaryKeybindings.hasChord(keybinding)) {
|
||||
return actualResult + ' ' + _asString(BinaryKeybindings.extractChordPart(keybinding), labelProvider, Platform);
|
||||
}
|
||||
|
||||
return actualResult;
|
||||
}
|
||||
|
||||
function _pushKey(result:IHTMLContentElement[], str:string): void {
|
||||
if (result.length > 0) {
|
||||
result.push({
|
||||
tagName: 'span',
|
||||
text: '+'
|
||||
});
|
||||
}
|
||||
result.push({
|
||||
tagName: 'span',
|
||||
className: 'monaco-kbkey',
|
||||
text: str
|
||||
});
|
||||
}
|
||||
|
||||
function _asHTML(keybinding:number, labelProvider:IKeyBindingLabelProvider, Platform:ISimplifiedPlatform, isChord:boolean = false): IHTMLContentElement[] {
|
||||
let result:IHTMLContentElement[] = [],
|
||||
ctrlCmd = BinaryKeybindings.hasCtrlCmd(keybinding),
|
||||
shift = BinaryKeybindings.hasShift(keybinding),
|
||||
alt = BinaryKeybindings.hasAlt(keybinding),
|
||||
winCtrl = BinaryKeybindings.hasWinCtrl(keybinding),
|
||||
keyCode = BinaryKeybindings.extractKeyCode(keybinding);
|
||||
|
||||
let keyLabel = labelProvider.getLabelForKey(keyCode);
|
||||
if (!keyLabel) {
|
||||
// cannot trigger this key code under this kb layout
|
||||
return [];
|
||||
}
|
||||
|
||||
// translate modifier keys: Ctrl-Shift-Alt-Meta
|
||||
if ((ctrlCmd && !Platform.isMacintosh) || (winCtrl && Platform.isMacintosh)) {
|
||||
_pushKey(result, labelProvider.ctrlKeyLabel);
|
||||
}
|
||||
|
||||
if (shift) {
|
||||
_pushKey(result, labelProvider.shiftKeyLabel);
|
||||
}
|
||||
|
||||
if (alt) {
|
||||
_pushKey(result, labelProvider.altKeyLabel);
|
||||
}
|
||||
|
||||
if (ctrlCmd && Platform.isMacintosh) {
|
||||
_pushKey(result, labelProvider.cmdKeyLabel);
|
||||
}
|
||||
|
||||
if (winCtrl && !Platform.isMacintosh) {
|
||||
_pushKey(result, labelProvider.windowsKeyLabel);
|
||||
}
|
||||
|
||||
// the actual key
|
||||
_pushKey(result, keyLabel);
|
||||
|
||||
let chordTo: IHTMLContentElement[] = null;
|
||||
|
||||
if (BinaryKeybindings.hasChord(keybinding)) {
|
||||
chordTo = _asHTML(BinaryKeybindings.extractChordPart(keybinding), labelProvider, Platform, true);
|
||||
result.push({
|
||||
tagName: 'span',
|
||||
text: ' '
|
||||
});
|
||||
result = result.concat(chordTo);
|
||||
}
|
||||
|
||||
if (isChord) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return [{
|
||||
tagName: 'span',
|
||||
className: 'monaco-kb',
|
||||
children: result
|
||||
}];
|
||||
}
|
||||
|
|
508
src/vs/base/common/keybinding.ts
Normal file
508
src/vs/base/common/keybinding.ts
Normal file
|
@ -0,0 +1,508 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import * as defaultPlatform from 'vs/base/common/platform';
|
||||
import {IHTMLContentElement} from 'vs/base/common/htmlContent';
|
||||
import {KeyCode, KeyMod, KeyChord, KeyCodeUtils, BinaryKeybindings, USER_SETTINGS} from 'vs/base/common/keyCodes';
|
||||
|
||||
export interface ISimplifiedPlatform {
|
||||
isMacintosh: boolean;
|
||||
isWindows: boolean;
|
||||
}
|
||||
|
||||
export class Keybinding {
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
private static _toUSLabel(value:number, Platform:ISimplifiedPlatform): string {
|
||||
return _asString(value, (Platform.isMacintosh ? MacUIKeyLabelProvider.INSTANCE : ClassicUIKeyLabelProvider.INSTANCE), Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for placing in an aria-label.
|
||||
*/
|
||||
private static _toUSAriaLabel(value:number, Platform:ISimplifiedPlatform): string {
|
||||
return _asString(value, AriaKeyLabelProvider.INSTANCE, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
private static _toUSHTMLLabel(value:number, Platform:ISimplifiedPlatform): IHTMLContentElement[] {
|
||||
return _asHTML(value, (Platform.isMacintosh ? MacUIKeyLabelProvider.INSTANCE : ClassicUIKeyLabelProvider.INSTANCE), Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
private static _toCustomLabel(value:number, labelProvider:IKeyBindingLabelProvider, Platform:ISimplifiedPlatform): string {
|
||||
return _asString(value, labelProvider, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
private static _toCustomHTMLLabel(value:number, labelProvider:IKeyBindingLabelProvider, Platform:ISimplifiedPlatform): IHTMLContentElement[] {
|
||||
return _asHTML(value, labelProvider, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* This prints the binding in a format suitable for electron's accelerators.
|
||||
* See https://github.com/electron/electron/blob/master/docs/api/accelerator.md
|
||||
*/
|
||||
private static _toElectronAccelerator(value:number, Platform:ISimplifiedPlatform): string {
|
||||
if (BinaryKeybindings.hasChord(value)) {
|
||||
// Electron cannot handle chords
|
||||
return null;
|
||||
}
|
||||
return _asString(value, ElectronAcceleratorLabelProvider.INSTANCE, Platform);
|
||||
}
|
||||
|
||||
private static _cachedKeybindingRegex: string = null;
|
||||
public static getUserSettingsKeybindingRegex(): string {
|
||||
if (!this._cachedKeybindingRegex) {
|
||||
let numpadKey = 'numpad(0|1|2|3|4|5|6|7|8|9|_multiply|_add|_subtract|_decimal|_divide|_separator)';
|
||||
let oemKey = '`|\\-|=|\\[|\\]|\\\\\\\\|;|\'|,|\\.|\\/|oem_8|oem_102';
|
||||
let specialKey = 'left|up|right|down|pageup|pagedown|end|home|tab|enter|escape|space|backspace|delete|pausebreak|capslock|insert|contextmenu|numlock|scrolllock';
|
||||
let casualKey = '[a-z]|[0-9]|f(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19)';
|
||||
let key = '((' + [numpadKey, oemKey, specialKey, casualKey].join(')|(') + '))';
|
||||
let mod = '((ctrl|shift|alt|cmd|win|meta)\\+)*';
|
||||
let keybinding = '(' + mod + key + ')';
|
||||
|
||||
this._cachedKeybindingRegex = '"\\s*(' + keybinding + '(\\s+' + keybinding +')?' + ')\\s*"';
|
||||
}
|
||||
return this._cachedKeybindingRegex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for the user settings file.
|
||||
*/
|
||||
public static toUserSettingsLabel(value:number, Platform:ISimplifiedPlatform = defaultPlatform): string {
|
||||
let result = _asString(value, UserSettingsKeyLabelProvider.INSTANCE, Platform);
|
||||
result = result.toLowerCase();
|
||||
|
||||
if (Platform.isMacintosh) {
|
||||
result = result.replace(/meta/g, 'cmd');
|
||||
} else if (Platform.isWindows) {
|
||||
result = result.replace(/meta/g, 'win');
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static fromUserSettingsLabel(input: string, Platform: ISimplifiedPlatform = defaultPlatform): number {
|
||||
if (!input) {
|
||||
return null;
|
||||
}
|
||||
input = input.toLowerCase().trim();
|
||||
|
||||
let ctrlCmd = false,
|
||||
shift = false,
|
||||
alt = false,
|
||||
winCtrl = false,
|
||||
key:string = '';
|
||||
|
||||
while (/^(ctrl|shift|alt|meta|win|cmd)(\+|\-)/.test(input)) {
|
||||
if (/^ctrl(\+|\-)/.test(input)) {
|
||||
if (Platform.isMacintosh) {
|
||||
winCtrl = true;
|
||||
} else {
|
||||
ctrlCmd = true;
|
||||
}
|
||||
input = input.substr('ctrl-'.length);
|
||||
}
|
||||
if (/^shift(\+|\-)/.test(input)) {
|
||||
shift = true;
|
||||
input = input.substr('shift-'.length);
|
||||
}
|
||||
if (/^alt(\+|\-)/.test(input)) {
|
||||
alt = true;
|
||||
input = input.substr('alt-'.length);
|
||||
}
|
||||
if (/^meta(\+|\-)/.test(input)) {
|
||||
if (Platform.isMacintosh) {
|
||||
ctrlCmd = true;
|
||||
} else {
|
||||
winCtrl = true;
|
||||
}
|
||||
input = input.substr('meta-'.length);
|
||||
}
|
||||
if (/^win(\+|\-)/.test(input)) {
|
||||
if (Platform.isMacintosh) {
|
||||
ctrlCmd = true;
|
||||
} else {
|
||||
winCtrl = true;
|
||||
}
|
||||
input = input.substr('win-'.length);
|
||||
}
|
||||
if (/^cmd(\+|\-)/.test(input)) {
|
||||
if (Platform.isMacintosh) {
|
||||
ctrlCmd = true;
|
||||
} else {
|
||||
winCtrl = true;
|
||||
}
|
||||
input = input.substr('cmd-'.length);
|
||||
}
|
||||
}
|
||||
|
||||
let chord: number = 0;
|
||||
|
||||
let firstSpaceIdx = input.indexOf(' ');
|
||||
if (firstSpaceIdx > 0) {
|
||||
key = input.substring(0, firstSpaceIdx);
|
||||
chord = Keybinding.fromUserSettingsLabel(input.substring(firstSpaceIdx), Platform);
|
||||
} else {
|
||||
key = input;
|
||||
}
|
||||
|
||||
let keyCode = USER_SETTINGS.toKeyCode(key);
|
||||
|
||||
let result = 0;
|
||||
if (ctrlCmd) {
|
||||
result |= KeyMod.CtrlCmd;
|
||||
}
|
||||
if (shift) {
|
||||
result |= KeyMod.Shift;
|
||||
}
|
||||
if (alt) {
|
||||
result |= KeyMod.Alt;
|
||||
}
|
||||
if (winCtrl) {
|
||||
result |= KeyMod.WinCtrl;
|
||||
}
|
||||
result |= keyCode;
|
||||
return KeyChord(result, chord);
|
||||
}
|
||||
|
||||
public value:number;
|
||||
|
||||
constructor(keybinding:number) {
|
||||
this.value = keybinding;
|
||||
}
|
||||
|
||||
public hasCtrlCmd(): boolean {
|
||||
return BinaryKeybindings.hasCtrlCmd(this.value);
|
||||
}
|
||||
|
||||
public hasShift(): boolean {
|
||||
return BinaryKeybindings.hasShift(this.value);
|
||||
}
|
||||
|
||||
public hasAlt(): boolean {
|
||||
return BinaryKeybindings.hasAlt(this.value);
|
||||
}
|
||||
|
||||
public hasWinCtrl(): boolean {
|
||||
return BinaryKeybindings.hasWinCtrl(this.value);
|
||||
}
|
||||
|
||||
public extractKeyCode(): KeyCode {
|
||||
return BinaryKeybindings.extractKeyCode(this.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
public _toUSLabel(Platform:ISimplifiedPlatform = defaultPlatform): string {
|
||||
return Keybinding._toUSLabel(this.value, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for placing in an aria-label.
|
||||
*/
|
||||
public _toUSAriaLabel(Platform:ISimplifiedPlatform = defaultPlatform): string {
|
||||
return Keybinding._toUSAriaLabel(this.value, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
public _toUSHTMLLabel(Platform:ISimplifiedPlatform = defaultPlatform): IHTMLContentElement[] {
|
||||
return Keybinding._toUSHTMLLabel(this.value, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
public toCustomLabel(labelProvider:IKeyBindingLabelProvider, Platform:ISimplifiedPlatform = defaultPlatform): string {
|
||||
return Keybinding._toCustomLabel(this.value, labelProvider, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for rendering in the UI
|
||||
*/
|
||||
public toCustomHTMLLabel(labelProvider:IKeyBindingLabelProvider, Platform:ISimplifiedPlatform = defaultPlatform): IHTMLContentElement[] {
|
||||
return Keybinding._toCustomHTMLLabel(this.value, labelProvider, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* This prints the binding in a format suitable for electron's accelerators.
|
||||
* See https://github.com/electron/electron/blob/master/docs/api/accelerator.md
|
||||
*/
|
||||
public _toElectronAccelerator(Platform:ISimplifiedPlatform = defaultPlatform): string {
|
||||
return Keybinding._toElectronAccelerator(this.value, Platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the binding to a format appropiate for the user settings file.
|
||||
*/
|
||||
public toUserSettingsLabel(Platform:ISimplifiedPlatform = defaultPlatform): string {
|
||||
return Keybinding.toUserSettingsLabel(this.value, Platform);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export interface IKeyBindingLabelProvider {
|
||||
ctrlKeyLabel:string;
|
||||
shiftKeyLabel:string;
|
||||
altKeyLabel:string;
|
||||
cmdKeyLabel:string;
|
||||
windowsKeyLabel:string;
|
||||
modifierSeparator:string;
|
||||
getLabelForKey(keyCode:KeyCode): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print for Electron
|
||||
*/
|
||||
export class ElectronAcceleratorLabelProvider implements IKeyBindingLabelProvider {
|
||||
public static INSTANCE = new ElectronAcceleratorLabelProvider();
|
||||
|
||||
public ctrlKeyLabel = 'Ctrl';
|
||||
public shiftKeyLabel = 'Shift';
|
||||
public altKeyLabel = 'Alt';
|
||||
public cmdKeyLabel = 'Cmd';
|
||||
public windowsKeyLabel = 'Super';
|
||||
public modifierSeparator = '+';
|
||||
|
||||
public getLabelForKey(keyCode:KeyCode): string {
|
||||
switch (keyCode) {
|
||||
case KeyCode.UpArrow:
|
||||
return 'Up';
|
||||
case KeyCode.DownArrow:
|
||||
return 'Down';
|
||||
case KeyCode.LeftArrow:
|
||||
return 'Left';
|
||||
case KeyCode.RightArrow:
|
||||
return 'Right';
|
||||
}
|
||||
|
||||
return KeyCodeUtils.toString(keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print for Mac UI
|
||||
*/
|
||||
export class MacUIKeyLabelProvider implements IKeyBindingLabelProvider {
|
||||
public static INSTANCE = new MacUIKeyLabelProvider();
|
||||
|
||||
private static leftArrowUnicodeLabel = String.fromCharCode(8592);
|
||||
private static upArrowUnicodeLabel = String.fromCharCode(8593);
|
||||
private static rightArrowUnicodeLabel = String.fromCharCode(8594);
|
||||
private static downArrowUnicodeLabel = String.fromCharCode(8595);
|
||||
|
||||
public ctrlKeyLabel = '\u2303';
|
||||
public shiftKeyLabel = '\u21E7';
|
||||
public altKeyLabel = '\u2325';
|
||||
public cmdKeyLabel = '\u2318';
|
||||
public windowsKeyLabel = nls.localize('windowsKey', "Windows");
|
||||
public modifierSeparator = '';
|
||||
|
||||
public getLabelForKey(keyCode:KeyCode): string {
|
||||
switch (keyCode) {
|
||||
case KeyCode.LeftArrow:
|
||||
return MacUIKeyLabelProvider.leftArrowUnicodeLabel;
|
||||
case KeyCode.UpArrow:
|
||||
return MacUIKeyLabelProvider.upArrowUnicodeLabel;
|
||||
case KeyCode.RightArrow:
|
||||
return MacUIKeyLabelProvider.rightArrowUnicodeLabel;
|
||||
case KeyCode.DownArrow:
|
||||
return MacUIKeyLabelProvider.downArrowUnicodeLabel;
|
||||
}
|
||||
|
||||
return KeyCodeUtils.toString(keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Aria label provider for Mac.
|
||||
*/
|
||||
export class AriaKeyLabelProvider implements IKeyBindingLabelProvider {
|
||||
public static INSTANCE = new MacUIKeyLabelProvider();
|
||||
|
||||
public ctrlKeyLabel = nls.localize('ctrlKey.long', "Control");
|
||||
public shiftKeyLabel = nls.localize('shiftKey.long', "Shift");
|
||||
public altKeyLabel = nls.localize('altKey.long', "Alt");
|
||||
public cmdKeyLabel = nls.localize('cmdKey.long', "Command");
|
||||
public windowsKeyLabel = nls.localize('windowsKey.long', "Windows");
|
||||
public modifierSeparator = '+';
|
||||
|
||||
public getLabelForKey(keyCode:KeyCode): string {
|
||||
return KeyCodeUtils.toString(keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print for Windows, Linux UI
|
||||
*/
|
||||
export class ClassicUIKeyLabelProvider implements IKeyBindingLabelProvider {
|
||||
public static INSTANCE = new ClassicUIKeyLabelProvider();
|
||||
|
||||
public ctrlKeyLabel = nls.localize('ctrlKey', "Ctrl");
|
||||
public shiftKeyLabel = nls.localize('shiftKey', "Shift");
|
||||
public altKeyLabel = nls.localize('altKey', "Alt");
|
||||
public cmdKeyLabel = nls.localize('cmdKey', "Command");
|
||||
public windowsKeyLabel = nls.localize('windowsKey', "Windows");
|
||||
public modifierSeparator = '+';
|
||||
|
||||
public getLabelForKey(keyCode:KeyCode): string {
|
||||
return KeyCodeUtils.toString(keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print for the user settings file.
|
||||
*/
|
||||
class UserSettingsKeyLabelProvider implements IKeyBindingLabelProvider {
|
||||
public static INSTANCE = new UserSettingsKeyLabelProvider();
|
||||
|
||||
public ctrlKeyLabel = 'Ctrl';
|
||||
public shiftKeyLabel = 'Shift';
|
||||
public altKeyLabel = 'Alt';
|
||||
public cmdKeyLabel = 'Meta';
|
||||
public windowsKeyLabel = 'Meta';
|
||||
|
||||
public modifierSeparator = '+';
|
||||
|
||||
public getLabelForKey(keyCode:KeyCode): string {
|
||||
return USER_SETTINGS.fromKeyCode(keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
function _asString(keybinding:number, labelProvider:IKeyBindingLabelProvider, Platform:ISimplifiedPlatform): string {
|
||||
let result:string[] = [],
|
||||
ctrlCmd = BinaryKeybindings.hasCtrlCmd(keybinding),
|
||||
shift = BinaryKeybindings.hasShift(keybinding),
|
||||
alt = BinaryKeybindings.hasAlt(keybinding),
|
||||
winCtrl = BinaryKeybindings.hasWinCtrl(keybinding),
|
||||
keyCode = BinaryKeybindings.extractKeyCode(keybinding);
|
||||
|
||||
let keyLabel = labelProvider.getLabelForKey(keyCode);
|
||||
if (!keyLabel) {
|
||||
// cannot trigger this key code under this kb layout
|
||||
return '';
|
||||
}
|
||||
|
||||
// translate modifier keys: Ctrl-Shift-Alt-Meta
|
||||
if ((ctrlCmd && !Platform.isMacintosh) || (winCtrl && Platform.isMacintosh)) {
|
||||
result.push(labelProvider.ctrlKeyLabel);
|
||||
}
|
||||
|
||||
if (shift) {
|
||||
result.push(labelProvider.shiftKeyLabel);
|
||||
}
|
||||
|
||||
if (alt) {
|
||||
result.push(labelProvider.altKeyLabel);
|
||||
}
|
||||
|
||||
if (ctrlCmd && Platform.isMacintosh) {
|
||||
result.push(labelProvider.cmdKeyLabel);
|
||||
}
|
||||
|
||||
if (winCtrl && !Platform.isMacintosh) {
|
||||
result.push(labelProvider.windowsKeyLabel);
|
||||
}
|
||||
|
||||
// the actual key
|
||||
result.push(keyLabel);
|
||||
|
||||
var actualResult = result.join(labelProvider.modifierSeparator);
|
||||
|
||||
if (BinaryKeybindings.hasChord(keybinding)) {
|
||||
return actualResult + ' ' + _asString(BinaryKeybindings.extractChordPart(keybinding), labelProvider, Platform);
|
||||
}
|
||||
|
||||
return actualResult;
|
||||
}
|
||||
|
||||
function _pushKey(result:IHTMLContentElement[], str:string): void {
|
||||
if (result.length > 0) {
|
||||
result.push({
|
||||
tagName: 'span',
|
||||
text: '+'
|
||||
});
|
||||
}
|
||||
result.push({
|
||||
tagName: 'span',
|
||||
className: 'monaco-kbkey',
|
||||
text: str
|
||||
});
|
||||
}
|
||||
|
||||
function _asHTML(keybinding:number, labelProvider:IKeyBindingLabelProvider, Platform:ISimplifiedPlatform, isChord:boolean = false): IHTMLContentElement[] {
|
||||
let result:IHTMLContentElement[] = [],
|
||||
ctrlCmd = BinaryKeybindings.hasCtrlCmd(keybinding),
|
||||
shift = BinaryKeybindings.hasShift(keybinding),
|
||||
alt = BinaryKeybindings.hasAlt(keybinding),
|
||||
winCtrl = BinaryKeybindings.hasWinCtrl(keybinding),
|
||||
keyCode = BinaryKeybindings.extractKeyCode(keybinding);
|
||||
|
||||
let keyLabel = labelProvider.getLabelForKey(keyCode);
|
||||
if (!keyLabel) {
|
||||
// cannot trigger this key code under this kb layout
|
||||
return [];
|
||||
}
|
||||
|
||||
// translate modifier keys: Ctrl-Shift-Alt-Meta
|
||||
if ((ctrlCmd && !Platform.isMacintosh) || (winCtrl && Platform.isMacintosh)) {
|
||||
_pushKey(result, labelProvider.ctrlKeyLabel);
|
||||
}
|
||||
|
||||
if (shift) {
|
||||
_pushKey(result, labelProvider.shiftKeyLabel);
|
||||
}
|
||||
|
||||
if (alt) {
|
||||
_pushKey(result, labelProvider.altKeyLabel);
|
||||
}
|
||||
|
||||
if (ctrlCmd && Platform.isMacintosh) {
|
||||
_pushKey(result, labelProvider.cmdKeyLabel);
|
||||
}
|
||||
|
||||
if (winCtrl && !Platform.isMacintosh) {
|
||||
_pushKey(result, labelProvider.windowsKeyLabel);
|
||||
}
|
||||
|
||||
// the actual key
|
||||
_pushKey(result, keyLabel);
|
||||
|
||||
let chordTo: IHTMLContentElement[] = null;
|
||||
|
||||
if (BinaryKeybindings.hasChord(keybinding)) {
|
||||
chordTo = _asHTML(BinaryKeybindings.extractChordPart(keybinding), labelProvider, Platform, true);
|
||||
result.push({
|
||||
tagName: 'span',
|
||||
text: ' '
|
||||
});
|
||||
result = result.concat(chordTo);
|
||||
}
|
||||
|
||||
if (isChord) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return [{
|
||||
tagName: 'span',
|
||||
className: 'monaco-kb',
|
||||
children: result
|
||||
}];
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import {Keybinding} from 'vs/base/common/keyCodes';
|
||||
import {Keybinding} from 'vs/base/common/keybinding';
|
||||
|
||||
export interface IQuickNavigateConfiguration {
|
||||
keybindings: Keybinding[];
|
||||
|
|
|
@ -15,7 +15,7 @@ import { IWindowsService } from 'vs/code/electron-main/windows';
|
|||
import { IPath, VSCodeWindow } from 'vs/code/electron-main/window';
|
||||
import { IStorageService } from 'vs/code/electron-main/storage';
|
||||
import { IUpdateService, State as UpdateState } from 'vs/code/electron-main/update-manager';
|
||||
import { Keybinding } from 'vs/base/common/keyCodes';
|
||||
import { Keybinding } from 'vs/base/common/keybinding';
|
||||
import product from 'vs/platform/product';
|
||||
import pkg from 'vs/platform/package';
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
import * as nls from 'vs/nls';
|
||||
import {IAction} from 'vs/base/common/actions';
|
||||
import {KeyCode, KeyMod, Keybinding} from 'vs/base/common/keyCodes';
|
||||
import {KeyCode, KeyMod} from 'vs/base/common/keyCodes';
|
||||
import {Keybinding} from 'vs/base/common/keybinding';
|
||||
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
|
||||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
|
|
|
@ -9,7 +9,8 @@ import 'vs/css!./defineKeybinding';
|
|||
import * as nls from 'vs/nls';
|
||||
import {RunOnceScheduler} from 'vs/base/common/async';
|
||||
import {MarkedString} from 'vs/base/common/htmlContent';
|
||||
import {KeyCode, KeyMod, KeyChord, Keybinding} from 'vs/base/common/keyCodes';
|
||||
import {KeyCode, KeyMod, KeyChord} from 'vs/base/common/keyCodes';
|
||||
import {Keybinding} from 'vs/base/common/keybinding';
|
||||
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
import {renderHtml} from 'vs/base/browser/htmlContentRenderer';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import * as assert from 'assert';
|
||||
import {KeyCode as StandaloneKeyCode} from 'vs/editor/common/standalone/standaloneBase';
|
||||
import {KeyCode as RuntimeKeyCode} from 'vs/base/common/keyCodes';
|
||||
import {/*KeyCode, KeyMod, BinaryKeybindings,*/ Keybinding} from 'vs/base/common/keyCodes';
|
||||
import {Keybinding} from 'vs/base/common/keybinding';
|
||||
|
||||
suite('KeyCode', () => {
|
||||
test('is exported correctly in standalone editor', () => {
|
||||
|
|
|
@ -8,7 +8,7 @@ import { IDisposable } from 'vs/base/common/lifecycle';
|
|||
import { IAction } from 'vs/base/common/actions';
|
||||
import { IActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { Keybinding } from 'vs/base/common/keyCodes';
|
||||
import { Keybinding } from 'vs/base/common/keybinding';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export const IContextViewService = createDecorator<IContextViewService>('contextViewService');
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
import 'vs/css!./keybindings';
|
||||
import * as nls from 'vs/nls';
|
||||
import {IHTMLContentElement} from 'vs/base/common/htmlContent';
|
||||
import {KeyCode, Keybinding} from 'vs/base/common/keyCodes';
|
||||
import {KeyCode} from 'vs/base/common/keyCodes';
|
||||
import {Keybinding} from 'vs/base/common/keybinding';
|
||||
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import {isFalsyOrEmpty} from 'vs/base/common/arrays';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
'use strict';
|
||||
|
||||
import {IHTMLContentElement} from 'vs/base/common/htmlContent';
|
||||
import {Keybinding} from 'vs/base/common/keyCodes';
|
||||
import {Keybinding} from 'vs/base/common/keybinding';
|
||||
import {createDecorator} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import {BinaryKeybindings, ISimplifiedPlatform, Keybinding} from 'vs/base/common/keyCodes';
|
||||
import {BinaryKeybindings} from 'vs/base/common/keyCodes';
|
||||
import {ISimplifiedPlatform, Keybinding} from 'vs/base/common/keybinding';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import {IKeybindingItem, IUserFriendlyKeybinding} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
|
|
|
@ -5,9 +5,10 @@
|
|||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import {ISimplifiedPlatform, KeyCode, KeyMod, KeyChord} from 'vs/base/common/keyCodes';
|
||||
import {KeyCode, KeyMod, KeyChord} from 'vs/base/common/keyCodes';
|
||||
import {NormalizedKeybindingItem, IOSupport} from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import {IUserFriendlyKeybinding} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {ISimplifiedPlatform} from 'vs/base/common/keybinding';
|
||||
|
||||
suite('Keybinding IO', () => {
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
'use strict';
|
||||
|
||||
import {IHTMLContentElement} from 'vs/base/common/htmlContent';
|
||||
import {Keybinding} from 'vs/base/common/keyCodes';
|
||||
import {Keybinding} from 'vs/base/common/keybinding';
|
||||
import Event from 'vs/base/common/event';
|
||||
import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
|
||||
import {IContextKey, IContextKeyService, ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey';
|
||||
|
|
|
@ -38,7 +38,7 @@ import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
|
|||
import { CombinedInstallAction, UpdateAction, EnableAction } from './extensionsActions';
|
||||
import WebView from 'vs/workbench/parts/html/browser/webview';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { Keybinding } from 'vs/base/common/keyCodes';
|
||||
import { Keybinding } from 'vs/base/common/keybinding';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
|
||||
import { IMessageService } from 'vs/platform/message/common/message';
|
||||
|
|
|
@ -45,7 +45,8 @@ import {IEventService} from 'vs/platform/event/common/event';
|
|||
import {IInstantiationService, IConstructorSignature2} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IMessageService, IMessageWithAction, IConfirmation, Severity, CancelAction} from 'vs/platform/message/common/message';
|
||||
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
|
||||
import {KeyMod, KeyCode, Keybinding} from 'vs/base/common/keyCodes';
|
||||
import {KeyMod, KeyCode} from 'vs/base/common/keyCodes';
|
||||
import {Keybinding} from 'vs/base/common/keybinding';
|
||||
import {Selection} from 'vs/editor/common/core/selection';
|
||||
|
||||
export interface IEditableData {
|
||||
|
|
|
@ -46,7 +46,8 @@ import {IInstantiationService} from 'vs/platform/instantiation/common/instantiat
|
|||
import {IMessageService, IConfirmation, Severity} from 'vs/platform/message/common/message';
|
||||
import {IProgressService} from 'vs/platform/progress/common/progress';
|
||||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {KeyCode, KeyMod, Keybinding} from 'vs/base/common/keyCodes';
|
||||
import {KeyCode, KeyMod} from 'vs/base/common/keyCodes';
|
||||
import {Keybinding} from 'vs/base/common/keybinding';
|
||||
import {IKeyboardEvent} from 'vs/base/browser/keyboardEvent';
|
||||
import {IMenuService, IMenu, MenuId} from 'vs/platform/actions/common/actions';
|
||||
import {fillInActions} from 'vs/platform/actions/browser/menuItemActionItem';
|
||||
|
|
|
@ -22,7 +22,8 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
|||
import { OpenGlobalSettingsAction } from 'vs/workbench/browser/actions/openSettings';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { Keybinding, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { Keybinding } from 'vs/base/common/keybinding';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { asFileEditorInput } from 'vs/workbench/common/editor';
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import { IMessageService, Severity } from 'vs/platform/message/common/message';
|
|||
import { IStringDictionary } from 'vs/base/common/collections';
|
||||
import { ITerminalInstance } from 'vs/workbench/parts/terminal/electron-browser/terminal';
|
||||
import { IWorkspace } from 'vs/platform/workspace/common/workspace';
|
||||
import { Keybinding } from 'vs/base/common/keyCodes';
|
||||
import { Keybinding } from 'vs/base/common/keybinding';
|
||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { TabFocus } from 'vs/editor/common/config/commonEditorConfig';
|
||||
import { TerminalConfigHelper, IShell } from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import * as nls from 'vs/nls';
|
||||
import {IHTMLContentElement} from 'vs/base/common/htmlContent';
|
||||
import {IJSONSchema} from 'vs/base/common/jsonSchema';
|
||||
import {Keybinding} from 'vs/base/common/keyCodes';
|
||||
import {Keybinding} from 'vs/base/common/keybinding';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import {toDisposable} from 'vs/base/common/lifecycle';
|
||||
import {IEventService} from 'vs/platform/event/common/event';
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
'use strict';
|
||||
|
||||
import * as nativeKeymap from 'native-keymap';
|
||||
import {KeyCode, KeyCodeUtils, IKeyBindingLabelProvider, MacUIKeyLabelProvider, ClassicUIKeyLabelProvider, AriaKeyLabelProvider} from 'vs/base/common/keyCodes';
|
||||
import {KeyCode, KeyCodeUtils} from 'vs/base/common/keyCodes';
|
||||
import {IKeyBindingLabelProvider, MacUIKeyLabelProvider, ClassicUIKeyLabelProvider, AriaKeyLabelProvider} from 'vs/base/common/keybinding';
|
||||
import {lookupKeyCode, setExtractKeyCode} from 'vs/base/browser/keyboardEvent';
|
||||
import Platform = require('vs/base/common/platform');
|
||||
|
||||
|
|
Loading…
Reference in a new issue