Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
9a50d1aa
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,发现更多精彩内容 >>
提交
9a50d1aa
编写于
6月 10, 2016
作者:
D
Daniel Imms
提交者:
GitHub
6月 10, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7503 from Microsoft/6458_multiple_terminals
Add multiple terminals
上级
8fd51f85
75fc2ac8
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
122 addition
and
21 deletion
+122
-21
src/vs/workbench/parts/terminal/electron-browser/media/terminal.contribution.css
...terminal/electron-browser/media/terminal.contribution.css
+8
-0
src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts
.../parts/terminal/electron-browser/terminal.contribution.ts
+10
-2
src/vs/workbench/parts/terminal/electron-browser/terminal.ts
src/vs/workbench/parts/terminal/electron-browser/terminal.ts
+2
-0
src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts
...kbench/parts/terminal/electron-browser/terminalActions.ts
+37
-3
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
...bench/parts/terminal/electron-browser/terminalInstance.ts
+10
-6
src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts
...orkbench/parts/terminal/electron-browser/terminalPanel.ts
+31
-10
src/vs/workbench/parts/terminal/electron-browser/terminalService.ts
...kbench/parts/terminal/electron-browser/terminalService.ts
+24
-0
未找到文件。
src/vs/workbench/parts/terminal/electron-browser/media/terminal.contribution.css
浏览文件 @
9a50d1aa
...
...
@@ -20,6 +20,14 @@
background-color
:
transparent
!important
;
}
.monaco-workbench
.integrated-terminal
.terminal-wrapper
{
display
:
none
;
}
.monaco-workbench
.integrated-terminal
.terminal-wrapper.active
{
display
:
block
;
}
.monaco-workbench
.integrated-terminal
.terminal-cursor
{
background-color
:
#333
;
}
...
...
src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts
浏览文件 @
9a50d1aa
...
...
@@ -10,7 +10,7 @@ import {SyncActionDescriptor} from 'vs/platform/actions/common/actions';
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
IWorkbenchActionRegistry
,
Extensions
as
ActionExtensions
}
from
'
vs/workbench/common/actionRegistry
'
;
import
{
TerminalService
}
from
'
vs/workbench/parts/terminal/electron-browser/terminalService
'
;
import
{
FocusTerminalAction
,
ToggleTerminalAction
}
from
'
vs/workbench/parts/terminal/electron-browser/terminalActions
'
;
import
{
CloseTerminalAction
,
CreateNewTerminalAction
,
FocusTerminalAction
,
ToggleTerminalAction
}
from
'
vs/workbench/parts/terminal/electron-browser/terminalActions
'
;
import
{
ITerminalService
,
TERMINAL_PANEL_ID
,
TERMINAL_DEFAULT_SHELL_LINUX
,
TERMINAL_DEFAULT_SHELL_OSX
,
TERMINAL_DEFAULT_SHELL_WINDOWS
}
from
'
vs/workbench/parts/terminal/electron-browser/terminal
'
;
import
*
as
panel
from
'
vs/workbench/browser/panel
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
...
...
@@ -89,10 +89,18 @@ registerSingleton(ITerminalService, TerminalService);
'
terminal
'
));
// On mac cmd+` is reserved to cycle between windows, that's why the keybindings use WinCtrl
let
actionRegistry
=
<
IWorkbenchActionRegistry
>
Registry
.
as
(
ActionExtensions
.
WorkbenchActions
);
actionRegistry
.
registerWorkbenchAction
(
new
SyncActionDescriptor
(
ToggleTerminalAction
,
ToggleTerminalAction
.
ID
,
ToggleTerminalAction
.
LABEL
,
{
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
US_BACKTICK
,
// on mac cmd+` is reserved to cycle between windows
mac
:
{
primary
:
KeyMod
.
WinCtrl
|
KeyCode
.
US_BACKTICK
}
}),
'
View:
'
+
ToggleTerminalAction
.
LABEL
,
nls
.
localize
(
'
viewCategory
'
,
"
View
"
));
actionRegistry
.
registerWorkbenchAction
(
new
SyncActionDescriptor
(
FocusTerminalAction
,
FocusTerminalAction
.
ID
,
FocusTerminalAction
.
LABEL
),
FocusTerminalAction
.
LABEL
);
actionRegistry
.
registerWorkbenchAction
(
new
SyncActionDescriptor
(
CreateNewTerminalAction
,
CreateNewTerminalAction
.
ID
,
CreateNewTerminalAction
.
LABEL
,
{
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
Shift
|
KeyCode
.
US_BACKTICK
,
mac
:
{
primary
:
KeyMod
.
WinCtrl
|
KeyMod
.
Shift
|
KeyCode
.
US_BACKTICK
}
}),
CreateNewTerminalAction
.
LABEL
);
actionRegistry
.
registerWorkbenchAction
(
new
SyncActionDescriptor
(
CloseTerminalAction
,
CloseTerminalAction
.
ID
,
CloseTerminalAction
.
LABEL
,
{
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
Shift
|
KeyCode
.
KEY_X
,
mac
:
{
primary
:
KeyMod
.
WinCtrl
|
KeyMod
.
Shift
|
KeyCode
.
KEY_X
}
}),
CloseTerminalAction
.
LABEL
);
src/vs/workbench/parts/terminal/electron-browser/terminal.ts
浏览文件 @
9a50d1aa
...
...
@@ -42,6 +42,8 @@ export interface ITerminalConfiguration {
export
interface
ITerminalService
{
serviceId
:
ServiceIdentifier
<
any
>
;
close
():
TPromise
<
any
>
;
createNew
():
TPromise
<
any
>
;
focus
():
TPromise
<
any
>
;
toggle
():
TPromise
<
any
>
;
}
src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts
浏览文件 @
9a50d1aa
...
...
@@ -10,8 +10,8 @@ import {ITerminalService} from 'vs/workbench/parts/terminal/electron-browser/ter
export
class
ToggleTerminalAction
extends
Action
{
public
static
ID
=
'
workbench.action.terminal.toggle
Terminal
'
;
public
static
LABEL
=
nls
.
localize
(
'
toggleTerminal
'
,
"
Toggle Integrated Terminal
"
);
public
static
ID
=
'
workbench.action.terminal.toggle
'
;
public
static
LABEL
=
nls
.
localize
(
'
workbench.action.terminal.toggle
'
,
"
Toggle Integrated Terminal
"
);
constructor
(
id
:
string
,
label
:
string
,
...
...
@@ -25,10 +25,44 @@ export class ToggleTerminalAction extends Action {
}
}
export
class
CloseTerminalAction
extends
Action
{
public
static
ID
=
'
workbench.action.terminal.close
'
;
public
static
LABEL
=
nls
.
localize
(
'
workbench.action.terminal.close
'
,
"
Terminal: Close the current terminal
"
);
constructor
(
id
:
string
,
label
:
string
,
@
ITerminalService
private
terminalService
:
ITerminalService
)
{
super
(
id
,
label
);
}
public
run
(
event
?:
any
):
TPromise
<
any
>
{
return
this
.
terminalService
.
close
();
}
}
export
class
CreateNewTerminalAction
extends
Action
{
public
static
ID
=
'
workbench.action.terminal.new
'
;
public
static
LABEL
=
nls
.
localize
(
'
workbench.action.terminal.new
'
,
"
Terminal: Create New Integrated Terminal
"
);
constructor
(
id
:
string
,
label
:
string
,
@
ITerminalService
private
terminalService
:
ITerminalService
)
{
super
(
id
,
label
);
}
public
run
(
event
?:
any
):
TPromise
<
any
>
{
return
this
.
terminalService
.
createNew
();
}
}
export
class
FocusTerminalAction
extends
Action
{
public
static
ID
=
'
workbench.action.terminal.focus
'
;
public
static
LABEL
=
nls
.
localize
(
'
focusTerminal
'
,
"
Focus Integrated
Terminal
"
);
public
static
LABEL
=
nls
.
localize
(
'
workbench.action.terminal.focus
'
,
"
Terminal: Focus
Terminal
"
);
constructor
(
id
:
string
,
label
:
string
,
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
浏览文件 @
9a50d1aa
...
...
@@ -37,6 +37,7 @@ export class TerminalInstance {
)
{
this
.
toDispose
=
[];
this
.
wrapperElement
=
document
.
createElement
(
'
div
'
);
this
.
wrapperElement
.
classList
.
add
(
'
terminal-wrapper
'
);
this
.
ptyProcess
=
this
.
createTerminalProcess
();
this
.
terminalDomElement
=
document
.
createElement
(
'
div
'
);
this
.
parentDomElement
.
classList
.
add
(
'
integrated-terminal
'
);
...
...
@@ -62,10 +63,7 @@ export class TerminalInstance {
});
this
.
ptyProcess
.
on
(
'
exit
'
,
(
exitCode
)
=>
{
this
.
dispose
();
// TODO: When multiple terminals are supported this should do something smarter. There is
// also a weird bug here at least on Ubuntu 15.10 where the new terminal text does not
// repaint correctly.
if
(
exitCode
!==
0
)
{
if
(
exitCode
)
{
console
.
error
(
'
Integrated terminal exited with code
'
+
exitCode
);
}
this
.
onExitCallback
(
this
);
...
...
@@ -137,6 +135,10 @@ export class TerminalInstance {
});
}
public
toggleVisibility
(
visible
:
boolean
)
{
this
.
wrapperElement
.
classList
.
toggle
(
'
active
'
,
visible
);
}
public
setFont
(
font
:
ITerminalFont
):
void
{
this
.
font
=
font
;
this
.
terminalDomElement
.
style
.
fontFamily
=
this
.
font
.
fontFamily
;
...
...
@@ -162,8 +164,10 @@ export class TerminalInstance {
}
public
dispose
():
void
{
this
.
parentDomElement
.
removeChild
(
this
.
wrapperElement
);
this
.
wrapperElement
=
null
;
if
(
this
.
wrapperElement
)
{
this
.
parentDomElement
.
removeChild
(
this
.
wrapperElement
);
this
.
wrapperElement
=
null
;
}
this
.
toDispose
=
lifecycle
.
dispose
(
this
.
toDispose
);
this
.
terminal
.
destroy
();
this
.
ptyProcess
.
kill
();
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts
浏览文件 @
9a50d1aa
...
...
@@ -50,12 +50,25 @@ export class TerminalPanel extends Panel {
this
.
parentDomElement
.
appendChild
(
this
.
themeStyleElement
);
this
.
configurationHelper
=
new
TerminalConfigHelper
(
platform
.
platform
,
this
.
configurationService
,
this
.
parentDomElement
);
this
.
toDispose
.
push
(
DOM
.
addDisposableListener
(
this
.
parentDomElement
,
'
wheel
'
,
(
event
:
WheelEvent
)
=>
{
this
.
terminalInstances
[
0
].
dispatchEvent
(
new
WheelEvent
(
event
.
type
,
event
));
this
.
terminalInstances
[
this
.
activeTerminalIndex
].
dispatchEvent
(
new
WheelEvent
(
event
.
type
,
event
));
}));
return
this
.
createTerminal
();
}
public
createNewTerminalInstance
():
TPromise
<
void
>
{
return
this
.
createTerminal
().
then
(()
=>
{
this
.
updateFont
();
this
.
focus
();
});
}
public
closeActiveTerminal
():
TPromise
<
void
>
{
return
new
TPromise
<
void
>
(
resolve
=>
{
this
.
onTerminalInstanceExit
(
this
.
terminalInstances
[
this
.
activeTerminalIndex
]);
});
}
public
setVisible
(
visible
:
boolean
):
TPromise
<
void
>
{
if
(
visible
)
{
if
(
this
.
terminalInstances
.
length
>
0
)
{
...
...
@@ -76,31 +89,39 @@ export class TerminalPanel extends Panel {
private
createTerminal
():
TPromise
<
void
>
{
return
new
TPromise
<
void
>
(
resolve
=>
{
this
.
terminalInstances
.
push
(
new
TerminalInstance
(
this
.
configurationHelper
.
getShell
(),
this
.
parentDomElement
,
this
.
contextService
,
this
.
terminalService
,
this
.
onTerminalInstanceExit
.
bind
(
this
)));
this
.
activeTerminalIndex
=
this
.
terminalInstances
.
length
-
1
;
this
.
setActiveTerminal
(
this
.
terminalInstances
.
length
-
1
)
;
this
.
toDispose
.
push
(
this
.
themeService
.
onDidThemeChange
(
this
.
updateTheme
.
bind
(
this
)));
this
.
toDispose
.
push
(
this
.
configurationService
.
onDidUpdateConfiguration
(
this
.
updateFont
.
bind
(
this
)));
resolve
(
void
0
);
});
}
private
setActiveTerminal
(
index
:
number
)
{
this
.
activeTerminalIndex
=
index
;
this
.
terminalInstances
.
forEach
((
terminalInstance
,
i
)
=>
{
terminalInstance
.
toggleVisibility
(
i
===
this
.
activeTerminalIndex
);
});
}
private
onTerminalInstanceExit
(
terminalInstance
:
TerminalInstance
):
void
{
for
(
var
i
=
0
;
i
<
this
.
terminalInstances
.
length
;
i
++
)
{
if
(
this
.
terminalInstances
[
i
]
===
terminalInstance
)
{
if
(
this
.
activeTerminalIndex
===
i
)
{
this
.
activeTerminalIndex
=
-
1
;
}
else
if
(
this
.
activeTerminalIndex
>
i
)
{
if
(
this
.
activeTerminalIndex
>
i
)
{
this
.
activeTerminalIndex
--
;
}
this
.
terminalInstances
.
splice
(
i
,
1
);
let
killedTerminal
=
this
.
terminalInstances
.
splice
(
i
,
1
)[
0
];
killedTerminal
.
dispose
();
}
}
this
.
terminalService
.
toggle
();
if
(
this
.
terminalInstances
.
length
===
0
)
{
this
.
activeTerminalIndex
=
-
1
;
this
.
terminalService
.
toggle
();
}
else
{
this
.
setActiveTerminal
(
Math
.
min
(
this
.
activeTerminalIndex
,
this
.
terminalInstances
.
length
-
1
));
}
}
private
updateTheme
(
themeId
?:
string
):
void
{
if
(
this
.
terminalInstances
.
length
===
0
)
{
return
;
}
if
(
!
themeId
)
{
themeId
=
this
.
themeService
.
getTheme
();
}
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalService.ts
浏览文件 @
9a50d1aa
...
...
@@ -7,6 +7,7 @@ import {TPromise} from 'vs/base/common/winjs.base';
import
{
IPanelService
}
from
'
vs/workbench/services/panel/common/panelService
'
;
import
{
IPartService
}
from
'
vs/workbench/services/part/common/partService
'
;
import
{
ITerminalService
,
TERMINAL_PANEL_ID
}
from
'
vs/workbench/parts/terminal/electron-browser/terminal
'
;
import
{
TerminalPanel
}
from
'
vs/workbench/parts/terminal/electron-browser/terminalPanel
'
;
export
class
TerminalService
implements
ITerminalService
{
public
serviceId
=
ITerminalService
;
...
...
@@ -31,4 +32,27 @@ export class TerminalService implements ITerminalService {
return
this
.
panelService
.
openPanel
(
TERMINAL_PANEL_ID
,
true
);
}
public
createNew
():
TPromise
<
any
>
{
let
panel
=
this
.
panelService
.
getActivePanel
();
if
(
!
panel
||
panel
.
getId
()
!==
TERMINAL_PANEL_ID
)
{
return
this
.
toggle
().
then
(()
=>
{
panel
=
this
.
panelService
.
getActivePanel
();
return
(
<
TerminalPanel
>
panel
).
createNewTerminalInstance
();
});
}
return
(
<
TerminalPanel
>
panel
).
createNewTerminalInstance
();
}
public
close
():
TPromise
<
any
>
{
// TODO: Refactor to share code with createNew
let
panel
=
this
.
panelService
.
getActivePanel
();
if
(
!
panel
||
panel
.
getId
()
!==
TERMINAL_PANEL_ID
)
{
return
this
.
toggle
().
then
(()
=>
{
panel
=
this
.
panelService
.
getActivePanel
();
return
(
<
TerminalPanel
>
panel
).
closeActiveTerminal
();
});
}
return
(
<
TerminalPanel
>
panel
).
closeActiveTerminal
();
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录