diff --git a/src/vs/base/browser/ui/dropdown/dropdown.ts b/src/vs/base/browser/ui/dropdown/dropdown.ts index 7507e982836..622304d5677 100644 --- a/src/vs/base/browser/ui/dropdown/dropdown.ts +++ b/src/vs/base/browser/ui/dropdown/dropdown.ts @@ -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; diff --git a/src/vs/base/browser/ui/menu/menu.ts b/src/vs/base/browser/ui/menu/menu.ts index 3fb267d562c..a9752490044 100644 --- a/src/vs/base/browser/ui/menu/menu.ts +++ b/src/vs/base/browser/ui/menu/menu.ts @@ -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; diff --git a/src/vs/base/browser/ui/toolbar/toolbar.ts b/src/vs/base/browser/ui/toolbar/toolbar.ts index 3ef7c64babd..830e61d970d 100644 --- a/src/vs/base/browser/ui/toolbar/toolbar.ts +++ b/src/vs/base/browser/ui/toolbar/toolbar.ts @@ -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'; diff --git a/src/vs/base/common/keyCodes.ts b/src/vs/base/common/keyCodes.ts index 732af413bd3..4581f40960f 100644 --- a/src/vs/base/common/keyCodes.ts +++ b/src/vs/base/common/keyCodes.ts @@ -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 - }]; -} diff --git a/src/vs/base/common/keybinding.ts b/src/vs/base/common/keybinding.ts new file mode 100644 index 00000000000..c891250abd3 --- /dev/null +++ b/src/vs/base/common/keybinding.ts @@ -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 + }]; +} diff --git a/src/vs/base/parts/quickopen/common/quickOpen.ts b/src/vs/base/parts/quickopen/common/quickOpen.ts index 8bbe2285f39..a7fee71cb92 100644 --- a/src/vs/base/parts/quickopen/common/quickOpen.ts +++ b/src/vs/base/parts/quickopen/common/quickOpen.ts @@ -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[]; diff --git a/src/vs/code/electron-main/menus.ts b/src/vs/code/electron-main/menus.ts index 717856e91a8..d2fa04d6d2b 100644 --- a/src/vs/code/electron-main/menus.ts +++ b/src/vs/code/electron-main/menus.ts @@ -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'; diff --git a/src/vs/editor/contrib/contextmenu/browser/contextmenu.ts b/src/vs/editor/contrib/contextmenu/browser/contextmenu.ts index df3e48c3ef7..8b131f667fb 100644 --- a/src/vs/editor/contrib/contextmenu/browser/contextmenu.ts +++ b/src/vs/editor/contrib/contextmenu/browser/contextmenu.ts @@ -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'; diff --git a/src/vs/editor/contrib/defineKeybinding/browser/defineKeybinding.ts b/src/vs/editor/contrib/defineKeybinding/browser/defineKeybinding.ts index df1cf8526dc..4f138a4cda7 100644 --- a/src/vs/editor/contrib/defineKeybinding/browser/defineKeybinding.ts +++ b/src/vs/editor/contrib/defineKeybinding/browser/defineKeybinding.ts @@ -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'; diff --git a/src/vs/editor/test/common/standalone/standaloneBase.test.ts b/src/vs/editor/test/common/standalone/standaloneBase.test.ts index 4597467d3a5..89a57135bf9 100644 --- a/src/vs/editor/test/common/standalone/standaloneBase.test.ts +++ b/src/vs/editor/test/common/standalone/standaloneBase.test.ts @@ -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', () => { diff --git a/src/vs/platform/contextview/browser/contextView.ts b/src/vs/platform/contextview/browser/contextView.ts index 5e4b770abd9..e4e72f6d4cb 100644 --- a/src/vs/platform/contextview/browser/contextView.ts +++ b/src/vs/platform/contextview/browser/contextView.ts @@ -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('contextViewService'); diff --git a/src/vs/platform/keybinding/browser/keybindingServiceImpl.ts b/src/vs/platform/keybinding/browser/keybindingServiceImpl.ts index f79d4b4220c..0abd8325f21 100644 --- a/src/vs/platform/keybinding/browser/keybindingServiceImpl.ts +++ b/src/vs/platform/keybinding/browser/keybindingServiceImpl.ts @@ -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'; diff --git a/src/vs/platform/keybinding/common/keybinding.ts b/src/vs/platform/keybinding/common/keybinding.ts index 703a470537f..7024378dde2 100644 --- a/src/vs/platform/keybinding/common/keybinding.ts +++ b/src/vs/platform/keybinding/common/keybinding.ts @@ -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'; diff --git a/src/vs/platform/keybinding/common/keybindingResolver.ts b/src/vs/platform/keybinding/common/keybindingResolver.ts index d1c777bf7b0..1b871222b4e 100644 --- a/src/vs/platform/keybinding/common/keybindingResolver.ts +++ b/src/vs/platform/keybinding/common/keybindingResolver.ts @@ -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'; diff --git a/src/vs/platform/keybinding/test/common/keybindingIO.test.ts b/src/vs/platform/keybinding/test/common/keybindingIO.test.ts index 929b000aa51..c5b3688d0f2 100644 --- a/src/vs/platform/keybinding/test/common/keybindingIO.test.ts +++ b/src/vs/platform/keybinding/test/common/keybindingIO.test.ts @@ -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', () => { diff --git a/src/vs/platform/keybinding/test/common/mockKeybindingService.ts b/src/vs/platform/keybinding/test/common/mockKeybindingService.ts index 158c4299fb2..38bd61560a9 100644 --- a/src/vs/platform/keybinding/test/common/mockKeybindingService.ts +++ b/src/vs/platform/keybinding/test/common/mockKeybindingService.ts @@ -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'; diff --git a/src/vs/workbench/parts/extensions/electron-browser/extensionEditor.ts b/src/vs/workbench/parts/extensions/electron-browser/extensionEditor.ts index ab5fab917dd..d8653df0a76 100644 --- a/src/vs/workbench/parts/extensions/electron-browser/extensionEditor.ts +++ b/src/vs/workbench/parts/extensions/electron-browser/extensionEditor.ts @@ -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'; diff --git a/src/vs/workbench/parts/files/browser/fileActions.ts b/src/vs/workbench/parts/files/browser/fileActions.ts index a49ca591ac4..489a2300676 100644 --- a/src/vs/workbench/parts/files/browser/fileActions.ts +++ b/src/vs/workbench/parts/files/browser/fileActions.ts @@ -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 { diff --git a/src/vs/workbench/parts/files/browser/views/explorerViewer.ts b/src/vs/workbench/parts/files/browser/views/explorerViewer.ts index e80253e0029..42d45b7b316 100644 --- a/src/vs/workbench/parts/files/browser/views/explorerViewer.ts +++ b/src/vs/workbench/parts/files/browser/views/explorerViewer.ts @@ -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'; diff --git a/src/vs/workbench/parts/search/browser/searchActions.ts b/src/vs/workbench/parts/search/browser/searchActions.ts index ec7c97d3bb3..00c1d95ae3a 100644 --- a/src/vs/workbench/parts/search/browser/searchActions.ts +++ b/src/vs/workbench/parts/search/browser/searchActions.ts @@ -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'; diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts index 47e7ac5cc06..551727181bf 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts @@ -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'; diff --git a/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts b/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts index dd39a79ec7b..6c3ee9ecaa8 100644 --- a/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts +++ b/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts @@ -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'; diff --git a/src/vs/workbench/services/keybinding/electron-browser/nativeKeymap.ts b/src/vs/workbench/services/keybinding/electron-browser/nativeKeymap.ts index 7a61e2e1d2f..126cf4d8ff0 100644 --- a/src/vs/workbench/services/keybinding/electron-browser/nativeKeymap.ts +++ b/src/vs/workbench/services/keybinding/electron-browser/nativeKeymap.ts @@ -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');