Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
ad209fbf
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ad209fbf
编写于
2月 15, 2019
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Introduce BaseResolvedKeybinding
上级
871a6fef
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
118 addition
and
209 deletion
+118
-209
src/vs/base/common/keyCodes.ts
src/vs/base/common/keyCodes.ts
+75
-4
src/vs/platform/keybinding/common/usLayoutResolvedKeybinding.ts
.../platform/keybinding/common/usLayoutResolvedKeybinding.ts
+13
-75
src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.ts
...ench/services/keybinding/common/macLinuxKeyboardMapper.ts
+15
-51
src/vs/workbench/services/keybinding/common/windowsKeyboardMapper.ts
...bench/services/keybinding/common/windowsKeyboardMapper.ts
+15
-79
未找到文件。
src/vs/base/common/keyCodes.ts
浏览文件 @
ad209fbf
...
...
@@ -5,6 +5,7 @@
import
{
OperatingSystem
}
from
'
vs/base/common/platform
'
;
import
{
illegalArgument
}
from
'
vs/base/common/errors
'
;
import
{
Modifiers
,
UILabelProvider
,
AriaLabelProvider
,
ElectronAcceleratorLabelProvider
,
UserSettingsLabelProvider
}
from
'
vs/base/common/keybindingLabels
'
;
/**
* Virtual Key Codes, the value does not hold any inherent meaning.
...
...
@@ -589,13 +590,83 @@ export abstract class ResolvedKeybinding {
*/
public
abstract
isChord
():
boolean
;
/**
* Returns the parts that should be used for dispatching.
*/
public
abstract
getDispatchParts
():
(
string
|
null
)[];
/**
* Returns the parts that comprise of the keybinding.
* Simple keybindings return one element.
*/
public
abstract
getParts
():
ResolvedKeybindingPart
[];
/**
* Returns the parts that should be used for dispatching.
*/
public
abstract
getDispatchParts
():
(
string
|
null
)[];
}
export
abstract
class
BaseResolvedKeybinding
<
T
extends
Modifiers
>
extends
ResolvedKeybinding
{
protected
readonly
_os
:
OperatingSystem
;
protected
readonly
_parts
:
T
[];
constructor
(
os
:
OperatingSystem
,
parts
:
T
[])
{
super
();
if
(
parts
.
length
===
0
)
{
throw
illegalArgument
(
`parts`
);
}
this
.
_os
=
os
;
this
.
_parts
=
parts
;
}
public
getLabel
():
string
|
null
{
return
UILabelProvider
.
toLabel
(
this
.
_os
,
this
.
_parts
,
(
keybinding
)
=>
this
.
_getLabel
(
keybinding
));
}
public
getAriaLabel
():
string
|
null
{
return
AriaLabelProvider
.
toLabel
(
this
.
_os
,
this
.
_parts
,
(
keybinding
)
=>
this
.
_getAriaLabel
(
keybinding
));
}
public
getElectronAccelerator
():
string
|
null
{
if
(
this
.
_parts
.
length
>
1
)
{
// Electron cannot handle chords
return
null
;
}
return
ElectronAcceleratorLabelProvider
.
toLabel
(
this
.
_os
,
this
.
_parts
,
(
keybinding
)
=>
this
.
_getElectronAccelerator
(
keybinding
));
}
public
getUserSettingsLabel
():
string
|
null
{
return
UserSettingsLabelProvider
.
toLabel
(
this
.
_os
,
this
.
_parts
,
(
keybinding
)
=>
this
.
_getUserSettingsLabel
(
keybinding
));
}
public
isWYSIWYG
():
boolean
{
return
this
.
_parts
.
every
((
keybinding
)
=>
this
.
_isWYSIWYG
(
keybinding
));
}
public
isChord
():
boolean
{
return
(
this
.
_parts
.
length
>
1
);
}
public
getParts
():
ResolvedKeybindingPart
[]
{
return
this
.
_parts
.
map
((
keybinding
)
=>
this
.
_getPart
(
keybinding
));
}
private
_getPart
(
keybinding
:
T
):
ResolvedKeybindingPart
{
return
new
ResolvedKeybindingPart
(
keybinding
.
ctrlKey
,
keybinding
.
shiftKey
,
keybinding
.
altKey
,
keybinding
.
metaKey
,
this
.
_getLabel
(
keybinding
),
this
.
_getAriaLabel
(
keybinding
)
);
}
public
getDispatchParts
():
(
string
|
null
)[]
{
return
this
.
_parts
.
map
((
keybinding
)
=>
this
.
_getDispatchPart
(
keybinding
));
}
protected
abstract
_getLabel
(
keybinding
:
T
):
string
|
null
;
protected
abstract
_getAriaLabel
(
keybinding
:
T
):
string
|
null
;
protected
abstract
_getElectronAccelerator
(
keybinding
:
T
):
string
|
null
;
protected
abstract
_getUserSettingsLabel
(
keybinding
:
T
):
string
|
null
;
protected
abstract
_isWYSIWYG
(
keybinding
:
T
):
boolean
;
protected
abstract
_getDispatchPart
(
keybinding
:
T
):
string
|
null
;
}
src/vs/platform/keybinding/common/usLayoutResolvedKeybinding.ts
浏览文件 @
ad209fbf
...
...
@@ -3,26 +3,16 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
KeyCode
,
KeyCodeUtils
,
Keybinding
,
ResolvedKeybinding
,
ResolvedKeybindingPart
,
SimpleKeybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
AriaLabelProvider
,
ElectronAcceleratorLabelProvider
,
UILabelProvider
,
UserSettingsLabelProvider
}
from
'
vs/base/common/keybindingLabels
'
;
import
{
KeyCode
,
KeyCodeUtils
,
Keybinding
,
SimpleKeybinding
,
BaseResolvedKeybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
OperatingSystem
}
from
'
vs/base/common/platform
'
;
/**
* Do not instantiate. Use KeybindingService to get a ResolvedKeybinding seeded with information about the current kb layout.
*/
export
class
USLayoutResolvedKeybinding
extends
ResolvedKeybinding
{
private
readonly
_os
:
OperatingSystem
;
private
readonly
_parts
:
SimpleKeybinding
[];
constructor
(
actual
:
Keybinding
,
OS
:
OperatingSystem
)
{
super
();
this
.
_os
=
OS
;
if
(
!
actual
)
{
throw
new
Error
(
`Invalid USLayoutResolvedKeybinding`
);
}
else
{
this
.
_parts
=
actual
.
parts
;
}
export
class
USLayoutResolvedKeybinding
extends
BaseResolvedKeybinding
<
SimpleKeybinding
>
{
constructor
(
actual
:
Keybinding
,
os
:
OperatingSystem
)
{
super
(
os
,
actual
.
parts
);
}
private
_keyCodeToUILabel
(
keyCode
:
KeyCode
):
string
{
...
...
@@ -41,34 +31,20 @@ export class USLayoutResolvedKeybinding extends ResolvedKeybinding {
return
KeyCodeUtils
.
toString
(
keyCode
);
}
private
_getUILabelForKeybinding
(
keybinding
:
SimpleKeybinding
|
null
):
string
|
null
{
if
(
!
keybinding
)
{
return
null
;
}
protected
_getLabel
(
keybinding
:
SimpleKeybinding
):
string
|
null
{
if
(
keybinding
.
isDuplicateModifierCase
())
{
return
''
;
}
return
this
.
_keyCodeToUILabel
(
keybinding
.
keyCode
);
}
public
getLabel
():
string
|
null
{
return
UILabelProvider
.
toLabel
(
this
.
_os
,
this
.
_parts
,
(
keybinding
)
=>
this
.
_getUILabelForKeybinding
(
keybinding
));
}
private
_getAriaLabelForKeybinding
(
keybinding
:
SimpleKeybinding
|
null
):
string
|
null
{
if
(
!
keybinding
)
{
return
null
;
}
protected
_getAriaLabel
(
keybinding
:
SimpleKeybinding
):
string
|
null
{
if
(
keybinding
.
isDuplicateModifierCase
())
{
return
''
;
}
return
KeyCodeUtils
.
toString
(
keybinding
.
keyCode
);
}
public
getAriaLabel
():
string
|
null
{
return
AriaLabelProvider
.
toLabel
(
this
.
_os
,
this
.
_parts
,
(
keybinding
)
=>
this
.
_getAriaLabelForKeybinding
(
keybinding
));
}
private
_keyCodeToElectronAccelerator
(
keyCode
:
KeyCode
):
string
|
null
{
if
(
keyCode
>=
KeyCode
.
NUMPAD_0
&&
keyCode
<=
KeyCode
.
NUMPAD_DIVIDE
)
{
// Electron cannot handle numpad keys
...
...
@@ -89,65 +65,27 @@ export class USLayoutResolvedKeybinding extends ResolvedKeybinding {
return
KeyCodeUtils
.
toString
(
keyCode
);
}
private
_getElectronAcceleratorLabelForKeybinding
(
keybinding
:
SimpleKeybinding
|
null
):
string
|
null
{
if
(
!
keybinding
)
{
return
null
;
}
protected
_getElectronAccelerator
(
keybinding
:
SimpleKeybinding
):
string
|
null
{
if
(
keybinding
.
isDuplicateModifierCase
())
{
return
null
;
}
return
this
.
_keyCodeToElectronAccelerator
(
keybinding
.
keyCode
);
}
public
getElectronAccelerator
():
string
|
null
{
if
(
this
.
_parts
.
length
>
1
)
{
// Electron cannot handle chords
return
null
;
}
return
ElectronAcceleratorLabelProvider
.
toLabel
(
this
.
_os
,
this
.
_parts
,
(
keybinding
)
=>
this
.
_getElectronAcceleratorLabelForKeybinding
(
keybinding
));
}
private
_getUserSettingsLabelForKeybinding
(
keybinding
:
SimpleKeybinding
|
null
):
string
|
null
{
if
(
!
keybinding
)
{
return
null
;
}
protected
_getUserSettingsLabel
(
keybinding
:
SimpleKeybinding
):
string
|
null
{
if
(
keybinding
.
isDuplicateModifierCase
())
{
return
''
;
}
return
KeyCodeUtils
.
toUserSettingsUS
(
keybinding
.
keyCode
);
}
public
getUserSettingsLabel
():
string
|
null
{
const
result
=
UserSettingsLabelProvider
.
toLabel
(
this
.
_os
,
this
.
_parts
,
(
keybinding
)
=>
this
.
_getUserSettingsLabelForKeybinding
(
keybinding
));
const
result
=
KeyCodeUtils
.
toUserSettingsUS
(
keybinding
.
keyCode
);
return
(
result
?
result
.
toLowerCase
()
:
result
);
}
p
ublic
isWYSIWYG
():
boolean
{
p
rotected
_
isWYSIWYG
():
boolean
{
return
true
;
}
public
isChord
():
boolean
{
return
(
this
.
_parts
.
length
>
1
);
}
public
getParts
():
ResolvedKeybindingPart
[]
{
return
this
.
_parts
.
map
((
keybinding
)
=>
this
.
_toResolvedKeybindingPart
(
keybinding
));
}
private
_toResolvedKeybindingPart
(
keybinding
:
SimpleKeybinding
):
ResolvedKeybindingPart
{
return
new
ResolvedKeybindingPart
(
keybinding
.
ctrlKey
,
keybinding
.
shiftKey
,
keybinding
.
altKey
,
keybinding
.
metaKey
,
this
.
_getUILabelForKeybinding
(
keybinding
),
this
.
_getAriaLabelForKeybinding
(
keybinding
)
);
}
public
getDispatchParts
():
(
string
|
null
)[]
{
return
this
.
_parts
.
map
((
keybinding
)
=>
USLayoutResolvedKeybinding
.
getDispatchStr
(
keybinding
));
protected
_getDispatchPart
(
keybinding
:
SimpleKeybinding
):
string
|
null
{
return
USLayoutResolvedKeybinding
.
getDispatchStr
(
keybinding
);
}
public
static
getDispatchStr
(
keybinding
:
SimpleKeybinding
):
string
|
null
{
...
...
src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.ts
浏览文件 @
ad209fbf
...
...
@@ -4,8 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
import
{
KeyCode
,
KeyCodeUtils
,
Keybinding
,
ResolvedKeybinding
,
ResolvedKeybindingPart
,
SimpleKeybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
AriaLabelProvider
,
ElectronAcceleratorLabelProvider
,
UILabelProvider
,
UserSettingsLabelProvider
}
from
'
vs/base/common/keybindingLabels
'
;
import
{
KeyCode
,
KeyCodeUtils
,
Keybinding
,
ResolvedKeybinding
,
SimpleKeybinding
,
BaseResolvedKeybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
OperatingSystem
}
from
'
vs/base/common/platform
'
;
import
{
IMMUTABLE_CODE_TO_KEY_CODE
,
IMMUTABLE_KEY_CODE_TO_CODE
,
ScanCode
,
ScanCodeBinding
,
ScanCodeUtils
}
from
'
vs/base/common/scanCode
'
;
import
{
IKeyboardEvent
}
from
'
vs/platform/keybinding/common/keybinding
'
;
...
...
@@ -63,44 +62,32 @@ export function macLinuxKeyboardMappingEquals(a: IMacLinuxKeyboardMapping | null
*/
const
CHAR_CODE_TO_KEY_CODE
:
({
keyCode
:
KeyCode
;
shiftKey
:
boolean
}
|
null
)[]
=
[];
export
class
NativeResolvedKeybinding
extends
ResolvedKeybinding
{
export
class
NativeResolvedKeybinding
extends
BaseResolvedKeybinding
<
ScanCodeBinding
>
{
private
readonly
_mapper
:
MacLinuxKeyboardMapper
;
private
readonly
_OS
:
OperatingSystem
;
private
readonly
_parts
:
ScanCodeBinding
[];
constructor
(
mapper
:
MacLinuxKeyboardMapper
,
OS
:
OperatingSystem
,
parts
:
ScanCodeBinding
[])
{
super
();
if
(
parts
.
length
===
0
)
{
throw
new
Error
(
`Invalid NativeResolvedKeybinding`
);
}
constructor
(
mapper
:
MacLinuxKeyboardMapper
,
os
:
OperatingSystem
,
parts
:
ScanCodeBinding
[])
{
super
(
os
,
parts
);
this
.
_mapper
=
mapper
;
this
.
_OS
=
OS
;
this
.
_parts
=
parts
;
}
p
ublic
getLabel
(
):
string
|
null
{
return
UILabelProvider
.
toLabel
(
this
.
_OS
,
this
.
_parts
,
(
keybinding
)
=>
this
.
_mapper
.
getUILabelForScanCodeBinding
(
keybinding
)
);
p
rotected
_getLabel
(
keybinding
:
ScanCodeBinding
):
string
|
null
{
return
this
.
_mapper
.
getUILabelForScanCodeBinding
(
keybinding
);
}
p
ublic
getAriaLabel
(
):
string
|
null
{
return
AriaLabelProvider
.
toLabel
(
this
.
_OS
,
this
.
_parts
,
(
keybinding
)
=>
this
.
_mapper
.
getAriaLabelForScanCodeBinding
(
keybinding
)
);
p
rotected
_getAriaLabel
(
keybinding
:
ScanCodeBinding
):
string
|
null
{
return
this
.
_mapper
.
getAriaLabelForScanCodeBinding
(
keybinding
);
}
public
getElectronAccelerator
():
string
|
null
{
if
(
this
.
_parts
.
length
>
1
)
{
// Electron cannot handle chords
return
null
;
}
return
ElectronAcceleratorLabelProvider
.
toLabel
(
this
.
_OS
,
this
.
_parts
,
(
keybinding
)
=>
this
.
_mapper
.
getElectronAcceleratorLabelForScanCodeBinding
(
keybinding
));
protected
_getElectronAccelerator
(
keybinding
:
ScanCodeBinding
):
string
|
null
{
return
this
.
_mapper
.
getElectronAcceleratorLabelForScanCodeBinding
(
keybinding
);
}
p
ublic
getUserSettingsLabel
(
):
string
|
null
{
return
UserSettingsLabelProvider
.
toLabel
(
this
.
_OS
,
this
.
_parts
,
(
keybinding
)
=>
this
.
_mapper
.
getUserSettingsLabelForScanCodeBinding
(
keybinding
)
);
p
rotected
_getUserSettingsLabel
(
keybinding
:
ScanCodeBinding
):
string
|
null
{
return
this
.
_mapper
.
getUserSettingsLabelForScanCodeBinding
(
keybinding
);
}
pr
ivate
_isWYSIWYG
(
binding
:
ScanCodeBinding
|
null
):
boolean
{
pr
otected
_isWYSIWYG
(
binding
:
ScanCodeBinding
|
null
):
boolean
{
if
(
!
binding
)
{
return
true
;
}
...
...
@@ -119,31 +106,8 @@ export class NativeResolvedKeybinding extends ResolvedKeybinding {
return
(
a
.
toLowerCase
()
===
b
.
toLowerCase
());
}
public
isWYSIWYG
():
boolean
{
return
this
.
_parts
.
every
((
keybinding
)
=>
this
.
_isWYSIWYG
(
keybinding
));
}
public
isChord
():
boolean
{
return
(
this
.
_parts
.
length
>
1
);
}
public
getParts
():
ResolvedKeybindingPart
[]
{
return
this
.
_parts
.
map
((
keybinding
)
=>
this
.
_toResolvedKeybindingPart
(
keybinding
));
}
private
_toResolvedKeybindingPart
(
binding
:
ScanCodeBinding
):
ResolvedKeybindingPart
{
return
new
ResolvedKeybindingPart
(
binding
.
ctrlKey
,
binding
.
shiftKey
,
binding
.
altKey
,
binding
.
metaKey
,
this
.
_mapper
.
getUILabelForScanCodeBinding
(
binding
),
this
.
_mapper
.
getAriaLabelForScanCodeBinding
(
binding
)
);
}
public
getDispatchParts
():
(
string
|
null
)[]
{
return
this
.
_parts
.
map
((
keybinding
)
=>
this
.
_mapper
.
getDispatchStrForScanCodeBinding
(
keybinding
));
protected
_getDispatchPart
(
keybinding
:
ScanCodeBinding
):
string
|
null
{
return
this
.
_mapper
.
getDispatchStrForScanCodeBinding
(
keybinding
);
}
}
...
...
src/vs/workbench/services/keybinding/common/windowsKeyboardMapper.ts
浏览文件 @
ad209fbf
...
...
@@ -4,8 +4,8 @@
*--------------------------------------------------------------------------------------------*/
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
import
{
KeyCode
,
KeyCodeUtils
,
Keybinding
,
ResolvedKeybinding
,
ResolvedKeybindingPart
,
Simple
Keybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
AriaLabelProvider
,
ElectronAcceleratorLabelProvider
,
UILabelProvider
,
UserSettings
LabelProvider
}
from
'
vs/base/common/keybindingLabels
'
;
import
{
KeyCode
,
KeyCodeUtils
,
Keybinding
,
ResolvedKeybinding
,
SimpleKeybinding
,
BaseResolved
Keybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
UI
LabelProvider
}
from
'
vs/base/common/keybindingLabels
'
;
import
{
OperatingSystem
}
from
'
vs/base/common/platform
'
;
import
{
IMMUTABLE_CODE_TO_KEY_CODE
,
ScanCode
,
ScanCodeBinding
,
ScanCodeUtils
}
from
'
vs/base/common/scanCode
'
;
import
{
IKeyboardEvent
}
from
'
vs/platform/keybinding/common/keybinding
'
;
...
...
@@ -76,38 +76,23 @@ export interface IScanCodeMapping {
withShiftAltGr
:
string
;
}
export
class
WindowsNativeResolvedKeybinding
extends
ResolvedKeybinding
{
export
class
WindowsNativeResolvedKeybinding
extends
BaseResolvedKeybinding
<
SimpleKeybinding
>
{
private
readonly
_mapper
:
WindowsKeyboardMapper
;
private
readonly
_parts
:
SimpleKeybinding
[];
constructor
(
mapper
:
WindowsKeyboardMapper
,
parts
:
SimpleKeybinding
[])
{
super
();
if
(
parts
.
length
===
0
)
{
throw
new
Error
(
`Invalid WindowsNativeResolvedKeybinding`
);
}
super
(
OperatingSystem
.
Windows
,
parts
);
this
.
_mapper
=
mapper
;
this
.
_parts
=
parts
;
}
private
_getUILabelForKeybinding
(
keybinding
:
SimpleKeybinding
|
null
):
string
|
null
{
if
(
!
keybinding
)
{
return
null
;
}
protected
_getLabel
(
keybinding
:
SimpleKeybinding
):
string
|
null
{
if
(
keybinding
.
isDuplicateModifierCase
())
{
return
''
;
}
return
this
.
_mapper
.
getUILabelForKeyCode
(
keybinding
.
keyCode
);
}
public
getLabel
():
string
|
null
{
return
UILabelProvider
.
toLabel
(
OperatingSystem
.
Windows
,
this
.
_parts
,
(
keybinding
)
=>
this
.
_getUILabelForKeybinding
(
keybinding
));
}
private
_getUSLabelForKeybinding
(
keybinding
:
SimpleKeybinding
|
null
):
string
|
null
{
if
(
!
keybinding
)
{
return
null
;
}
private
_getUSLabelForKeybinding
(
keybinding
:
SimpleKeybinding
):
string
|
null
{
if
(
keybinding
.
isDuplicateModifierCase
())
{
return
''
;
}
...
...
@@ -115,23 +100,16 @@ export class WindowsNativeResolvedKeybinding extends ResolvedKeybinding {
}
public
getUSLabel
():
string
|
null
{
return
UILabelProvider
.
toLabel
(
OperatingSystem
.
Window
s
,
this
.
_parts
,
(
keybinding
)
=>
this
.
_getUSLabelForKeybinding
(
keybinding
));
return
UILabelProvider
.
toLabel
(
this
.
_o
s
,
this
.
_parts
,
(
keybinding
)
=>
this
.
_getUSLabelForKeybinding
(
keybinding
));
}
private
_getAriaLabelForKeybinding
(
keybinding
:
SimpleKeybinding
|
null
):
string
|
null
{
if
(
!
keybinding
)
{
return
null
;
}
protected
_getAriaLabel
(
keybinding
:
SimpleKeybinding
):
string
|
null
{
if
(
keybinding
.
isDuplicateModifierCase
())
{
return
''
;
}
return
this
.
_mapper
.
getAriaLabelForKeyCode
(
keybinding
.
keyCode
);
}
public
getAriaLabel
():
string
|
null
{
return
AriaLabelProvider
.
toLabel
(
OperatingSystem
.
Windows
,
this
.
_parts
,
(
keybinding
)
=>
this
.
_getAriaLabelForKeybinding
(
keybinding
));
}
private
_keyCodeToElectronAccelerator
(
keyCode
:
KeyCode
):
string
|
null
{
if
(
keyCode
>=
KeyCode
.
NUMPAD_0
&&
keyCode
<=
KeyCode
.
NUMPAD_DIVIDE
)
{
// Electron cannot handle numpad keys
...
...
@@ -153,45 +131,26 @@ export class WindowsNativeResolvedKeybinding extends ResolvedKeybinding {
return
KeyCodeUtils
.
toString
(
keyCode
);
}
private
_getElectronAcceleratorLabelForKeybinding
(
keybinding
:
SimpleKeybinding
|
null
):
string
|
null
{
if
(
!
keybinding
)
{
return
null
;
}
protected
_getElectronAccelerator
(
keybinding
:
SimpleKeybinding
):
string
|
null
{
if
(
keybinding
.
isDuplicateModifierCase
())
{
return
null
;
}
return
this
.
_keyCodeToElectronAccelerator
(
keybinding
.
keyCode
);
}
public
getElectronAccelerator
():
string
|
null
{
if
(
this
.
_parts
.
length
>
1
)
{
// Electron cannot handle chords
return
null
;
}
return
ElectronAcceleratorLabelProvider
.
toLabel
(
OperatingSystem
.
Windows
,
this
.
_parts
,
(
keybinding
)
=>
this
.
_getElectronAcceleratorLabelForKeybinding
(
keybinding
));
}
private
_getUserSettingsLabelForKeybinding
(
keybinding
:
SimpleKeybinding
|
null
):
string
|
null
{
if
(
!
keybinding
)
{
return
null
;
}
protected
_getUserSettingsLabel
(
keybinding
:
SimpleKeybinding
):
string
|
null
{
if
(
keybinding
.
isDuplicateModifierCase
())
{
return
''
;
}
return
this
.
_mapper
.
getUserSettingsLabelForKeyCode
(
keybinding
.
keyCode
);
}
public
getUserSettingsLabel
():
string
|
null
{
const
result
=
UserSettingsLabelProvider
.
toLabel
(
OperatingSystem
.
Windows
,
this
.
_parts
,
(
keybinding
)
=>
this
.
_getUserSettingsLabelForKeybinding
(
keybinding
));
const
result
=
this
.
_mapper
.
getUserSettingsLabelForKeyCode
(
keybinding
.
keyCode
);
return
(
result
?
result
.
toLowerCase
()
:
result
);
}
p
ublic
isWYSIWYG
(
):
boolean
{
return
this
.
_
parts
.
every
((
keybinding
)
=>
this
.
_isWYSIWYG
(
keybinding
.
keyCode
)
);
p
rotected
_isWYSIWYG
(
keybinding
:
SimpleKeybinding
):
boolean
{
return
this
.
_
_isWYSIWYG
(
keybinding
.
keyCode
);
}
private
_isWYSIWYG
(
keyCode
:
KeyCode
):
boolean
{
private
_
_
isWYSIWYG
(
keyCode
:
KeyCode
):
boolean
{
if
(
keyCode
===
KeyCode
.
LeftArrow
||
keyCode
===
KeyCode
.
UpArrow
...
...
@@ -205,30 +164,7 @@ export class WindowsNativeResolvedKeybinding extends ResolvedKeybinding {
return
(
ariaLabel
===
userSettingsLabel
);
}
public
isChord
():
boolean
{
return
(
this
.
_parts
.
length
>
1
);
}
public
getParts
():
ResolvedKeybindingPart
[]
{
return
this
.
_parts
.
map
((
keybinding
)
=>
this
.
_toResolvedKeybindingPart
(
keybinding
));
}
private
_toResolvedKeybindingPart
(
keybinding
:
SimpleKeybinding
):
ResolvedKeybindingPart
{
return
new
ResolvedKeybindingPart
(
keybinding
.
ctrlKey
,
keybinding
.
shiftKey
,
keybinding
.
altKey
,
keybinding
.
metaKey
,
this
.
_getUILabelForKeybinding
(
keybinding
),
this
.
_getAriaLabelForKeybinding
(
keybinding
)
);
}
public
getDispatchParts
():
(
string
|
null
)[]
{
return
this
.
_parts
.
map
((
keybinding
)
=>
this
.
_getDispatchStr
(
keybinding
));
}
private
_getDispatchStr
(
keybinding
:
SimpleKeybinding
):
string
|
null
{
protected
_getDispatchPart
(
keybinding
:
SimpleKeybinding
):
string
|
null
{
if
(
keybinding
.
isModifierKey
())
{
return
null
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录