Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e47f1213
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,发现更多精彩内容 >>
提交
e47f1213
编写于
4月 10, 2018
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dispatchKeybinding from main
上级
48bd86b4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
51 addition
and
61 deletion
+51
-61
src/vs/platform/driver/common/driver.ts
src/vs/platform/driver/common/driver.ts
+0
-7
src/vs/platform/driver/electron-browser/driver.ts
src/vs/platform/driver/electron-browser/driver.ts
+0
-51
src/vs/platform/driver/electron-main/driver.ts
src/vs/platform/driver/electron-main/driver.ts
+51
-3
未找到文件。
src/vs/platform/driver/common/driver.ts
浏览文件 @
e47f1213
...
...
@@ -155,7 +155,6 @@ export class WindowDriverRegistryChannelClient implements IWindowDriverRegistry
}
export
interface
IWindowDriver
{
dispatchKeybinding
(
keybinding
:
string
):
TPromise
<
void
>
;
click
(
selector
:
string
,
xoffset
?:
number
|
undefined
,
yoffset
?:
number
|
undefined
):
TPromise
<
void
>
;
doubleClick
(
selector
:
string
):
TPromise
<
void
>
;
move
(
selector
:
string
):
TPromise
<
void
>
;
...
...
@@ -167,7 +166,6 @@ export interface IWindowDriver {
}
export
interface
IWindowDriverChannel
extends
IChannel
{
call
(
command
:
'
dispatchKeybinding
'
,
arg
:
string
):
TPromise
<
void
>
;
call
(
command
:
'
click
'
,
arg
:
[
string
,
number
|
undefined
,
number
|
undefined
]):
TPromise
<
void
>
;
call
(
command
:
'
doubleClick
'
,
arg
:
string
):
TPromise
<
void
>
;
call
(
command
:
'
move
'
,
arg
:
string
):
TPromise
<
void
>
;
...
...
@@ -185,7 +183,6 @@ export class WindowDriverChannel implements IWindowDriverChannel {
call
(
command
:
string
,
arg
?:
any
):
TPromise
<
any
>
{
switch
(
command
)
{
case
'
dispatchKeybinding
'
:
return
this
.
driver
.
dispatchKeybinding
(
arg
);
case
'
click
'
:
return
this
.
driver
.
click
(
arg
[
0
],
arg
[
1
],
arg
[
2
]);
case
'
doubleClick
'
:
return
this
.
driver
.
doubleClick
(
arg
);
case
'
move
'
:
return
this
.
driver
.
move
(
arg
);
...
...
@@ -207,10 +204,6 @@ export class WindowDriverChannelClient implements IWindowDriver {
constructor
(
private
channel
:
IWindowDriverChannel
)
{
}
dispatchKeybinding
(
keybinding
:
string
):
TPromise
<
void
>
{
return
this
.
channel
.
call
(
'
dispatchKeybinding
'
,
keybinding
);
}
click
(
selector
:
string
,
xoffset
?:
number
,
yoffset
?:
number
):
TPromise
<
void
>
{
return
this
.
channel
.
call
(
'
click
'
,
[
selector
,
xoffset
,
yoffset
]);
}
...
...
src/vs/platform/driver/electron-browser/driver.ts
浏览文件 @
e47f1213
...
...
@@ -9,63 +9,12 @@ import { TPromise } from 'vs/base/common/winjs.base';
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IWindowDriver
,
IElement
,
WindowDriverChannel
,
WindowDriverRegistryChannelClient
}
from
'
vs/platform/driver/common/driver
'
;
import
{
IPCClient
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
KeybindingIO
}
from
'
vs/workbench/services/keybinding/common/keybindingIO
'
;
import
{
SimpleKeybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
ScanCodeBinding
}
from
'
vs/workbench/services/keybinding/common/scanCode
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
*
as
electron
from
'
electron
'
;
import
{
USLayoutResolvedKeybinding
}
from
'
../../keybinding/common/usLayoutResolvedKeybinding
'
;
import
{
OS
}
from
'
vs/base/common/platform
'
;
class
WindowDriver
implements
IWindowDriver
{
constructor
()
{
}
async
dispatchKeybinding
(
rawKeybinding
:
string
):
TPromise
<
void
>
{
const
[
first
,
second
]
=
KeybindingIO
.
_readUserBinding
(
rawKeybinding
);
await
this
.
_dispatchKeybinding
(
first
);
if
(
second
)
{
await
this
.
_dispatchKeybinding
(
second
);
}
}
private
async
_dispatchKeybinding
(
keybinding
:
SimpleKeybinding
|
ScanCodeBinding
):
TPromise
<
void
>
{
if
(
keybinding
instanceof
ScanCodeBinding
)
{
throw
new
Error
(
'
ScanCodeBindings not supported
'
);
}
const
webContents
=
electron
.
remote
.
getCurrentWebContents
();
const
noModifiedKeybinding
=
new
SimpleKeybinding
(
false
,
false
,
false
,
false
,
keybinding
.
keyCode
);
const
resolvedKeybinding
=
new
USLayoutResolvedKeybinding
(
noModifiedKeybinding
,
OS
);
const
keyCode
=
resolvedKeybinding
.
getElectronAccelerator
();
const
modifiers
=
[];
if
(
keybinding
.
ctrlKey
)
{
modifiers
.
push
(
'
ctrl
'
);
}
if
(
keybinding
.
metaKey
)
{
modifiers
.
push
(
'
meta
'
);
}
if
(
keybinding
.
shiftKey
)
{
modifiers
.
push
(
'
shift
'
);
}
if
(
keybinding
.
altKey
)
{
modifiers
.
push
(
'
alt
'
);
}
webContents
.
sendInputEvent
({
type
:
'
keyDown
'
,
keyCode
,
modifiers
}
as
any
);
webContents
.
sendInputEvent
({
type
:
'
char
'
,
keyCode
,
modifiers
}
as
any
);
webContents
.
sendInputEvent
({
type
:
'
keyUp
'
,
keyCode
,
modifiers
}
as
any
);
await
TPromise
.
timeout
(
100
);
}
click
(
selector
:
string
,
xoffset
?:
number
,
yoffset
?:
number
):
TPromise
<
void
>
{
throw
new
Error
(
'
Method not implemented.
'
);
}
...
...
src/vs/platform/driver/electron-main/driver.ts
浏览文件 @
e47f1213
...
...
@@ -12,6 +12,13 @@ import { serve as serveNet } from 'vs/base/parts/ipc/node/ipc.net';
import
{
combinedDisposable
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IPCServer
,
IClientRouter
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
SimpleKeybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
USLayoutResolvedKeybinding
}
from
'
vs/platform/keybinding/common/usLayoutResolvedKeybinding
'
;
import
{
OS
}
from
'
vs/base/common/platform
'
;
// TODO@joao: bad layering!
import
{
KeybindingIO
}
from
'
vs/workbench/services/keybinding/common/keybindingIO
'
;
import
{
ScanCodeBinding
}
from
'
vs/workbench/services/keybinding/common/scanCode
'
;
class
WindowRouter
implements
IClientRouter
{
...
...
@@ -44,9 +51,50 @@ export class Driver implements IDriver, IWindowDriverRegistry {
.
filter
(
id
=>
this
.
registeredWindowIds
.
has
(
id
));
}
dispatchKeybinding
(
windowId
:
number
,
keybinding
:
string
):
TPromise
<
void
>
{
const
windowDriver
=
this
.
getWindowDriver
(
windowId
);
return
windowDriver
.
dispatchKeybinding
(
keybinding
);
async
dispatchKeybinding
(
windowId
:
number
,
keybinding
:
string
):
TPromise
<
void
>
{
const
[
first
,
second
]
=
KeybindingIO
.
_readUserBinding
(
keybinding
);
await
this
.
_dispatchKeybinding
(
windowId
,
first
);
if
(
second
)
{
await
this
.
_dispatchKeybinding
(
windowId
,
second
);
}
}
private
async
_dispatchKeybinding
(
windowId
:
number
,
keybinding
:
SimpleKeybinding
|
ScanCodeBinding
):
TPromise
<
void
>
{
if
(
keybinding
instanceof
ScanCodeBinding
)
{
throw
new
Error
(
'
ScanCodeBindings not supported
'
);
}
const
window
=
this
.
windowsService
.
getWindowById
(
windowId
);
const
webContents
=
window
.
win
.
webContents
;
const
noModifiedKeybinding
=
new
SimpleKeybinding
(
false
,
false
,
false
,
false
,
keybinding
.
keyCode
);
const
resolvedKeybinding
=
new
USLayoutResolvedKeybinding
(
noModifiedKeybinding
,
OS
);
const
keyCode
=
resolvedKeybinding
.
getElectronAccelerator
();
const
modifiers
=
[];
if
(
keybinding
.
ctrlKey
)
{
modifiers
.
push
(
'
ctrl
'
);
}
if
(
keybinding
.
metaKey
)
{
modifiers
.
push
(
'
meta
'
);
}
if
(
keybinding
.
shiftKey
)
{
modifiers
.
push
(
'
shift
'
);
}
if
(
keybinding
.
altKey
)
{
modifiers
.
push
(
'
alt
'
);
}
webContents
.
sendInputEvent
({
type
:
'
keyDown
'
,
keyCode
,
modifiers
}
as
any
);
webContents
.
sendInputEvent
({
type
:
'
char
'
,
keyCode
,
modifiers
}
as
any
);
webContents
.
sendInputEvent
({
type
:
'
keyUp
'
,
keyCode
,
modifiers
}
as
any
);
await
TPromise
.
timeout
(
100
);
}
click
(
windowId
:
number
,
selector
:
string
,
xoffset
?:
number
,
yoffset
?:
number
):
TPromise
<
void
>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录