Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
4dbb1443
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,发现更多精彩内容 >>
提交
4dbb1443
编写于
2月 10, 2018
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Layout orientation correctly
上级
cbbbe6a5
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
74 addition
and
28 deletion
+74
-28
src/vs/workbench/parts/terminal/common/terminal.ts
src/vs/workbench/parts/terminal/common/terminal.ts
+2
-1
src/vs/workbench/parts/terminal/common/terminalService.ts
src/vs/workbench/parts/terminal/common/terminalService.ts
+27
-8
src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts
...kbench/parts/terminal/electron-browser/terminalActions.ts
+1
-1
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
...bench/parts/terminal/electron-browser/terminalInstance.ts
+6
-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
+37
-18
未找到文件。
src/vs/workbench/parts/terminal/common/terminal.ts
浏览文件 @
4dbb1443
...
...
@@ -146,7 +146,7 @@ export interface ITerminalService {
activeTerminalInstanceIndex
:
number
;
configHelper
:
ITerminalConfigHelper
;
onActive
InstanceChanged
:
Event
<
string
>
;
onActive
TabChanged
:
Event
<
void
>
;
onTabDisposed
:
Event
<
ITerminalTab
>
;
onInstanceDisposed
:
Event
<
ITerminalInstance
>
;
onInstanceProcessIdReady
:
Event
<
ITerminalInstance
>
;
...
...
@@ -182,6 +182,7 @@ export interface ITerminalTab {
terminalInstances
:
ITerminalInstance
[];
title
:
string
;
attachToElement
(
element
:
HTMLElement
):
void
;
setVisible
(
visible
:
boolean
):
void
;
layout
(
width
:
number
,
height
:
number
):
void
;
addDisposable
(
disposable
:
IDisposable
):
void
;
...
...
src/vs/workbench/parts/terminal/common/terminalService.ts
浏览文件 @
4dbb1443
...
...
@@ -27,11 +27,13 @@ export abstract class TerminalService implements ITerminalService {
protected
_terminalTabs
:
ITerminalTab
[];
protected
abstract
_terminalInstances
:
ITerminalInstance
[];
private
_activeTabIndex
:
number
;
// TODO: Remove _activeTerminalInstanceIndex
private
_activeTerminalInstanceIndex
:
number
;
private
_onActive
InstanceChanged
:
Emitter
<
string
>
;
private
_onActive
TabChanged
:
Emitter
<
void
>
;
public
get
activeTerminalInstanceIndex
():
number
{
return
this
.
_activeTerminalInstanceIndex
;
}
public
get
onActive
InstanceChanged
():
Event
<
string
>
{
return
this
.
_onActiveInstance
Changed
.
event
;
}
public
get
onActive
TabChanged
():
Event
<
void
>
{
return
this
.
_onActiveTab
Changed
.
event
;
}
public
get
onTabDisposed
():
Event
<
ITerminalTab
>
{
return
this
.
_onTabDisposed
.
event
;
}
public
get
onInstanceDisposed
():
Event
<
ITerminalInstance
>
{
return
this
.
_onInstanceDisposed
.
event
;
}
public
get
onInstanceProcessIdReady
():
Event
<
ITerminalInstance
>
{
return
this
.
_onInstanceProcessIdReady
.
event
;
}
...
...
@@ -48,10 +50,11 @@ export abstract class TerminalService implements ITerminalService {
@
IPartService
private
_partService
:
IPartService
,
@
ILifecycleService
lifecycleService
:
ILifecycleService
)
{
this
.
_activeTabIndex
=
0
;
this
.
_activeTerminalInstanceIndex
=
0
;
this
.
_isShuttingDown
=
false
;
this
.
_onActive
InstanceChanged
=
new
Emitter
<
string
>
();
this
.
_onActive
TabChanged
=
new
Emitter
<
void
>
();
this
.
_onTabDisposed
=
new
Emitter
<
ITerminalTab
>
();
this
.
_onInstanceDisposed
=
new
Emitter
<
ITerminalInstance
>
();
this
.
_onInstanceProcessIdReady
=
new
Emitter
<
ITerminalInstance
>
();
...
...
@@ -102,11 +105,11 @@ export abstract class TerminalService implements ITerminalService {
private
_removeTab
(
tab
:
ITerminalTab
):
void
{
let
index
=
this
.
_terminalTabs
.
indexOf
(
tab
);
let
wasActive
Instance
=
tab
===
this
.
_getActiveTab
();
let
wasActive
Tab
=
tab
===
this
.
_getActiveTab
();
if
(
index
!==
-
1
)
{
this
.
_terminalTabs
.
splice
(
index
,
1
);
}
if
(
wasActive
Instance
&&
this
.
_terminalTabs
.
length
>
0
)
{
if
(
wasActive
Tab
&&
this
.
_terminalTabs
.
length
>
0
)
{
let
newIndex
=
index
<
this
.
_terminalTabs
.
length
?
index
:
this
.
_terminalTabs
.
length
-
1
;
this
.
setActiveInstanceByIndex
(
newIndex
);
// TODO: Needs to be made to work with multiple instances in a tab
...
...
@@ -122,8 +125,8 @@ export abstract class TerminalService implements ITerminalService {
}
// TODO: This should be onTabsChanged?
this
.
_onInstancesChanged
.
fire
();
if
(
wasActive
Instance
)
{
this
.
_onActive
Instance
Changed
.
fire
();
if
(
wasActive
Tab
)
{
this
.
_onActive
Tab
Changed
.
fire
();
}
}
...
...
@@ -155,6 +158,21 @@ export abstract class TerminalService implements ITerminalService {
this
.
setActiveInstanceByIndex
(
this
.
_getIndexFromId
(
terminalInstance
.
id
));
}
public
setActiveTabByIndex
(
tabIndex
:
number
):
void
{
if
(
tabIndex
>=
this
.
_terminalTabs
.
length
)
{
return
;
}
const
didTabChange
=
this
.
_activeTabIndex
!==
tabIndex
;
this
.
_activeTabIndex
=
tabIndex
;
this
.
_terminalTabs
.
forEach
((
t
,
i
)
=>
t
.
setVisible
(
i
===
this
.
_activeTabIndex
));
if
(
didTabChange
)
{
this
.
_onActiveTabChanged
.
fire
();
}
}
// TODO: Remove setActiveInstanceByIndex?
public
setActiveInstanceByIndex
(
terminalIndex
:
number
):
void
{
if
(
terminalIndex
>=
this
.
_terminalInstances
.
length
)
{
return
;
...
...
@@ -173,7 +191,8 @@ export abstract class TerminalService implements ITerminalService {
// });
// Only fire the event if there was a change
if
(
didInstanceChange
)
{
this
.
_onActiveInstanceChanged
.
fire
();
// TODO: If this method is being kept this should only fire when the tab is actually changed
this
.
_onActiveTabChanged
.
fire
();
}
}
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts
浏览文件 @
4dbb1443
...
...
@@ -493,7 +493,7 @@ export class SwitchTerminalInstanceActionItem extends SelectActionItem {
super
(
null
,
action
,
terminalService
.
getTabLabels
(),
terminalService
.
activeTerminalInstanceIndex
,
contextViewService
);
this
.
toDispose
.
push
(
terminalService
.
onInstancesChanged
(
this
.
_updateItems
,
this
));
this
.
toDispose
.
push
(
terminalService
.
onActive
Instance
Changed
(
this
.
_updateItems
,
this
));
this
.
toDispose
.
push
(
terminalService
.
onActive
Tab
Changed
(
this
.
_updateItems
,
this
));
this
.
toDispose
.
push
(
terminalService
.
onInstanceTitleChanged
(
this
.
_updateItems
,
this
));
this
.
toDispose
.
push
(
attachSelectBoxStyler
(
this
.
selectBox
,
themeService
));
}
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
浏览文件 @
4dbb1443
...
...
@@ -202,10 +202,16 @@ export class TerminalInstance implements ITerminalInstance {
* @return The terminal's width if it requires a layout.
*/
private
_evaluateColsAndRows
(
width
:
number
,
height
:
number
):
number
{
// Ignore if dimensions are undefined or 0
if
(
!
width
||
!
height
)
{
return
null
;
}
const
dimension
=
this
.
_getDimension
(
width
,
height
);
if
(
!
dimension
)
{
return
null
;
}
const
font
=
this
.
_configHelper
.
getFont
();
// Because xterm.js converts from CSS pixels to actual pixels through
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalService.ts
浏览文件 @
4dbb1443
...
...
@@ -247,6 +247,7 @@ export class TerminalService extends AbstractTerminalService implements ITermina
public
setContainers
(
panelContainer
:
HTMLElement
,
terminalContainer
:
HTMLElement
):
void
{
this
.
_configHelper
.
panelContainer
=
panelContainer
;
this
.
_terminalContainer
=
terminalContainer
;
this
.
_terminalTabs
.
forEach
(
tab
=>
tab
.
attachToElement
(
this
.
_terminalContainer
));
this
.
_terminalInstances
.
forEach
(
terminalInstance
=>
{
terminalInstance
.
attachToElement
(
this
.
_terminalContainer
);
});
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalTab.ts
浏览文件 @
4dbb1443
...
...
@@ -9,7 +9,7 @@ import { TerminalConfigHelper } from 'vs/workbench/parts/terminal/electron-brows
import
{
IContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
TerminalInstance
}
from
'
vs/workbench/parts/terminal/electron-browser/terminalInstance
'
;
import
Event
,
{
Emitter
,
anyEvent
}
from
'
vs/base/common/event
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
SplitView
,
Orientation
,
IView
}
from
'
vs/base/browser/ui/splitview/splitview
'
;
class
SplitPane
implements
IView
{
...
...
@@ -64,6 +64,7 @@ class SplitPane implements IView {
private
addChild
(
size
:
number
,
orthogonalSize
:
number
,
instance
:
ITerminalInstance
,
index
?:
number
,
needsReattach
?:
boolean
):
void
{
const
child
=
new
SplitPane
(
this
,
orthogonalSize
,
needsReattach
);
child
.
orientation
=
this
.
orientation
;
child
.
instance
=
instance
;
this
.
_splitView
.
addView
(
child
,
size
,
index
);
...
...
@@ -77,6 +78,9 @@ class SplitPane implements IView {
}
public
render
(
container
:
HTMLElement
):
void
{
if
(
!
container
)
{
return
;
}
this
.
_container
=
container
;
console
.
log
(
'
render
'
);
// throw new Error("Method not implemented.");
...
...
@@ -101,17 +105,18 @@ class SplitPane implements IView {
console
.
log
(
'
layout
'
,
size
,
this
.
orthogonalSize
);
if
(
this
.
orientation
===
Orientation
.
VERTICAL
)
{
this
.
instance
.
layout
({
width
:
this
.
_size
,
height
:
this
.
orthogonalSize
});
}
else
{
this
.
instance
.
layout
({
width
:
this
.
orthogonalSize
,
height
:
this
.
_size
});
}
else
{
this
.
instance
.
layout
({
width
:
this
.
_size
,
height
:
this
.
orthogonalSize
});
}
}
public
orthogonalLayout
(
size
:
number
):
void
{
this
.
orthogonalSize
=
size
;
console
.
log
(
'
orthogonalLayout
'
,
this
.
_size
,
this
.
orthogonalSize
);
if
(
this
.
_splitView
)
{
this
.
_splitView
.
layout
(
s
ize
);
this
.
_splitView
.
layout
(
this
.
orthogonalS
ize
);
}
}
}
...
...
@@ -146,12 +151,13 @@ class RootSplitPane extends SplitPane {
}
}
export
class
TerminalTab
implements
ITerminalTab
{
export
class
TerminalTab
extends
Disposable
implements
ITerminalTab
{
private
_terminalInstances
:
ITerminalInstance
[]
=
[];
private
_disposables
:
IDisposable
[]
=
[];
private
_rootSplitPane
:
RootSplitPane
;
private
_splitPanes
:
SplitPane
[]
=
[];
// private _activeInstanceIndex: number;
public
get
terminalInstances
():
ITerminalInstance
[]
{
return
this
.
_terminalInstances
;
}
private
_onDisposed
:
Emitter
<
ITerminalTab
>
;
...
...
@@ -164,6 +170,7 @@ export class TerminalTab implements ITerminalTab {
shellLaunchConfig
:
IShellLaunchConfig
,
@
IInstantiationService
private
_instantiationService
:
IInstantiationService
)
{
super
();
this
.
_onDisposed
=
new
Emitter
<
ITerminalTab
>
();
const
instance
=
this
.
_instantiationService
.
createInstance
(
TerminalInstance
,
...
...
@@ -172,6 +179,7 @@ export class TerminalTab implements ITerminalTab {
undefined
,
shellLaunchConfig
);
this
.
_terminalInstances
.
push
(
instance
);
// this._activeInstanceIndex = 0;
instance
.
addDisposable
(
instance
.
onDisposed
(
instance
=>
this
.
_onInstanceDisposed
(
instance
)));
this
.
_rootSplitPane
=
new
RootSplitPane
();
...
...
@@ -182,6 +190,23 @@ export class TerminalTab implements ITerminalTab {
this
.
_splitPanes
.
push
(
this
.
_rootSplitPane
);
}
public
dispose
():
void
{
super
.
dispose
();
this
.
_terminalInstances
=
[];
}
private
_onInstanceDisposed
(
instance
:
ITerminalInstance
):
void
{
// TODO: Listen for disposed on TerminalService and handle appropriately (remove the tab and its instance from the service)
this
.
_onDisposed
.
fire
(
this
);
this
.
dispose
();
}
public
attachToElement
(
element
:
HTMLElement
):
void
{
this
.
_container
=
element
;
}
public
get
title
():
string
{
let
title
=
this
.
terminalInstances
[
0
].
title
;
for
(
let
i
=
1
;
i
<
this
.
terminalInstances
.
length
;
i
++
)
{
...
...
@@ -191,7 +216,9 @@ export class TerminalTab implements ITerminalTab {
}
public
setVisible
(
visible
:
boolean
):
void
{
this
.
_container
.
style
.
display
=
visible
?
'
block
'
:
'
none
'
;
if
(
this
.
_container
)
{
this
.
_container
.
style
.
display
=
visible
?
'
block
'
:
'
none
'
;
}
// TODO: probably don't need to tell terminal instances about visiblility anymore?
this
.
terminalInstances
.
forEach
(
i
=>
i
.
setVisible
(
visible
));
}
...
...
@@ -211,20 +238,12 @@ export class TerminalTab implements ITerminalTab {
this
.
_rootSplitPane
.
orientation
=
Orientation
.
HORIZONTAL
;
this
.
_rootSplitPane
.
split
(
instance
);
const
pane2
=
new
SplitPane
();
this
.
_splitPanes
.
push
(
pane2
);
}
private
_onInstanceDisposed
(
instance
:
ITerminalInstance
):
void
{
// TODO: Listen for disposed on TerminalService and handle appropriately (remove the tab and its instance from the service)
this
.
_onDisposed
.
fire
(
this
);
this
.
_terminalInstances
=
[];
// const pane2 = new SplitPane();
// this._splitPanes.push(pane2);
}
public
addDisposable
(
disposable
:
IDisposable
):
void
{
this
.
_
disposables
.
push
(
disposable
);
this
.
_
register
(
disposable
);
}
public
layout
(
width
:
number
,
height
:
number
):
void
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录