Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e257780a
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,发现更多精彩内容 >>
提交
e257780a
编写于
6月 16, 2019
作者:
P
Peng Lyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
keyboard layout provider initialization
上级
308686a9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
44 addition
and
14 deletion
+44
-14
src/vs/workbench/services/keybinding/browser/keyboardLayoutService.ts
...ench/services/keybinding/browser/keyboardLayoutService.ts
+44
-14
未找到文件。
src/vs/workbench/services/keybinding/browser/keyboardLayoutService.ts
浏览文件 @
e257780a
...
...
@@ -25,7 +25,20 @@ export class BrowserKeymap {
private
readonly
_onDidChangeKeyboardLayout
=
new
Emitter
<
void
>
();
public
readonly
onDidChangeKeyboardLayout
:
Event
<
void
>
=
this
.
_onDidChangeKeyboardLayout
.
event
;
private
readonly
_onDidInitialized
=
new
Emitter
<
void
>
();
public
readonly
onDidInitialized
:
Event
<
void
>
=
this
.
_onDidInitialized
.
event
;
private
_initialized
:
boolean
;
private
constructor
()
{
this
.
_initialized
=
false
;
const
platform
=
isWindows
?
'
win
'
:
isMacintosh
?
'
darwin
'
:
'
linux
'
;
import
(
'
vs/workbench/services/keybinding/browser/keyboardlayouts/layout.contribution.
'
+
platform
).
then
(()
=>
{
this
.
_initialized
=
true
;
this
.
_onDidInitialized
.
fire
();
});
if
((
navigator
as
any
).
keyboard
&&
(
navigator
as
any
).
keyboard
.
addEventListener
)
{
(
navigator
as
any
).
keyboard
.
addEventListener
(
'
layoutchange
'
,
()
=>
{
// Update user keyboard map settings
...
...
@@ -39,14 +52,14 @@ export class BrowserKeymap {
});
}
const
platform
=
isWindows
?
'
win
'
:
isMacintosh
?
'
darwin
'
:
'
linux
'
;
import
(
'
vs/workbench/services/keybinding/browser/keyboardlayouts/layout.contribution.
'
+
platform
).
then
(()
=>
{
console
.
log
(
KeyboardLayoutProvider
.
INSTANCE
.
getKeyboardLayouts
().
length
);
});
}
validateCurrentKeyboardMapping
(
keyboardEvent
:
IKeyboardEvent
):
boolean
{
if
(
!
this
.
_initialized
)
{
return
true
;
}
const
standardKeyboardEvent
=
keyboardEvent
as
StandardKeyboardEvent
;
const
currentKeymap
=
KeyboardLayoutProvider
.
INSTANCE
.
activeKeyboardLayout
;
const
mapping
=
currentKeymap
.
value
[
standardKeyboardEvent
.
code
];
...
...
@@ -92,6 +105,10 @@ export class BrowserKeymap {
}
getCurrentKeyboardLayout
()
{
if
(
!
this
.
_initialized
)
{
return
null
;
}
return
KeyboardLayoutProvider
.
INSTANCE
.
activeKeyboardLayout
.
layout
;
}
...
...
@@ -125,12 +142,20 @@ export class BrowserKeyboardMapperFactory {
private
readonly
_onDidChangeKeyboardMapper
=
new
Emitter
<
void
>
();
public
readonly
onDidChangeKeyboardMapper
:
Event
<
void
>
=
this
.
_onDidChangeKeyboardMapper
.
event
;
private
readonly
_onDidInitialized
=
new
Emitter
<
void
>
();
public
readonly
onDidInitialized
:
Event
<
void
>
=
this
.
_onDidInitialized
.
event
;
private
constructor
()
{
this
.
_layoutInfo
=
null
;
this
.
_rawMapping
=
null
;
this
.
_keyboardMapper
=
null
;
this
.
_initialized
=
false
;
BrowserKeymap
.
INSTANCE
.
onDidInitialized
(()
=>
{
this
.
_initialized
=
true
;
this
.
_onKeyboardLayoutChanged
();
});
BrowserKeymap
.
INSTANCE
.
onDidChangeKeyboardLayout
(()
=>
{
this
.
_onKeyboardLayoutChanged
();
});
...
...
@@ -138,21 +163,24 @@ export class BrowserKeyboardMapperFactory {
private
_onKeyboardLayoutChanged
():
void
{
if
(
this
.
_initialized
)
{
this
.
updateKeyboardLayoutAsync
();
this
.
updateKeyboardLayoutAsync
(
true
);
}
}
private
updateKeyboardLayoutAsync
()
{
private
updateKeyboardLayoutAsync
(
initialized
:
boolean
)
{
if
(
!
initialized
)
{
return
;
}
BrowserKeymap
.
INSTANCE
.
getBrowserKeyMap
().
then
(
keyMap
=>
{
KeyboardLayoutProvider
.
INSTANCE
.
setActive
(
keyMap
);
this
.
_setKeyboardData
(
BrowserKeymap
.
INSTANCE
.
getCurrentKeyboardLayout
(),
keyMap
);
this
.
_setKeyboardData
(
BrowserKeymap
.
INSTANCE
.
getCurrentKeyboardLayout
()
!
,
keyMap
);
});
}
public
getKeyboardMapper
(
dispatchConfig
:
DispatchConfig
):
IKeyboardMapper
{
if
(
!
this
.
_initialized
)
{
this
.
_setKeyboardData
(
BrowserKeymap
.
INSTANCE
.
getCurrentKeyboardLayout
(),
{});
this
.
updateKeyboardLayoutAsync
();
return
new
MacLinuxFallbackKeyboardMapper
(
OS
);
}
if
(
dispatchConfig
===
DispatchConfig
.
KeyCode
)
{
// Forcefully set to use keyCode
...
...
@@ -164,26 +192,28 @@ export class BrowserKeyboardMapperFactory {
public
getCurrentKeyboardLayout
():
IKeyboardLayoutInfo
|
null
{
if
(
!
this
.
_initialized
)
{
this
.
_setKeyboardData
(
BrowserKeymap
.
INSTANCE
.
getCurrentKeyboardLayout
(),
{});
this
.
updateKeyboardLayoutAsync
();
return
null
;
}
return
this
.
_layoutInfo
;
}
public
validateCurrentKeyboardMapping
(
keyboardEvent
:
IKeyboardEvent
):
void
{
if
(
!
this
.
_initialized
)
{
return
;
}
let
isCurrentKeyboard
=
BrowserKeymap
.
INSTANCE
.
validateCurrentKeyboardMapping
(
keyboardEvent
);
if
(
isCurrentKeyboard
)
{
return
;
}
this
.
updateKeyboardLayoutAsync
();
this
.
updateKeyboardLayoutAsync
(
true
);
}
public
getRawKeyboardMapping
():
IKeyboardMapping
|
null
{
if
(
!
this
.
_initialized
)
{
this
.
_setKeyboardData
(
BrowserKeymap
.
INSTANCE
.
getCurrentKeyboardLayout
(),
{});
this
.
updateKeyboardLayoutAsync
();
return
null
;
}
return
this
.
_rawMapping
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录