Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b10ccf74
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,发现更多精彩内容 >>
提交
b10ccf74
编写于
2月 12, 2018
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Work on removal of splits
上级
d56d8ac5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
103 addition
and
32 deletion
+103
-32
src/vs/workbench/parts/terminal/common/terminalService.ts
src/vs/workbench/parts/terminal/common/terminalService.ts
+5
-2
src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts
...kbench/parts/terminal/electron-browser/terminalActions.ts
+1
-0
src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts
...orkbench/parts/terminal/electron-browser/terminalPanel.ts
+15
-14
src/vs/workbench/parts/terminal/electron-browser/terminalTab.ts
.../workbench/parts/terminal/electron-browser/terminalTab.ts
+82
-16
未找到文件。
src/vs/workbench/parts/terminal/common/terminalService.ts
浏览文件 @
b10ccf74
...
...
@@ -104,11 +104,14 @@ export abstract class TerminalService implements ITerminalService {
}
private
_removeTab
(
tab
:
ITerminalTab
):
void
{
let
index
=
this
.
_terminalTabs
.
indexOf
(
tab
);
let
wasActiveTab
=
tab
===
this
.
_getActiveTab
();
// Get the index of the tab and remove it from the list
const
index
=
this
.
_terminalTabs
.
indexOf
(
tab
);
const
wasActiveTab
=
tab
===
this
.
_getActiveTab
();
if
(
index
!==
-
1
)
{
this
.
_terminalTabs
.
splice
(
index
,
1
);
}
// Adjust focus if the tab was active
if
(
wasActiveTab
&&
this
.
_terminalTabs
.
length
>
0
)
{
let
newIndex
=
index
<
this
.
_terminalTabs
.
length
?
index
:
this
.
_terminalTabs
.
length
-
1
;
this
.
setActiveInstanceByIndex
(
newIndex
);
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts
浏览文件 @
b10ccf74
...
...
@@ -353,6 +353,7 @@ export class FocusPreviousTerminalAction extends Action {
return
this
.
terminalService
.
showPanel
(
true
);
}
}
export
class
TerminalPasteAction
extends
Action
{
public
static
readonly
ID
=
'
workbench.action.terminal.paste
'
;
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts
浏览文件 @
b10ccf74
...
...
@@ -256,20 +256,21 @@ export class TerminalPanel extends Panel {
}
this
.
_cancelContextMenu
=
false
;
}));
this
.
_register
(
dom
.
addDisposableListener
(
this
.
_parentDomElement
,
'
click
'
,
(
event
)
=>
{
if
(
event
.
which
===
3
)
{
return
;
}
const
instance
=
this
.
_terminalService
.
getActiveInstance
();
if
(
instance
)
{
// TODO: This and other usages for getActiveInstance().focus() are now invalid,
// TerminalService should defer the active instance to the TerminalTab
console
.
log
(
'
clicked, focus
'
);
this
.
_terminalService
.
getActiveInstance
().
focus
();
}
}));
// TODO: Not sure if this is needed anymore?
// this._register(dom.addDisposableListener(this._parentDomElement, 'click', (event) => {
// if (event.which === 3) {
// return;
// }
// const instance = this._terminalService.getActiveInstance();
// if (instance) {
// // TODO: This and other usages for getActiveInstance().focus() are now invalid,
// // TerminalService should defer the active instance to the TerminalTab
// console.log('clicked, focus');
// this._terminalService.getActiveInstance().focus();
// }
// }));
this
.
_register
(
dom
.
addDisposableListener
(
this
.
_parentDomElement
,
'
keyup
'
,
(
event
:
KeyboardEvent
)
=>
{
if
(
event
.
keyCode
===
27
)
{
// Keep terminal open on escape
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalTab.ts
浏览文件 @
b10ccf74
...
...
@@ -16,20 +16,20 @@ class SplitPane implements IView {
// TODO: What's a good number for the min?
public
minimumSize
:
number
=
10
;
public
maximumSize
:
number
=
Number
.
MAX_VALUE
;
protected
_size
:
number
;
public
instance
:
ITerminalInstance
;
public
orientation
:
Orientation
|
undefined
;
protected
_size
:
number
;
private
_splitView
:
SplitView
|
undefined
;
private
_children
:
SplitPane
[]
=
[];
private
_container
:
HTMLElement
;
public
instance
:
ITerminalInstance
;
private
_isContainerSet
:
boolean
=
false
;
private
_onDidChange
:
Event
<
number
|
undefined
>
=
Event
.
None
;
public
get
onDidChange
():
Event
<
number
|
undefined
>
{
return
this
.
_onDidChange
;
}
public
get
children
():
SplitPane
[]
{
return
this
.
_children
;
}
public
get
onDidChange
():
Event
<
number
|
undefined
>
{
return
this
.
_onDidChange
;
}
constructor
(
private
_parent
?:
SplitPane
,
...
...
@@ -50,6 +50,9 @@ class SplitPane implements IView {
this
.
addChild
(
this
.
orthogonalSize
/
2
,
this
.
_size
,
this
.
instance
,
0
,
this
.
_isContainerSet
);
this
.
addChild
(
this
.
orthogonalSize
/
2
,
this
.
_size
,
instance
);
// Instance is now owned by the first child
this
.
instance
=
null
;
}
public
split
(
instance
:
ITerminalInstance
):
void
{
...
...
@@ -77,6 +80,20 @@ class SplitPane implements IView {
this
.
_onDidChange
=
anyEvent
(...
this
.
_children
.
map
(
c
=>
c
.
onDidChange
));
}
public
remove
():
void
{
if
(
!
this
.
_parent
)
{
return
;
}
this
.
_parent
.
removeChild
(
this
);
}
public
removeChild
(
child
:
SplitPane
):
void
{
const
index
=
this
.
_children
.
indexOf
(
child
);
this
.
_children
.
splice
(
index
,
1
);
this
.
_splitView
.
removeView
(
index
);
}
public
render
(
container
:
HTMLElement
):
void
{
if
(
!
container
)
{
return
;
...
...
@@ -97,8 +114,9 @@ class SplitPane implements IView {
}
public
layout
(
size
:
number
):
void
{
// Only layout when both sizes are known and the SplitPane owns an instance
this
.
_size
=
size
;
if
(
!
this
.
_size
||
!
this
.
orthogonalSize
)
{
if
(
!
this
.
_size
||
!
this
.
orthogonalSize
||
!
this
.
instance
)
{
return
;
}
...
...
@@ -154,9 +172,8 @@ class RootSplitPane extends SplitPane {
export
class
TerminalTab
extends
Disposable
implements
ITerminalTab
{
private
_terminalInstances
:
ITerminalInstance
[]
=
[];
private
_rootSplitPane
:
RootSplitPane
;
private
_splitPanes
:
SplitPane
[]
=
[];
//
private _activeInstanceIndex: number;
private
_activeInstanceIndex
:
number
;
public
get
terminalInstances
():
ITerminalInstance
[]
{
return
this
.
_terminalInstances
;
}
...
...
@@ -179,15 +196,15 @@ export class TerminalTab extends Disposable implements ITerminalTab {
undefined
,
shellLaunchConfig
);
this
.
_terminalInstances
.
push
(
instance
);
//
this._activeInstanceIndex = 0;
this
.
_activeInstanceIndex
=
0
;
instance
.
addDisposable
(
instance
.
onDisposed
(
instance
=>
this
.
_onInstanceDisposed
(
instance
)));
this
.
_rootSplitPane
=
new
RootSplitPane
();
this
.
_rootSplitPane
.
instance
=
instance
;
// TODO: Only render if it's visible?
this
.
_rootSplitPane
.
render
(
this
.
_container
);
// TODO: Is _splitPanes useful?
this
.
_splitPanes
.
push
(
this
.
_rootSplitPane
);
// TODO: Listen to instance focus and update activeInstanceIndex accordingly
}
public
dispose
():
void
{
...
...
@@ -195,12 +212,59 @@ export class TerminalTab extends Disposable implements ITerminalTab {
this
.
_terminalInstances
=
[];
}
public
get
activeInstance
():
ITerminalInstance
{
if
(
this
.
_terminalInstances
.
length
===
0
)
{
return
null
;
}
return
this
.
_terminalInstances
[
this
.
_activeInstanceIndex
];
}
private
_onInstanceDisposed
(
instance
:
ITerminalInstance
):
void
{
// Get the index of the instance and remove it from the list
const
index
=
this
.
_terminalInstances
.
indexOf
(
instance
);
const
wasActiveInstance
=
instance
===
this
.
activeInstance
;
if
(
index
!==
-
1
)
{
this
.
_terminalInstances
.
splice
(
index
,
1
);
}
// Adjust focus if the instance was active
if
(
wasActiveInstance
&&
this
.
_terminalInstances
.
length
>
0
)
{
let
newIndex
=
index
<
this
.
_terminalInstances
.
length
?
index
:
this
.
_terminalInstances
.
length
-
1
;
this
.
_setActiveInstanceByIndex
(
newIndex
);
if
(
instance
.
hadFocusOnExit
)
{
this
.
activeInstance
.
focus
(
true
);
}
}
// TODO: Find instance's SplitPane and unsplit it
this
.
_findSplitPane
(
instance
).
remove
();
// TODO: Listen for disposed on TerminalService and handle appropriately (remove the tab and its instance from the service)
// console.log('splitPane: ', splitPane);
// Dispose the tab if it was the last instance
if
(
this
.
_terminalInstances
.
length
===
0
)
{
console
.
log
(
'
Disposed terminal tab!
'
);
this
.
_onDisposed
.
fire
(
this
);
this
.
dispose
();
}
}
private
_findSplitPane
(
instance
:
ITerminalInstance
):
SplitPane
{
const
openList
:
SplitPane
[]
=
[
this
.
_rootSplitPane
];
while
(
openList
.
length
>
0
)
{
const
current
=
openList
.
shift
();
if
(
current
.
instance
===
instance
)
{
return
current
;
}
openList
.
push
.
apply
(
openList
,
current
.
children
);
}
return
null
;
}
this
.
_onDisposed
.
fire
(
this
);
this
.
dispose
();
private
_setActiveInstanceByIndex
(
index
:
number
):
void
{
this
.
_activeInstanceIndex
=
index
;
// TODO: Fire events like in TerminalService.setActiveInstanceByIndex?
}
public
attachToElement
(
element
:
HTMLElement
):
void
{
...
...
@@ -238,6 +302,8 @@ export class TerminalTab extends Disposable implements ITerminalTab {
this
.
_rootSplitPane
.
orientation
=
Orientation
.
HORIZONTAL
;
this
.
_rootSplitPane
.
split
(
instance
);
// TOOD: Set this correctly
this
.
_activeInstanceIndex
=
1
;
}
public
addDisposable
(
disposable
:
IDisposable
):
void
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录