Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
5d9d2d12
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,发现更多精彩内容 >>
提交
5d9d2d12
编写于
4月 09, 2018
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Work in progress for exposing all terminals via API
上级
eb0f99cb
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
53 addition
and
9 deletion
+53
-9
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+8
-0
src/vs/workbench/api/electron-browser/mainThreadTerminalService.ts
...rkbench/api/electron-browser/mainThreadTerminalService.ts
+5
-0
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+3
-0
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+1
-0
src/vs/workbench/api/node/extHostTerminalService.ts
src/vs/workbench/api/node/extHostTerminalService.ts
+29
-9
src/vs/workbench/parts/terminal/common/terminal.ts
src/vs/workbench/parts/terminal/common/terminal.ts
+1
-0
src/vs/workbench/parts/terminal/common/terminalService.ts
src/vs/workbench/parts/terminal/common/terminalService.ts
+3
-0
src/vs/workbench/parts/terminal/electron-browser/terminalService.ts
...kbench/parts/terminal/electron-browser/terminalService.ts
+1
-0
src/vs/workbench/parts/terminal/electron-browser/terminalTab.ts
.../workbench/parts/terminal/electron-browser/terminalTab.ts
+2
-0
未找到文件。
src/vs/vscode.proposed.d.ts
浏览文件 @
5d9d2d12
...
...
@@ -769,4 +769,12 @@ declare module 'vscode' {
}
//#endregion
//#region Terminal
export
namespace
window
{
export
const
onDidOpenTerminal
:
Event
<
Terminal
>
;
}
//#endregion
}
src/vs/workbench/api/electron-browser/mainThreadTerminalService.ts
浏览文件 @
5d9d2d12
...
...
@@ -22,6 +22,7 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
)
{
this
.
_proxy
=
extHostContext
.
getProxy
(
ExtHostContext
.
ExtHostTerminalService
);
this
.
_toDispose
=
[];
this
.
_toDispose
.
push
(
terminalService
.
onInstanceCreated
((
terminalInstance
)
=>
this
.
_onTerminalOpened
(
terminalInstance
)));
this
.
_toDispose
.
push
(
terminalService
.
onInstanceDisposed
((
terminalInstance
)
=>
this
.
_onTerminalDisposed
(
terminalInstance
)));
this
.
_toDispose
.
push
(
terminalService
.
onInstanceProcessIdReady
((
terminalInstance
)
=>
this
.
_onTerminalProcessIdReady
(
terminalInstance
)));
}
...
...
@@ -78,6 +79,10 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
this
.
_proxy
.
$acceptTerminalClosed
(
terminalInstance
.
id
);
}
private
_onTerminalOpened
(
terminalInstance
:
ITerminalInstance
):
void
{
this
.
_proxy
.
$acceptTerminalOpened
(
terminalInstance
.
id
,
terminalInstance
.
title
);
}
private
_onTerminalProcessIdReady
(
terminalInstance
:
ITerminalInstance
):
void
{
this
.
_proxy
.
$acceptTerminalProcessId
(
terminalInstance
.
id
,
terminalInstance
.
processId
);
}
...
...
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
5d9d2d12
...
...
@@ -351,6 +351,9 @@ export function createApiFactory(
onDidCloseTerminal
(
listener
,
thisArg
?,
disposables
?)
{
return
extHostTerminalService
.
onDidCloseTerminal
(
listener
,
thisArg
,
disposables
);
},
onDidOpenTerminal
(
listener
,
thisArg
?,
disposables
?)
{
return
extHostTerminalService
.
onDidOpenTerminal
(
listener
,
thisArg
,
disposables
);
},
get
state
()
{
return
extHostWindow
.
state
;
},
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
5d9d2d12
...
...
@@ -728,6 +728,7 @@ export interface ExtHostQuickOpenShape {
export
interface
ExtHostTerminalServiceShape
{
$acceptTerminalClosed
(
id
:
number
):
void
;
$acceptTerminalOpened
(
id
:
number
,
name
:
string
):
void
;
$acceptTerminalProcessId
(
id
:
number
,
processId
:
number
):
void
;
}
...
...
src/vs/workbench/api/node/extHostTerminalService.ts
浏览文件 @
5d9d2d12
...
...
@@ -20,12 +20,7 @@ export class ExtHostTerminal implements vscode.Terminal {
constructor
(
proxy
:
MainThreadTerminalServiceShape
,
name
?:
string
,
shellPath
?:
string
,
shellArgs
?:
string
[],
cwd
?:
string
,
env
?:
{
[
key
:
string
]:
string
},
waitOnExit
?:
boolean
name
?:
string
)
{
this
.
_name
=
name
;
this
.
_queuedRequests
=
[];
...
...
@@ -33,8 +28,16 @@ export class ExtHostTerminal implements vscode.Terminal {
this
.
_pidPromise
=
new
Promise
<
number
>
(
c
=>
{
this
.
_pidPromiseComplete
=
c
;
});
}
this
.
_proxy
.
$createTerminal
(
name
,
shellPath
,
shellArgs
,
cwd
,
env
,
waitOnExit
).
then
((
id
)
=>
{
public
create
(
shellPath
?:
string
,
shellArgs
?:
string
[],
cwd
?:
string
,
env
?:
{
[
key
:
string
]:
string
},
waitOnExit
?:
boolean
):
void
{
this
.
_proxy
.
$createTerminal
(
this
.
_name
,
shellPath
,
shellArgs
,
cwd
,
env
,
waitOnExit
).
then
((
id
)
=>
{
this
.
_id
=
id
;
this
.
_queuedRequests
.
forEach
((
r
)
=>
{
r
.
run
(
this
.
_proxy
,
this
.
_id
);
...
...
@@ -99,23 +102,27 @@ export class ExtHostTerminal implements vscode.Terminal {
export
class
ExtHostTerminalService
implements
ExtHostTerminalServiceShape
{
private
readonly
_onDidCloseTerminal
:
Emitter
<
vscode
.
Terminal
>
;
private
readonly
_onDidOpenTerminal
:
Emitter
<
vscode
.
Terminal
>
;
private
_proxy
:
MainThreadTerminalServiceShape
;
private
_terminals
:
ExtHostTerminal
[];
constructor
(
mainContext
:
IMainContext
)
{
this
.
_onDidCloseTerminal
=
new
Emitter
<
vscode
.
Terminal
>
();
this
.
_onDidOpenTerminal
=
new
Emitter
<
vscode
.
Terminal
>
();
this
.
_proxy
=
mainContext
.
getProxy
(
MainContext
.
MainThreadTerminalService
);
this
.
_terminals
=
[];
}
public
createTerminal
(
name
?:
string
,
shellPath
?:
string
,
shellArgs
?:
string
[]):
vscode
.
Terminal
{
let
terminal
=
new
ExtHostTerminal
(
this
.
_proxy
,
name
,
shellPath
,
shellArgs
);
let
terminal
=
new
ExtHostTerminal
(
this
.
_proxy
,
name
);
terminal
.
create
(
shellPath
,
shellArgs
);
this
.
_terminals
.
push
(
terminal
);
return
terminal
;
}
public
createTerminalFromOptions
(
options
:
vscode
.
TerminalOptions
):
vscode
.
Terminal
{
let
terminal
=
new
ExtHostTerminal
(
this
.
_proxy
,
options
.
name
,
options
.
shellPath
,
options
.
shellArgs
,
options
.
cwd
,
options
.
env
/*, options.waitOnExit*/
);
let
terminal
=
new
ExtHostTerminal
(
this
.
_proxy
,
options
.
name
);
terminal
.
create
(
options
.
shellPath
,
options
.
shellArgs
,
options
.
cwd
,
options
.
env
/*, options.waitOnExit*/
);
this
.
_terminals
.
push
(
terminal
);
return
terminal
;
}
...
...
@@ -124,6 +131,10 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
return
this
.
_onDidCloseTerminal
&&
this
.
_onDidCloseTerminal
.
event
;
}
public
get
onDidOpenTerminal
():
Event
<
vscode
.
Terminal
>
{
return
this
.
_onDidOpenTerminal
&&
this
.
_onDidOpenTerminal
.
event
;
}
public
$acceptTerminalClosed
(
id
:
number
):
void
{
let
index
=
this
.
_getTerminalIndexById
(
id
);
if
(
index
===
null
)
{
...
...
@@ -134,6 +145,15 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
this
.
_onDidCloseTerminal
.
fire
(
terminal
);
}
// TOOD: How do we set PID
// TODO: Make sure both API terminals and non-API terminals are created correctly
public
$acceptTerminalOpened
(
id
:
number
,
name
:
string
):
void
{
// TODO: Only create a terminal if it doesn't already exist for the ID
let
terminal
=
new
ExtHostTerminal
(
this
.
_proxy
,
name
);
this
.
_terminals
.
push
(
terminal
);
this
.
_onDidOpenTerminal
.
fire
(
terminal
);
}
public
$acceptTerminalProcessId
(
id
:
number
,
processId
:
number
):
void
{
let
terminal
=
this
.
_getTerminalById
(
id
);
if
(
terminal
)
{
...
...
src/vs/workbench/parts/terminal/common/terminal.ts
浏览文件 @
5d9d2d12
...
...
@@ -149,6 +149,7 @@ export interface ITerminalService {
configHelper
:
ITerminalConfigHelper
;
onActiveTabChanged
:
Event
<
void
>
;
onTabDisposed
:
Event
<
ITerminalTab
>
;
onInstanceCreated
:
Event
<
ITerminalInstance
>
;
onInstanceDisposed
:
Event
<
ITerminalInstance
>
;
onInstanceProcessIdReady
:
Event
<
ITerminalInstance
>
;
onInstancesChanged
:
Event
<
void
>
;
...
...
src/vs/workbench/parts/terminal/common/terminalService.ts
浏览文件 @
5d9d2d12
...
...
@@ -24,6 +24,7 @@ export abstract class TerminalService implements ITerminalService {
protected
_terminalContainer
:
HTMLElement
;
protected
_onInstancesChanged
:
Emitter
<
void
>
;
protected
_onTabDisposed
:
Emitter
<
ITerminalTab
>
;
protected
_onInstanceCreated
:
Emitter
<
ITerminalInstance
>
;
protected
_onInstanceDisposed
:
Emitter
<
ITerminalInstance
>
;
protected
_onInstanceProcessIdReady
:
Emitter
<
ITerminalInstance
>
;
protected
_onInstanceTitleChanged
:
Emitter
<
string
>
;
...
...
@@ -36,6 +37,7 @@ export abstract class TerminalService implements ITerminalService {
public
get
activeTabIndex
():
number
{
return
this
.
_activeTabIndex
;
}
public
get
onActiveTabChanged
():
Event
<
void
>
{
return
this
.
_onActiveTabChanged
.
event
;
}
public
get
onTabDisposed
():
Event
<
ITerminalTab
>
{
return
this
.
_onTabDisposed
.
event
;
}
public
get
onInstanceCreated
():
Event
<
ITerminalInstance
>
{
return
this
.
_onInstanceCreated
.
event
;
}
public
get
onInstanceDisposed
():
Event
<
ITerminalInstance
>
{
return
this
.
_onInstanceDisposed
.
event
;
}
public
get
onInstanceProcessIdReady
():
Event
<
ITerminalInstance
>
{
return
this
.
_onInstanceProcessIdReady
.
event
;
}
public
get
onInstanceTitleChanged
():
Event
<
string
>
{
return
this
.
_onInstanceTitleChanged
.
event
;
}
...
...
@@ -57,6 +59,7 @@ export abstract class TerminalService implements ITerminalService {
this
.
_onActiveTabChanged
=
new
Emitter
<
void
>
();
this
.
_onTabDisposed
=
new
Emitter
<
ITerminalTab
>
();
this
.
_onInstanceCreated
=
new
Emitter
<
ITerminalInstance
>
();
this
.
_onInstanceDisposed
=
new
Emitter
<
ITerminalInstance
>
();
this
.
_onInstanceProcessIdReady
=
new
Emitter
<
ITerminalInstance
>
();
this
.
_onInstanceTitleChanged
=
new
Emitter
<
string
>
();
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalService.ts
浏览文件 @
5d9d2d12
...
...
@@ -82,6 +82,7 @@ export class TerminalService extends AbstractTerminalService implements ITermina
// It's the first instance so it should be made active automatically
this
.
setActiveInstanceByIndex
(
0
);
}
this
.
_onInstanceCreated
.
fire
(
instance
);
this
.
_onInstancesChanged
.
fire
();
this
.
_suggestShellChange
(
wasNewTerminalAction
);
return
instance
;
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalTab.ts
浏览文件 @
5d9d2d12
...
...
@@ -402,6 +402,8 @@ export class TerminalTab extends Disposable implements ITerminalTab {
shellLaunchConfig
);
this
.
_terminalInstances
.
splice
(
this
.
_activeInstanceIndex
+
1
,
0
,
instance
);
this
.
_initInstanceListeners
(
instance
);
// TODO: Ensure change event is fired
// TODO: Fire create event on service
this
.
_setActiveInstance
(
instance
);
if
(
this
.
_splitPaneContainer
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录