Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b059bd2d
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b059bd2d
编写于
3月 22, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve Inspect KeyMap data
上级
e4bc9075
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
281 addition
and
275 deletion
+281
-275
src/vs/workbench/services/keybinding/common/keybindingIO.ts
src/vs/workbench/services/keybinding/common/keybindingIO.ts
+1
-1
src/vs/workbench/services/keybinding/common/keyboardMapper.ts
...vs/workbench/services/keybinding/common/keyboardMapper.ts
+0
-1
src/vs/workbench/services/keybinding/common/macLinuxFallbackKeyboardMapper.ts
...vices/keybinding/common/macLinuxFallbackKeyboardMapper.ts
+0
-9
src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.ts
...ench/services/keybinding/common/macLinuxKeyboardMapper.ts
+14
-39
src/vs/workbench/services/keybinding/common/scanCode.ts
src/vs/workbench/services/keybinding/common/scanCode.ts
+227
-208
src/vs/workbench/services/keybinding/common/windowsKeyboardMapper.ts
...bench/services/keybinding/common/windowsKeyboardMapper.ts
+0
-6
src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts
...services/keybinding/electron-browser/keybindingService.ts
+27
-6
src/vs/workbench/services/keybinding/test/keybindingIO.test.ts
...s/workbench/services/keybinding/test/keybindingIO.test.ts
+11
-4
src/vs/workbench/services/keybinding/test/macLinuxKeyboardMapper.test.ts
...h/services/keybinding/test/macLinuxKeyboardMapper.test.ts
+1
-1
未找到文件。
src/vs/workbench/services/keybinding/common/keybindingIO.ts
浏览文件 @
b059bd2d
...
...
@@ -30,7 +30,7 @@ export class KeybindingIO {
out
.
write
(
'
}
'
);
}
public
static
readKeybindingItem
(
input
:
IUserFriendlyKeybinding
,
index
:
number
,
OS
:
OperatingSystem
):
IKeybindingItem
{
public
static
read
User
KeybindingItem
(
input
:
IUserFriendlyKeybinding
,
index
:
number
,
OS
:
OperatingSystem
):
IKeybindingItem
{
let
keybinding
:
Keybinding
=
null
;
if
(
typeof
input
.
key
===
'
string
'
)
{
keybinding
=
KeybindingIO
.
readKeybinding
(
input
.
key
,
OS
);
...
...
src/vs/workbench/services/keybinding/common/keyboardMapper.ts
浏览文件 @
b059bd2d
...
...
@@ -9,7 +9,6 @@ import { Keybinding, ResolvedKeybinding } from 'vs/base/common/keyCodes';
import
{
IKeyboardEvent
}
from
'
vs/platform/keybinding/common/keybinding
'
;
export
interface
IKeyboardMapper
{
dumpRawDebugInfo
():
string
;
dumpDebugInfo
():
string
;
resolveKeybinding
(
keybinding
:
Keybinding
):
ResolvedKeybinding
[];
resolveKeyboardEvent
(
keyboardEvent
:
IKeyboardEvent
):
ResolvedKeybinding
;
...
...
src/vs/workbench/services/keybinding/common/macLinuxFallbackKeyboardMapper.ts
浏览文件 @
b059bd2d
...
...
@@ -32,24 +32,15 @@ export interface IMacLinuxKeyboardMapping {
*/
export
class
MacLinuxFallbackKeyboardMapper
implements
IKeyboardMapper
{
/**
* used only for debug purposes.
*/
private
readonly
_rawMappings
:
IMacLinuxKeyboardMapping
;
/**
* OS (can be Linux or Macintosh)
*/
private
readonly
_OS
:
OperatingSystem
;
constructor
(
rawMappings
:
IMacLinuxKeyboardMapping
,
OS
:
OperatingSystem
)
{
this
.
_rawMappings
=
rawMappings
;
this
.
_OS
=
OS
;
}
public
dumpRawDebugInfo
():
string
{
return
JSON
.
stringify
(
this
.
_rawMappings
,
null
,
'
\t
'
);
}
public
dumpDebugInfo
():
string
{
return
'
FallbackKeyboardMapper dispatching on keyCode
'
;
}
...
...
src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.ts
浏览文件 @
b059bd2d
...
...
@@ -7,7 +7,7 @@
import
{
OperatingSystem
}
from
'
vs/base/common/platform
'
;
import
{
KeyCode
,
ResolvedKeybinding
,
KeyCodeUtils
,
SimpleKeybinding
,
Keybinding
,
KeybindingType
,
USER_SETTINGS
}
from
'
vs/base/common/keyCodes
'
;
import
{
ScanCode
,
ScanCodeUtils
,
IMMUTABLE_CODE_TO_KEY_CODE
}
from
'
vs/workbench/services/keybinding/common/scanCode
'
;
import
{
ScanCode
,
ScanCodeUtils
,
IMMUTABLE_CODE_TO_KEY_CODE
,
ScanCodeBinding
}
from
'
vs/workbench/services/keybinding/common/scanCode
'
;
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
import
{
IHTMLContentElement
}
from
'
vs/base/common/htmlContent
'
;
import
{
UILabelProvider
,
AriaLabelProvider
,
UserSettingsLabelProvider
,
ElectronAcceleratorLabelProvider
}
from
'
vs/platform/keybinding/common/keybindingLabels
'
;
...
...
@@ -73,30 +73,14 @@ function log(str: string): void {
*/
const
CHAR_CODE_TO_KEY_CODE
:
{
keyCode
:
KeyCode
;
shiftKey
:
boolean
}[]
=
[];
export
class
ScanCodePress
{
public
readonly
ctrlKey
:
boolean
;
public
readonly
shiftKey
:
boolean
;
public
readonly
altKey
:
boolean
;
public
readonly
metaKey
:
boolean
;
public
readonly
scanCode
:
ScanCode
;
constructor
(
ctrlKey
:
boolean
,
shiftKey
:
boolean
,
altKey
:
boolean
,
metaKey
:
boolean
,
scanCode
:
ScanCode
)
{
this
.
ctrlKey
=
ctrlKey
;
this
.
shiftKey
=
shiftKey
;
this
.
altKey
=
altKey
;
this
.
metaKey
=
metaKey
;
this
.
scanCode
=
scanCode
;
}
}
export
class
NativeResolvedKeybinding
extends
ResolvedKeybinding
{
private
readonly
_mapper
:
MacLinuxKeyboardMapper
;
private
readonly
_OS
:
OperatingSystem
;
private
readonly
_firstPart
:
ScanCode
Press
;
private
readonly
_chordPart
:
ScanCode
Press
;
private
readonly
_firstPart
:
ScanCode
Binding
;
private
readonly
_chordPart
:
ScanCode
Binding
;
constructor
(
mapper
:
MacLinuxKeyboardMapper
,
OS
:
OperatingSystem
,
firstPart
:
ScanCode
Press
,
chordPart
:
ScanCodePress
)
{
constructor
(
mapper
:
MacLinuxKeyboardMapper
,
OS
:
OperatingSystem
,
firstPart
:
ScanCode
Binding
,
chordPart
:
ScanCodeBinding
)
{
super
();
this
.
_mapper
=
mapper
;
this
.
_OS
=
OS
;
...
...
@@ -171,8 +155,8 @@ export class NativeResolvedKeybinding extends ResolvedKeybinding {
}
public
getDispatchParts
():
[
string
,
string
]
{
let
firstPart
=
this
.
_firstPart
?
this
.
_mapper
.
getDispatchStrForScanCode
Press
(
this
.
_firstPart
)
:
null
;
let
chordPart
=
this
.
_chordPart
?
this
.
_mapper
.
getDispatchStrForScanCode
Press
(
this
.
_chordPart
)
:
null
;
let
firstPart
=
this
.
_firstPart
?
this
.
_mapper
.
getDispatchStrForScanCode
Binding
(
this
.
_firstPart
)
:
null
;
let
chordPart
=
this
.
_chordPart
?
this
.
_mapper
.
getDispatchStrForScanCode
Binding
(
this
.
_chordPart
)
:
null
;
return
[
firstPart
,
chordPart
];
}
}
...
...
@@ -453,10 +437,6 @@ class ScanCodeKeyCodeMapper {
export
class
MacLinuxKeyboardMapper
implements
IKeyboardMapper
{
/**
* used only for debug purposes.
*/
private
readonly
_rawMappings
:
IMacLinuxKeyboardMapping
;
/**
* OS (can be Linux or Macintosh)
*/
...
...
@@ -479,7 +459,6 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
private
readonly
_scanCodeToDispatch
:
string
[]
=
[];
constructor
(
rawMappings
:
IMacLinuxKeyboardMapping
,
OS
:
OperatingSystem
)
{
this
.
_rawMappings
=
rawMappings
;
this
.
_OS
=
OS
;
this
.
_codeInfo
=
[];
this
.
_scanCodeKeyCodeMapper
=
new
ScanCodeKeyCodeMapper
();
...
...
@@ -590,10 +569,6 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
this
.
_scanCodeKeyCodeMapper
.
registrationComplete
();
}
public
dumpRawDebugInfo
():
string
{
return
JSON
.
stringify
(
this
.
_rawMappings
,
null
,
'
\t
'
);
}
public
dumpDebugInfo
():
string
{
let
result
:
string
[]
=
[];
...
...
@@ -773,15 +748,15 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
);
}
public
simpleKeybindingToScanCode
Press
(
keybinding
:
SimpleKeybinding
):
ScanCodePress
[]
{
public
simpleKeybindingToScanCode
Binding
(
keybinding
:
SimpleKeybinding
):
ScanCodeBinding
[]
{
const
scanCodeCombos
=
this
.
_scanCodeKeyCodeMapper
.
lookupKeyCodeCombo
(
new
KeyCodeCombo
(
keybinding
.
ctrlKey
,
keybinding
.
shiftKey
,
keybinding
.
altKey
,
keybinding
.
keyCode
)
);
let
result
:
ScanCode
Press
[]
=
[];
let
result
:
ScanCode
Binding
[]
=
[];
for
(
let
i
=
0
,
len
=
scanCodeCombos
.
length
;
i
<
len
;
i
++
)
{
const
scanCodeCombo
=
scanCodeCombos
[
i
];
result
[
i
]
=
new
ScanCode
Press
(
scanCodeCombo
.
ctrlKey
,
scanCodeCombo
.
shiftKey
,
scanCodeCombo
.
altKey
,
keybinding
.
metaKey
,
scanCodeCombo
.
scanCode
);
result
[
i
]
=
new
ScanCode
Binding
(
scanCodeCombo
.
ctrlKey
,
scanCodeCombo
.
shiftKey
,
scanCodeCombo
.
altKey
,
keybinding
.
metaKey
,
scanCodeCombo
.
scanCode
);
}
return
result
;
}
...
...
@@ -806,7 +781,7 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
return
this
.
_scanCodeToLabel
[
scanCode
];
}
public
getDispatchStrForScanCode
Press
(
keypress
:
ScanCodePress
):
string
{
public
getDispatchStrForScanCode
Binding
(
keypress
:
ScanCodeBinding
):
string
{
const
codeDispatch
=
this
.
_scanCodeToDispatch
[
keypress
.
scanCode
];
if
(
!
codeDispatch
)
{
return
null
;
...
...
@@ -885,8 +860,8 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
let
result
:
NativeResolvedKeybinding
[]
=
[],
resultLen
=
0
;
if
(
keybinding
.
type
===
KeybindingType
.
Chord
)
{
const
firstParts
=
this
.
simpleKeybindingToScanCode
Press
(
keybinding
.
firstPart
);
const
chordParts
=
this
.
simpleKeybindingToScanCode
Press
(
keybinding
.
chordPart
);
const
firstParts
=
this
.
simpleKeybindingToScanCode
Binding
(
keybinding
.
firstPart
);
const
chordParts
=
this
.
simpleKeybindingToScanCode
Binding
(
keybinding
.
chordPart
);
for
(
let
i
=
0
,
len
=
firstParts
.
length
;
i
<
len
;
i
++
)
{
const
firstPart
=
firstParts
[
i
];
...
...
@@ -897,7 +872,7 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
}
}
}
else
{
const
firstParts
=
this
.
simpleKeybindingToScanCode
Press
(
keybinding
);
const
firstParts
=
this
.
simpleKeybindingToScanCode
Binding
(
keybinding
);
for
(
let
i
=
0
,
len
=
firstParts
.
length
;
i
<
len
;
i
++
)
{
const
firstPart
=
firstParts
[
i
];
...
...
@@ -910,7 +885,7 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
}
public
resolveKeyboardEvent
(
keyboardEvent
:
IKeyboardEvent
):
NativeResolvedKeybinding
{
const
keypress
=
new
ScanCode
Press
(
keyboardEvent
.
ctrlKey
,
keyboardEvent
.
shiftKey
,
keyboardEvent
.
altKey
,
keyboardEvent
.
metaKey
,
ScanCodeUtils
.
toEnum
(
keyboardEvent
.
code
));
const
keypress
=
new
ScanCode
Binding
(
keyboardEvent
.
ctrlKey
,
keyboardEvent
.
shiftKey
,
keyboardEvent
.
altKey
,
keyboardEvent
.
metaKey
,
ScanCodeUtils
.
toEnum
(
keyboardEvent
.
code
));
return
new
NativeResolvedKeybinding
(
this
,
this
.
_OS
,
keypress
,
null
);
}
...
...
src/vs/workbench/services/keybinding/common/scanCode.ts
浏览文件 @
b059bd2d
...
...
@@ -7,214 +7,6 @@
import
{
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
const
scanCodeIntToStr
:
string
[]
=
[];
const
scanCodeStrToInt
:
{
[
code
:
string
]:
number
;
}
=
Object
.
create
(
null
);
export
const
ScanCodeUtils
=
{
toEnum
:
(
scanCode
:
string
)
=>
scanCodeStrToInt
[
scanCode
]
||
ScanCode
.
None
,
toString
:
(
scanCode
:
ScanCode
)
=>
scanCodeIntToStr
[
scanCode
]
||
'
None
'
};
function
d
(
intScanCode
:
ScanCode
,
strScanCode
:
string
):
void
{
scanCodeIntToStr
[
intScanCode
]
=
strScanCode
;
scanCodeStrToInt
[
strScanCode
]
=
intScanCode
;
}
(
function
()
{
d
(
ScanCode
.
None
,
'
None
'
);
d
(
ScanCode
.
Hyper
,
'
Hyper
'
);
d
(
ScanCode
.
Super
,
'
Super
'
);
d
(
ScanCode
.
Fn
,
'
Fn
'
);
d
(
ScanCode
.
FnLock
,
'
FnLock
'
);
d
(
ScanCode
.
Suspend
,
'
Suspend
'
);
d
(
ScanCode
.
Resume
,
'
Resume
'
);
d
(
ScanCode
.
Turbo
,
'
Turbo
'
);
d
(
ScanCode
.
Sleep
,
'
Sleep
'
);
d
(
ScanCode
.
WakeUp
,
'
WakeUp
'
);
d
(
ScanCode
.
KeyA
,
'
KeyA
'
);
d
(
ScanCode
.
KeyB
,
'
KeyB
'
);
d
(
ScanCode
.
KeyC
,
'
KeyC
'
);
d
(
ScanCode
.
KeyD
,
'
KeyD
'
);
d
(
ScanCode
.
KeyE
,
'
KeyE
'
);
d
(
ScanCode
.
KeyF
,
'
KeyF
'
);
d
(
ScanCode
.
KeyG
,
'
KeyG
'
);
d
(
ScanCode
.
KeyH
,
'
KeyH
'
);
d
(
ScanCode
.
KeyI
,
'
KeyI
'
);
d
(
ScanCode
.
KeyJ
,
'
KeyJ
'
);
d
(
ScanCode
.
KeyK
,
'
KeyK
'
);
d
(
ScanCode
.
KeyL
,
'
KeyL
'
);
d
(
ScanCode
.
KeyM
,
'
KeyM
'
);
d
(
ScanCode
.
KeyN
,
'
KeyN
'
);
d
(
ScanCode
.
KeyO
,
'
KeyO
'
);
d
(
ScanCode
.
KeyP
,
'
KeyP
'
);
d
(
ScanCode
.
KeyQ
,
'
KeyQ
'
);
d
(
ScanCode
.
KeyR
,
'
KeyR
'
);
d
(
ScanCode
.
KeyS
,
'
KeyS
'
);
d
(
ScanCode
.
KeyT
,
'
KeyT
'
);
d
(
ScanCode
.
KeyU
,
'
KeyU
'
);
d
(
ScanCode
.
KeyV
,
'
KeyV
'
);
d
(
ScanCode
.
KeyW
,
'
KeyW
'
);
d
(
ScanCode
.
KeyX
,
'
KeyX
'
);
d
(
ScanCode
.
KeyY
,
'
KeyY
'
);
d
(
ScanCode
.
KeyZ
,
'
KeyZ
'
);
d
(
ScanCode
.
Digit1
,
'
Digit1
'
);
d
(
ScanCode
.
Digit2
,
'
Digit2
'
);
d
(
ScanCode
.
Digit3
,
'
Digit3
'
);
d
(
ScanCode
.
Digit4
,
'
Digit4
'
);
d
(
ScanCode
.
Digit5
,
'
Digit5
'
);
d
(
ScanCode
.
Digit6
,
'
Digit6
'
);
d
(
ScanCode
.
Digit7
,
'
Digit7
'
);
d
(
ScanCode
.
Digit8
,
'
Digit8
'
);
d
(
ScanCode
.
Digit9
,
'
Digit9
'
);
d
(
ScanCode
.
Digit0
,
'
Digit0
'
);
d
(
ScanCode
.
Enter
,
'
Enter
'
);
d
(
ScanCode
.
Escape
,
'
Escape
'
);
d
(
ScanCode
.
Backspace
,
'
Backspace
'
);
d
(
ScanCode
.
Tab
,
'
Tab
'
);
d
(
ScanCode
.
Space
,
'
Space
'
);
d
(
ScanCode
.
Minus
,
'
Minus
'
);
d
(
ScanCode
.
Equal
,
'
Equal
'
);
d
(
ScanCode
.
BracketLeft
,
'
BracketLeft
'
);
d
(
ScanCode
.
BracketRight
,
'
BracketRight
'
);
d
(
ScanCode
.
Backslash
,
'
Backslash
'
);
d
(
ScanCode
.
IntlHash
,
'
IntlHash
'
);
d
(
ScanCode
.
Semicolon
,
'
Semicolon
'
);
d
(
ScanCode
.
Quote
,
'
Quote
'
);
d
(
ScanCode
.
Backquote
,
'
Backquote
'
);
d
(
ScanCode
.
Comma
,
'
Comma
'
);
d
(
ScanCode
.
Period
,
'
Period
'
);
d
(
ScanCode
.
Slash
,
'
Slash
'
);
d
(
ScanCode
.
CapsLock
,
'
CapsLock
'
);
d
(
ScanCode
.
F1
,
'
F1
'
);
d
(
ScanCode
.
F2
,
'
F2
'
);
d
(
ScanCode
.
F3
,
'
F3
'
);
d
(
ScanCode
.
F4
,
'
F4
'
);
d
(
ScanCode
.
F5
,
'
F5
'
);
d
(
ScanCode
.
F6
,
'
F6
'
);
d
(
ScanCode
.
F7
,
'
F7
'
);
d
(
ScanCode
.
F8
,
'
F8
'
);
d
(
ScanCode
.
F9
,
'
F9
'
);
d
(
ScanCode
.
F10
,
'
F10
'
);
d
(
ScanCode
.
F11
,
'
F11
'
);
d
(
ScanCode
.
F12
,
'
F12
'
);
d
(
ScanCode
.
PrintScreen
,
'
PrintScreen
'
);
d
(
ScanCode
.
ScrollLock
,
'
ScrollLock
'
);
d
(
ScanCode
.
Pause
,
'
Pause
'
);
d
(
ScanCode
.
Insert
,
'
Insert
'
);
d
(
ScanCode
.
Home
,
'
Home
'
);
d
(
ScanCode
.
PageUp
,
'
PageUp
'
);
d
(
ScanCode
.
Delete
,
'
Delete
'
);
d
(
ScanCode
.
End
,
'
End
'
);
d
(
ScanCode
.
PageDown
,
'
PageDown
'
);
d
(
ScanCode
.
ArrowRight
,
'
ArrowRight
'
);
d
(
ScanCode
.
ArrowLeft
,
'
ArrowLeft
'
);
d
(
ScanCode
.
ArrowDown
,
'
ArrowDown
'
);
d
(
ScanCode
.
ArrowUp
,
'
ArrowUp
'
);
d
(
ScanCode
.
NumLock
,
'
NumLock
'
);
d
(
ScanCode
.
NumpadDivide
,
'
NumpadDivide
'
);
d
(
ScanCode
.
NumpadMultiply
,
'
NumpadMultiply
'
);
d
(
ScanCode
.
NumpadSubtract
,
'
NumpadSubtract
'
);
d
(
ScanCode
.
NumpadAdd
,
'
NumpadAdd
'
);
d
(
ScanCode
.
NumpadEnter
,
'
NumpadEnter
'
);
d
(
ScanCode
.
Numpad1
,
'
Numpad1
'
);
d
(
ScanCode
.
Numpad2
,
'
Numpad2
'
);
d
(
ScanCode
.
Numpad3
,
'
Numpad3
'
);
d
(
ScanCode
.
Numpad4
,
'
Numpad4
'
);
d
(
ScanCode
.
Numpad5
,
'
Numpad5
'
);
d
(
ScanCode
.
Numpad6
,
'
Numpad6
'
);
d
(
ScanCode
.
Numpad7
,
'
Numpad7
'
);
d
(
ScanCode
.
Numpad8
,
'
Numpad8
'
);
d
(
ScanCode
.
Numpad9
,
'
Numpad9
'
);
d
(
ScanCode
.
Numpad0
,
'
Numpad0
'
);
d
(
ScanCode
.
NumpadDecimal
,
'
NumpadDecimal
'
);
d
(
ScanCode
.
IntlBackslash
,
'
IntlBackslash
'
);
d
(
ScanCode
.
ContextMenu
,
'
ContextMenu
'
);
d
(
ScanCode
.
Power
,
'
Power
'
);
d
(
ScanCode
.
NumpadEqual
,
'
NumpadEqual
'
);
d
(
ScanCode
.
F13
,
'
F13
'
);
d
(
ScanCode
.
F14
,
'
F14
'
);
d
(
ScanCode
.
F15
,
'
F15
'
);
d
(
ScanCode
.
F16
,
'
F16
'
);
d
(
ScanCode
.
F17
,
'
F17
'
);
d
(
ScanCode
.
F18
,
'
F18
'
);
d
(
ScanCode
.
F19
,
'
F19
'
);
d
(
ScanCode
.
F20
,
'
F20
'
);
d
(
ScanCode
.
F21
,
'
F21
'
);
d
(
ScanCode
.
F22
,
'
F22
'
);
d
(
ScanCode
.
F23
,
'
F23
'
);
d
(
ScanCode
.
F24
,
'
F24
'
);
d
(
ScanCode
.
Open
,
'
Open
'
);
d
(
ScanCode
.
Help
,
'
Help
'
);
d
(
ScanCode
.
Select
,
'
Select
'
);
d
(
ScanCode
.
Again
,
'
Again
'
);
d
(
ScanCode
.
Undo
,
'
Undo
'
);
d
(
ScanCode
.
Cut
,
'
Cut
'
);
d
(
ScanCode
.
Copy
,
'
Copy
'
);
d
(
ScanCode
.
Paste
,
'
Paste
'
);
d
(
ScanCode
.
Find
,
'
Find
'
);
d
(
ScanCode
.
AudioVolumeMute
,
'
AudioVolumeMute
'
);
d
(
ScanCode
.
AudioVolumeUp
,
'
AudioVolumeUp
'
);
d
(
ScanCode
.
AudioVolumeDown
,
'
AudioVolumeDown
'
);
d
(
ScanCode
.
NumpadComma
,
'
NumpadComma
'
);
d
(
ScanCode
.
IntlRo
,
'
IntlRo
'
);
d
(
ScanCode
.
KanaMode
,
'
KanaMode
'
);
d
(
ScanCode
.
IntlYen
,
'
IntlYen
'
);
d
(
ScanCode
.
Convert
,
'
Convert
'
);
d
(
ScanCode
.
NonConvert
,
'
NonConvert
'
);
d
(
ScanCode
.
Lang1
,
'
Lang1
'
);
d
(
ScanCode
.
Lang2
,
'
Lang2
'
);
d
(
ScanCode
.
Lang3
,
'
Lang3
'
);
d
(
ScanCode
.
Lang4
,
'
Lang4
'
);
d
(
ScanCode
.
Lang5
,
'
Lang5
'
);
d
(
ScanCode
.
Abort
,
'
Abort
'
);
d
(
ScanCode
.
Props
,
'
Props
'
);
d
(
ScanCode
.
NumpadParenLeft
,
'
NumpadParenLeft
'
);
d
(
ScanCode
.
NumpadParenRight
,
'
NumpadParenRight
'
);
d
(
ScanCode
.
NumpadBackspace
,
'
NumpadBackspace
'
);
d
(
ScanCode
.
NumpadMemoryStore
,
'
NumpadMemoryStore
'
);
d
(
ScanCode
.
NumpadMemoryRecall
,
'
NumpadMemoryRecall
'
);
d
(
ScanCode
.
NumpadMemoryClear
,
'
NumpadMemoryClear
'
);
d
(
ScanCode
.
NumpadMemoryAdd
,
'
NumpadMemoryAdd
'
);
d
(
ScanCode
.
NumpadMemorySubtract
,
'
NumpadMemorySubtract
'
);
d
(
ScanCode
.
NumpadClear
,
'
NumpadClear
'
);
d
(
ScanCode
.
NumpadClearEntry
,
'
NumpadClearEntry
'
);
d
(
ScanCode
.
ControlLeft
,
'
ControlLeft
'
);
d
(
ScanCode
.
ShiftLeft
,
'
ShiftLeft
'
);
d
(
ScanCode
.
AltLeft
,
'
AltLeft
'
);
d
(
ScanCode
.
MetaLeft
,
'
MetaLeft
'
);
d
(
ScanCode
.
ControlRight
,
'
ControlRight
'
);
d
(
ScanCode
.
ShiftRight
,
'
ShiftRight
'
);
d
(
ScanCode
.
AltRight
,
'
AltRight
'
);
d
(
ScanCode
.
MetaRight
,
'
MetaRight
'
);
d
(
ScanCode
.
BrightnessUp
,
'
BrightnessUp
'
);
d
(
ScanCode
.
BrightnessDown
,
'
BrightnessDown
'
);
d
(
ScanCode
.
MediaPlay
,
'
MediaPlay
'
);
d
(
ScanCode
.
MediaRecord
,
'
MediaRecord
'
);
d
(
ScanCode
.
MediaFastForward
,
'
MediaFastForward
'
);
d
(
ScanCode
.
MediaRewind
,
'
MediaRewind
'
);
d
(
ScanCode
.
MediaTrackNext
,
'
MediaTrackNext
'
);
d
(
ScanCode
.
MediaTrackPrevious
,
'
MediaTrackPrevious
'
);
d
(
ScanCode
.
MediaStop
,
'
MediaStop
'
);
d
(
ScanCode
.
Eject
,
'
Eject
'
);
d
(
ScanCode
.
MediaPlayPause
,
'
MediaPlayPause
'
);
d
(
ScanCode
.
MediaSelect
,
'
MediaSelect
'
);
d
(
ScanCode
.
LaunchMail
,
'
LaunchMail
'
);
d
(
ScanCode
.
LaunchApp2
,
'
LaunchApp2
'
);
d
(
ScanCode
.
LaunchApp1
,
'
LaunchApp1
'
);
d
(
ScanCode
.
SelectTask
,
'
SelectTask
'
);
d
(
ScanCode
.
LaunchScreenSaver
,
'
LaunchScreenSaver
'
);
d
(
ScanCode
.
BrowserSearch
,
'
BrowserSearch
'
);
d
(
ScanCode
.
BrowserHome
,
'
BrowserHome
'
);
d
(
ScanCode
.
BrowserBack
,
'
BrowserBack
'
);
d
(
ScanCode
.
BrowserForward
,
'
BrowserForward
'
);
d
(
ScanCode
.
BrowserStop
,
'
BrowserStop
'
);
d
(
ScanCode
.
BrowserRefresh
,
'
BrowserRefresh
'
);
d
(
ScanCode
.
BrowserFavorites
,
'
BrowserFavorites
'
);
d
(
ScanCode
.
ZoomToggle
,
'
ZoomToggle
'
);
d
(
ScanCode
.
MailReply
,
'
MailReply
'
);
d
(
ScanCode
.
MailForward
,
'
MailForward
'
);
d
(
ScanCode
.
MailSend
,
'
MailSend
'
);
})();
/**
* keyboardEvent.code
*/
...
...
@@ -417,11 +209,238 @@ export const enum ScanCode {
MAX_VALUE
}
const
scanCodeIntToStr
:
string
[]
=
[];
const
scanCodeStrToInt
:
{
[
code
:
string
]:
number
;
}
=
Object
.
create
(
null
);
const
scanCodeLowerCaseStrToInt
:
{
[
code
:
string
]:
number
;
}
=
Object
.
create
(
null
);
export
const
ScanCodeUtils
=
{
lowerCaseToEnum
:
(
scanCode
:
string
)
=>
scanCodeLowerCaseStrToInt
[
scanCode
]
||
ScanCode
.
None
,
toEnum
:
(
scanCode
:
string
)
=>
scanCodeStrToInt
[
scanCode
]
||
ScanCode
.
None
,
toString
:
(
scanCode
:
ScanCode
)
=>
scanCodeIntToStr
[
scanCode
]
||
'
None
'
};
/**
* -1 if a HwCode => KeyCode mapping depends on kb layout.
*/
export
const
IMMUTABLE_CODE_TO_KEY_CODE
:
KeyCode
[]
=
[];
export
class
ScanCodeBinding
{
public
readonly
ctrlKey
:
boolean
;
public
readonly
shiftKey
:
boolean
;
public
readonly
altKey
:
boolean
;
public
readonly
metaKey
:
boolean
;
public
readonly
scanCode
:
ScanCode
;
constructor
(
ctrlKey
:
boolean
,
shiftKey
:
boolean
,
altKey
:
boolean
,
metaKey
:
boolean
,
scanCode
:
ScanCode
)
{
this
.
ctrlKey
=
ctrlKey
;
this
.
shiftKey
=
shiftKey
;
this
.
altKey
=
altKey
;
this
.
metaKey
=
metaKey
;
this
.
scanCode
=
scanCode
;
}
}
(
function
()
{
function
d
(
intScanCode
:
ScanCode
,
strScanCode
:
string
):
void
{
scanCodeIntToStr
[
intScanCode
]
=
strScanCode
;
scanCodeStrToInt
[
strScanCode
]
=
intScanCode
;
scanCodeLowerCaseStrToInt
[
strScanCode
.
toLowerCase
()]
=
intScanCode
;
}
d
(
ScanCode
.
None
,
'
None
'
);
d
(
ScanCode
.
Hyper
,
'
Hyper
'
);
d
(
ScanCode
.
Super
,
'
Super
'
);
d
(
ScanCode
.
Fn
,
'
Fn
'
);
d
(
ScanCode
.
FnLock
,
'
FnLock
'
);
d
(
ScanCode
.
Suspend
,
'
Suspend
'
);
d
(
ScanCode
.
Resume
,
'
Resume
'
);
d
(
ScanCode
.
Turbo
,
'
Turbo
'
);
d
(
ScanCode
.
Sleep
,
'
Sleep
'
);
d
(
ScanCode
.
WakeUp
,
'
WakeUp
'
);
d
(
ScanCode
.
KeyA
,
'
KeyA
'
);
d
(
ScanCode
.
KeyB
,
'
KeyB
'
);
d
(
ScanCode
.
KeyC
,
'
KeyC
'
);
d
(
ScanCode
.
KeyD
,
'
KeyD
'
);
d
(
ScanCode
.
KeyE
,
'
KeyE
'
);
d
(
ScanCode
.
KeyF
,
'
KeyF
'
);
d
(
ScanCode
.
KeyG
,
'
KeyG
'
);
d
(
ScanCode
.
KeyH
,
'
KeyH
'
);
d
(
ScanCode
.
KeyI
,
'
KeyI
'
);
d
(
ScanCode
.
KeyJ
,
'
KeyJ
'
);
d
(
ScanCode
.
KeyK
,
'
KeyK
'
);
d
(
ScanCode
.
KeyL
,
'
KeyL
'
);
d
(
ScanCode
.
KeyM
,
'
KeyM
'
);
d
(
ScanCode
.
KeyN
,
'
KeyN
'
);
d
(
ScanCode
.
KeyO
,
'
KeyO
'
);
d
(
ScanCode
.
KeyP
,
'
KeyP
'
);
d
(
ScanCode
.
KeyQ
,
'
KeyQ
'
);
d
(
ScanCode
.
KeyR
,
'
KeyR
'
);
d
(
ScanCode
.
KeyS
,
'
KeyS
'
);
d
(
ScanCode
.
KeyT
,
'
KeyT
'
);
d
(
ScanCode
.
KeyU
,
'
KeyU
'
);
d
(
ScanCode
.
KeyV
,
'
KeyV
'
);
d
(
ScanCode
.
KeyW
,
'
KeyW
'
);
d
(
ScanCode
.
KeyX
,
'
KeyX
'
);
d
(
ScanCode
.
KeyY
,
'
KeyY
'
);
d
(
ScanCode
.
KeyZ
,
'
KeyZ
'
);
d
(
ScanCode
.
Digit1
,
'
Digit1
'
);
d
(
ScanCode
.
Digit2
,
'
Digit2
'
);
d
(
ScanCode
.
Digit3
,
'
Digit3
'
);
d
(
ScanCode
.
Digit4
,
'
Digit4
'
);
d
(
ScanCode
.
Digit5
,
'
Digit5
'
);
d
(
ScanCode
.
Digit6
,
'
Digit6
'
);
d
(
ScanCode
.
Digit7
,
'
Digit7
'
);
d
(
ScanCode
.
Digit8
,
'
Digit8
'
);
d
(
ScanCode
.
Digit9
,
'
Digit9
'
);
d
(
ScanCode
.
Digit0
,
'
Digit0
'
);
d
(
ScanCode
.
Enter
,
'
Enter
'
);
d
(
ScanCode
.
Escape
,
'
Escape
'
);
d
(
ScanCode
.
Backspace
,
'
Backspace
'
);
d
(
ScanCode
.
Tab
,
'
Tab
'
);
d
(
ScanCode
.
Space
,
'
Space
'
);
d
(
ScanCode
.
Minus
,
'
Minus
'
);
d
(
ScanCode
.
Equal
,
'
Equal
'
);
d
(
ScanCode
.
BracketLeft
,
'
BracketLeft
'
);
d
(
ScanCode
.
BracketRight
,
'
BracketRight
'
);
d
(
ScanCode
.
Backslash
,
'
Backslash
'
);
d
(
ScanCode
.
IntlHash
,
'
IntlHash
'
);
d
(
ScanCode
.
Semicolon
,
'
Semicolon
'
);
d
(
ScanCode
.
Quote
,
'
Quote
'
);
d
(
ScanCode
.
Backquote
,
'
Backquote
'
);
d
(
ScanCode
.
Comma
,
'
Comma
'
);
d
(
ScanCode
.
Period
,
'
Period
'
);
d
(
ScanCode
.
Slash
,
'
Slash
'
);
d
(
ScanCode
.
CapsLock
,
'
CapsLock
'
);
d
(
ScanCode
.
F1
,
'
F1
'
);
d
(
ScanCode
.
F2
,
'
F2
'
);
d
(
ScanCode
.
F3
,
'
F3
'
);
d
(
ScanCode
.
F4
,
'
F4
'
);
d
(
ScanCode
.
F5
,
'
F5
'
);
d
(
ScanCode
.
F6
,
'
F6
'
);
d
(
ScanCode
.
F7
,
'
F7
'
);
d
(
ScanCode
.
F8
,
'
F8
'
);
d
(
ScanCode
.
F9
,
'
F9
'
);
d
(
ScanCode
.
F10
,
'
F10
'
);
d
(
ScanCode
.
F11
,
'
F11
'
);
d
(
ScanCode
.
F12
,
'
F12
'
);
d
(
ScanCode
.
PrintScreen
,
'
PrintScreen
'
);
d
(
ScanCode
.
ScrollLock
,
'
ScrollLock
'
);
d
(
ScanCode
.
Pause
,
'
Pause
'
);
d
(
ScanCode
.
Insert
,
'
Insert
'
);
d
(
ScanCode
.
Home
,
'
Home
'
);
d
(
ScanCode
.
PageUp
,
'
PageUp
'
);
d
(
ScanCode
.
Delete
,
'
Delete
'
);
d
(
ScanCode
.
End
,
'
End
'
);
d
(
ScanCode
.
PageDown
,
'
PageDown
'
);
d
(
ScanCode
.
ArrowRight
,
'
ArrowRight
'
);
d
(
ScanCode
.
ArrowLeft
,
'
ArrowLeft
'
);
d
(
ScanCode
.
ArrowDown
,
'
ArrowDown
'
);
d
(
ScanCode
.
ArrowUp
,
'
ArrowUp
'
);
d
(
ScanCode
.
NumLock
,
'
NumLock
'
);
d
(
ScanCode
.
NumpadDivide
,
'
NumpadDivide
'
);
d
(
ScanCode
.
NumpadMultiply
,
'
NumpadMultiply
'
);
d
(
ScanCode
.
NumpadSubtract
,
'
NumpadSubtract
'
);
d
(
ScanCode
.
NumpadAdd
,
'
NumpadAdd
'
);
d
(
ScanCode
.
NumpadEnter
,
'
NumpadEnter
'
);
d
(
ScanCode
.
Numpad1
,
'
Numpad1
'
);
d
(
ScanCode
.
Numpad2
,
'
Numpad2
'
);
d
(
ScanCode
.
Numpad3
,
'
Numpad3
'
);
d
(
ScanCode
.
Numpad4
,
'
Numpad4
'
);
d
(
ScanCode
.
Numpad5
,
'
Numpad5
'
);
d
(
ScanCode
.
Numpad6
,
'
Numpad6
'
);
d
(
ScanCode
.
Numpad7
,
'
Numpad7
'
);
d
(
ScanCode
.
Numpad8
,
'
Numpad8
'
);
d
(
ScanCode
.
Numpad9
,
'
Numpad9
'
);
d
(
ScanCode
.
Numpad0
,
'
Numpad0
'
);
d
(
ScanCode
.
NumpadDecimal
,
'
NumpadDecimal
'
);
d
(
ScanCode
.
IntlBackslash
,
'
IntlBackslash
'
);
d
(
ScanCode
.
ContextMenu
,
'
ContextMenu
'
);
d
(
ScanCode
.
Power
,
'
Power
'
);
d
(
ScanCode
.
NumpadEqual
,
'
NumpadEqual
'
);
d
(
ScanCode
.
F13
,
'
F13
'
);
d
(
ScanCode
.
F14
,
'
F14
'
);
d
(
ScanCode
.
F15
,
'
F15
'
);
d
(
ScanCode
.
F16
,
'
F16
'
);
d
(
ScanCode
.
F17
,
'
F17
'
);
d
(
ScanCode
.
F18
,
'
F18
'
);
d
(
ScanCode
.
F19
,
'
F19
'
);
d
(
ScanCode
.
F20
,
'
F20
'
);
d
(
ScanCode
.
F21
,
'
F21
'
);
d
(
ScanCode
.
F22
,
'
F22
'
);
d
(
ScanCode
.
F23
,
'
F23
'
);
d
(
ScanCode
.
F24
,
'
F24
'
);
d
(
ScanCode
.
Open
,
'
Open
'
);
d
(
ScanCode
.
Help
,
'
Help
'
);
d
(
ScanCode
.
Select
,
'
Select
'
);
d
(
ScanCode
.
Again
,
'
Again
'
);
d
(
ScanCode
.
Undo
,
'
Undo
'
);
d
(
ScanCode
.
Cut
,
'
Cut
'
);
d
(
ScanCode
.
Copy
,
'
Copy
'
);
d
(
ScanCode
.
Paste
,
'
Paste
'
);
d
(
ScanCode
.
Find
,
'
Find
'
);
d
(
ScanCode
.
AudioVolumeMute
,
'
AudioVolumeMute
'
);
d
(
ScanCode
.
AudioVolumeUp
,
'
AudioVolumeUp
'
);
d
(
ScanCode
.
AudioVolumeDown
,
'
AudioVolumeDown
'
);
d
(
ScanCode
.
NumpadComma
,
'
NumpadComma
'
);
d
(
ScanCode
.
IntlRo
,
'
IntlRo
'
);
d
(
ScanCode
.
KanaMode
,
'
KanaMode
'
);
d
(
ScanCode
.
IntlYen
,
'
IntlYen
'
);
d
(
ScanCode
.
Convert
,
'
Convert
'
);
d
(
ScanCode
.
NonConvert
,
'
NonConvert
'
);
d
(
ScanCode
.
Lang1
,
'
Lang1
'
);
d
(
ScanCode
.
Lang2
,
'
Lang2
'
);
d
(
ScanCode
.
Lang3
,
'
Lang3
'
);
d
(
ScanCode
.
Lang4
,
'
Lang4
'
);
d
(
ScanCode
.
Lang5
,
'
Lang5
'
);
d
(
ScanCode
.
Abort
,
'
Abort
'
);
d
(
ScanCode
.
Props
,
'
Props
'
);
d
(
ScanCode
.
NumpadParenLeft
,
'
NumpadParenLeft
'
);
d
(
ScanCode
.
NumpadParenRight
,
'
NumpadParenRight
'
);
d
(
ScanCode
.
NumpadBackspace
,
'
NumpadBackspace
'
);
d
(
ScanCode
.
NumpadMemoryStore
,
'
NumpadMemoryStore
'
);
d
(
ScanCode
.
NumpadMemoryRecall
,
'
NumpadMemoryRecall
'
);
d
(
ScanCode
.
NumpadMemoryClear
,
'
NumpadMemoryClear
'
);
d
(
ScanCode
.
NumpadMemoryAdd
,
'
NumpadMemoryAdd
'
);
d
(
ScanCode
.
NumpadMemorySubtract
,
'
NumpadMemorySubtract
'
);
d
(
ScanCode
.
NumpadClear
,
'
NumpadClear
'
);
d
(
ScanCode
.
NumpadClearEntry
,
'
NumpadClearEntry
'
);
d
(
ScanCode
.
ControlLeft
,
'
ControlLeft
'
);
d
(
ScanCode
.
ShiftLeft
,
'
ShiftLeft
'
);
d
(
ScanCode
.
AltLeft
,
'
AltLeft
'
);
d
(
ScanCode
.
MetaLeft
,
'
MetaLeft
'
);
d
(
ScanCode
.
ControlRight
,
'
ControlRight
'
);
d
(
ScanCode
.
ShiftRight
,
'
ShiftRight
'
);
d
(
ScanCode
.
AltRight
,
'
AltRight
'
);
d
(
ScanCode
.
MetaRight
,
'
MetaRight
'
);
d
(
ScanCode
.
BrightnessUp
,
'
BrightnessUp
'
);
d
(
ScanCode
.
BrightnessDown
,
'
BrightnessDown
'
);
d
(
ScanCode
.
MediaPlay
,
'
MediaPlay
'
);
d
(
ScanCode
.
MediaRecord
,
'
MediaRecord
'
);
d
(
ScanCode
.
MediaFastForward
,
'
MediaFastForward
'
);
d
(
ScanCode
.
MediaRewind
,
'
MediaRewind
'
);
d
(
ScanCode
.
MediaTrackNext
,
'
MediaTrackNext
'
);
d
(
ScanCode
.
MediaTrackPrevious
,
'
MediaTrackPrevious
'
);
d
(
ScanCode
.
MediaStop
,
'
MediaStop
'
);
d
(
ScanCode
.
Eject
,
'
Eject
'
);
d
(
ScanCode
.
MediaPlayPause
,
'
MediaPlayPause
'
);
d
(
ScanCode
.
MediaSelect
,
'
MediaSelect
'
);
d
(
ScanCode
.
LaunchMail
,
'
LaunchMail
'
);
d
(
ScanCode
.
LaunchApp2
,
'
LaunchApp2
'
);
d
(
ScanCode
.
LaunchApp1
,
'
LaunchApp1
'
);
d
(
ScanCode
.
SelectTask
,
'
SelectTask
'
);
d
(
ScanCode
.
LaunchScreenSaver
,
'
LaunchScreenSaver
'
);
d
(
ScanCode
.
BrowserSearch
,
'
BrowserSearch
'
);
d
(
ScanCode
.
BrowserHome
,
'
BrowserHome
'
);
d
(
ScanCode
.
BrowserBack
,
'
BrowserBack
'
);
d
(
ScanCode
.
BrowserForward
,
'
BrowserForward
'
);
d
(
ScanCode
.
BrowserStop
,
'
BrowserStop
'
);
d
(
ScanCode
.
BrowserRefresh
,
'
BrowserRefresh
'
);
d
(
ScanCode
.
BrowserFavorites
,
'
BrowserFavorites
'
);
d
(
ScanCode
.
ZoomToggle
,
'
ZoomToggle
'
);
d
(
ScanCode
.
MailReply
,
'
MailReply
'
);
d
(
ScanCode
.
MailForward
,
'
MailForward
'
);
d
(
ScanCode
.
MailSend
,
'
MailSend
'
);
})();
(
function
()
{
for
(
let
i
=
0
;
i
<=
ScanCode
.
MAX_VALUE
;
i
++
)
{
IMMUTABLE_CODE_TO_KEY_CODE
[
i
]
=
-
1
;
...
...
src/vs/workbench/services/keybinding/common/windowsKeyboardMapper.ts
浏览文件 @
b059bd2d
...
...
@@ -212,14 +212,12 @@ export class WindowsNativeResolvedKeybinding extends ResolvedKeybinding {
export
class
WindowsKeyboardMapper
implements
IKeyboardMapper
{
private
readonly
_rawMappings
:
IWindowsKeyboardMapping
;
private
readonly
_codeInfo
:
IHardwareCodeMapping
[];
private
readonly
_hwToKb
:
KeyCode
[];
private
readonly
_kbToLabel
:
string
[]
=
[];
private
readonly
_kbExists
:
boolean
[];
constructor
(
rawMappings
:
IWindowsKeyboardMapping
)
{
this
.
_rawMappings
=
rawMappings
;
this
.
_hwToKb
=
[];
this
.
_kbToLabel
=
[];
this
.
_kbExists
=
[];
...
...
@@ -278,10 +276,6 @@ export class WindowsKeyboardMapper implements IKeyboardMapper {
}
}
public
dumpRawDebugInfo
():
string
{
return
JSON
.
stringify
(
this
.
_rawMappings
,
null
,
'
\t
'
);
}
public
dumpDebugInfo
():
string
{
let
result
:
string
[]
=
[];
...
...
src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts
浏览文件 @
b059bd2d
...
...
@@ -41,6 +41,7 @@ export class KeyboardMapperFactory {
private
_layoutInfo
:
nativeKeymap
.
IKeyboardLayoutInfo
;
private
_rawMapping
:
nativeKeymap
.
IKeyboardMapping
;
private
_keyboardMapper
:
IKeyboardMapper
;
private
_initialized
:
boolean
;
private
_onDidChangeKeyboardMapper
:
Emitter
<
void
>
=
new
Emitter
<
void
>
();
public
onDidChangeKeyboardMapper
:
Event
<
void
>
=
this
.
_onDidChangeKeyboardMapper
.
event
;
...
...
@@ -49,29 +50,46 @@ export class KeyboardMapperFactory {
this
.
_layoutInfo
=
null
;
this
.
_rawMapping
=
null
;
this
.
_keyboardMapper
=
null
;
this
.
_initialized
=
false
;
}
public
_onKeyboardLayoutChanged
():
void
{
if
(
this
.
_
keyboardMapper
)
{
if
(
this
.
_
initialized
)
{
this
.
_setKeyboardData
(
nativeKeymap
.
getCurrentKeyboardLayout
(),
nativeKeymap
.
getKeyMap
());
}
}
public
getKeyboardMapper
():
IKeyboardMapper
{
if
(
!
this
.
_
keyboardMapper
)
{
if
(
!
this
.
_
initialized
)
{
this
.
_setKeyboardData
(
nativeKeymap
.
getCurrentKeyboardLayout
(),
nativeKeymap
.
getKeyMap
());
}
return
this
.
_keyboardMapper
;
}
public
getCurrentKeyboardLayout
():
nativeKeymap
.
IKeyboardLayoutInfo
{
if
(
!
this
.
_initialized
)
{
this
.
_setKeyboardData
(
nativeKeymap
.
getCurrentKeyboardLayout
(),
nativeKeymap
.
getKeyMap
());
}
return
this
.
_layoutInfo
;
}
public
getRawKeyboardMapping
():
nativeKeymap
.
IKeyboardMapping
{
if
(
!
this
.
_initialized
)
{
this
.
_setKeyboardData
(
nativeKeymap
.
getCurrentKeyboardLayout
(),
nativeKeymap
.
getKeyMap
());
}
return
this
.
_rawMapping
;
}
private
_setKeyboardData
(
layoutInfo
:
nativeKeymap
.
IKeyboardLayoutInfo
,
rawMapping
:
nativeKeymap
.
IKeyboardMapping
):
void
{
this
.
_layoutInfo
=
layoutInfo
;
if
(
this
.
_
keyboardMapper
&&
KeyboardMapperFactory
.
_equals
(
this
.
_rawMapping
,
rawMapping
))
{
if
(
this
.
_
initialized
&&
KeyboardMapperFactory
.
_equals
(
this
.
_rawMapping
,
rawMapping
))
{
// nothing to do...
return
;
}
this
.
_initialized
=
true
;
this
.
_rawMapping
=
rawMapping
;
this
.
_keyboardMapper
=
KeyboardMapperFactory
.
_createKeyboardMapper
(
this
.
_rawMapping
);
this
.
_onDidChangeKeyboardMapper
.
fire
();
...
...
@@ -241,14 +259,17 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
}));
keybindingsTelemetry
(
telemetryService
,
this
);
let
data
=
nativeKeymap
.
getCurrentKeyboardLayout
();
let
data
=
KeyboardMapperFactory
.
INSTANCE
.
getCurrentKeyboardLayout
();
telemetryService
.
publicLog
(
'
keyboardLayout
'
,
{
currentKeyboardLayout
:
data
});
}
public
dumpDebugInfo
():
string
{
return
this
.
_keyboardMapper
.
dumpDebugInfo
()
+
`\n\n\nraw info: \n`
+
this
.
_keyboardMapper
.
dumpRawDebugInfo
();
const
layoutInfo
=
JSON
.
stringify
(
KeyboardMapperFactory
.
INSTANCE
.
getCurrentKeyboardLayout
(),
null
,
'
\t
'
);
const
mapperInfo
=
this
.
_keyboardMapper
.
dumpDebugInfo
();
const
rawMapping
=
JSON
.
stringify
(
KeyboardMapperFactory
.
INSTANCE
.
getRawKeyboardMapping
(),
null
,
'
\t
'
);
return
`Layout info:\n
${
layoutInfo
}
\n
${
mapperInfo
}
\n\nRaw mapping:\n
${
rawMapping
}
`
;
}
private
_safeGetConfig
():
IUserFriendlyKeybinding
[]
{
...
...
@@ -310,7 +331,7 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
});
}
return
extraUserKeybindings
.
map
((
k
,
i
)
=>
KeybindingIO
.
readKeybindingItem
(
k
,
i
,
OS
));
return
extraUserKeybindings
.
map
((
k
,
i
)
=>
KeybindingIO
.
read
User
KeybindingItem
(
k
,
i
,
OS
));
}
public
resolveKeybinding
(
kb
:
Keybinding
):
ResolvedKeybinding
[]
{
...
...
src/vs/workbench/services/keybinding/test/keybindingIO.test.ts
浏览文件 @
b059bd2d
...
...
@@ -156,28 +156,35 @@ suite('keybindingIO', () => {
test
(
'
issue #10452 - invalid command
'
,
()
=>
{
let
strJSON
=
`[{ "key": "ctrl+k ctrl+f", "command": ["firstcommand", "seccondcommand"] }]`
;
let
userKeybinding
=
<
IUserFriendlyKeybinding
>
JSON
.
parse
(
strJSON
)[
0
];
let
keybindingItem
=
KeybindingIO
.
readKeybindingItem
(
userKeybinding
,
0
,
OS
);
let
keybindingItem
=
KeybindingIO
.
read
User
KeybindingItem
(
userKeybinding
,
0
,
OS
);
assert
.
equal
(
keybindingItem
.
command
,
null
);
});
test
(
'
issue #10452 - invalid when
'
,
()
=>
{
let
strJSON
=
`[{ "key": "ctrl+k ctrl+f", "command": "firstcommand", "when": [] }]`
;
let
userKeybinding
=
<
IUserFriendlyKeybinding
>
JSON
.
parse
(
strJSON
)[
0
];
let
keybindingItem
=
KeybindingIO
.
readKeybindingItem
(
userKeybinding
,
0
,
OS
);
let
keybindingItem
=
KeybindingIO
.
read
User
KeybindingItem
(
userKeybinding
,
0
,
OS
);
assert
.
equal
(
keybindingItem
.
when
,
null
);
});
test
(
'
issue #10452 - invalid key
'
,
()
=>
{
let
strJSON
=
`[{ "key": [], "command": "firstcommand" }]`
;
let
userKeybinding
=
<
IUserFriendlyKeybinding
>
JSON
.
parse
(
strJSON
)[
0
];
let
keybindingItem
=
KeybindingIO
.
readKeybindingItem
(
userKeybinding
,
0
,
OS
);
let
keybindingItem
=
KeybindingIO
.
readUserKeybindingItem
(
userKeybinding
,
0
,
OS
);
assert
.
equal
(
keybindingItem
.
keybinding
,
null
);
});
test
(
'
issue #10452 - invalid key 2
'
,
()
=>
{
let
strJSON
=
`[{ "key": "", "command": "firstcommand" }]`
;
let
userKeybinding
=
<
IUserFriendlyKeybinding
>
JSON
.
parse
(
strJSON
)[
0
];
let
keybindingItem
=
KeybindingIO
.
readUserKeybindingItem
(
userKeybinding
,
0
,
OS
);
assert
.
equal
(
keybindingItem
.
keybinding
,
null
);
});
test
(
'
test commands args
'
,
()
=>
{
let
strJSON
=
`[{ "key": "ctrl+k ctrl+f", "command": "firstcommand", "when": [], "args": { "text": "theText" } }]`
;
let
userKeybinding
=
<
IUserFriendlyKeybinding
>
JSON
.
parse
(
strJSON
)[
0
];
let
keybindingItem
=
KeybindingIO
.
readKeybindingItem
(
userKeybinding
,
0
,
OS
);
let
keybindingItem
=
KeybindingIO
.
read
User
KeybindingItem
(
userKeybinding
,
0
,
OS
);
assert
.
equal
(
keybindingItem
.
commandArgs
.
text
,
'
theText
'
);
});
});
src/vs/workbench/services/keybinding/test/macLinuxKeyboardMapper.test.ts
浏览文件 @
b059bd2d
...
...
@@ -1111,7 +1111,7 @@ function _assertKeybindingTranslation(mapper: MacLinuxKeyboardMapper, OS: Operat
const
keybindingLabel
=
new
USLayoutResolvedKeybinding
(
runtimeKeybinding
,
OS
).
getUserSettingsLabel
();
const
actualHardwareKeypresses
=
mapper
.
simpleKeybindingToScanCode
Press
(
<
SimpleKeybinding
>
runtimeKeybinding
);
const
actualHardwareKeypresses
=
mapper
.
simpleKeybindingToScanCode
Binding
(
<
SimpleKeybinding
>
runtimeKeybinding
);
if
(
actualHardwareKeypresses
.
length
===
0
)
{
assert
.
deepEqual
([],
expected
,
`simpleKeybindingToHardwareKeypress -- "
${
keybindingLabel
}
" -- actual: "[]" -- expected: "
${
expected
}
"`
);
return
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录