Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
4f7ef0be
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,发现更多精彩内容 >>
提交
4f7ef0be
编写于
2月 16, 2018
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add commands to resize pane
上级
1a59decd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
151 addition
and
5 deletion
+151
-5
src/vs/workbench/parts/terminal/common/terminal.ts
src/vs/workbench/parts/terminal/common/terminal.ts
+8
-0
src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts
.../parts/terminal/electron-browser/terminal.contribution.ts
+22
-2
src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts
...kbench/parts/terminal/electron-browser/terminalActions.ts
+67
-1
src/vs/workbench/parts/terminal/electron-browser/terminalTab.ts
.../workbench/parts/terminal/electron-browser/terminalTab.ts
+54
-2
未找到文件。
src/vs/workbench/parts/terminal/common/terminal.ts
浏览文件 @
4f7ef0be
...
...
@@ -182,6 +182,13 @@ export interface ITerminalService {
setWorkspaceShellAllowed
(
isAllowed
:
boolean
):
void
;
}
export
const
enum
Direction
{
Left
=
0
,
Right
=
1
,
Up
=
2
,
Down
=
3
}
export
interface
ITerminalTab
{
activeInstance
:
ITerminalInstance
;
terminalInstances
:
ITerminalInstance
[];
...
...
@@ -191,6 +198,7 @@ export interface ITerminalTab {
focusPreviousPane
():
void
;
focusNextPane
():
void
;
resizePane
(
direction
:
Direction
):
void
;
setActiveInstanceByIndex
(
index
:
number
):
void
;
attachToElement
(
element
:
HTMLElement
):
void
;
setVisible
(
visible
:
boolean
):
void
;
...
...
src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts
浏览文件 @
4f7ef0be
...
...
@@ -18,7 +18,7 @@ import { getTerminalDefaultShellUnixLike, getTerminalDefaultShellWindows } from
import
{
IWorkbenchActionRegistry
,
Extensions
as
ActionExtensions
}
from
'
vs/workbench/common/actions
'
;
import
{
KeyCode
,
KeyMod
}
from
'
vs/base/common/keyCodes
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
KillTerminalAction
,
CopyTerminalSelectionAction
,
CreateNewTerminalAction
,
CreateNewInActiveWorkspaceTerminalAction
,
FocusActiveTerminalAction
,
FocusNextTerminalAction
,
FocusPreviousTerminalAction
,
SelectDefaultShellWindowsTerminalAction
,
RunSelectedTextInTerminalAction
,
RunActiveFileInTerminalAction
,
ScrollDownTerminalAction
,
ScrollDownPageTerminalAction
,
ScrollToBottomTerminalAction
,
ScrollUpTerminalAction
,
ScrollUpPageTerminalAction
,
ScrollToTopTerminalAction
,
TerminalPasteAction
,
ToggleTerminalAction
,
ClearTerminalAction
,
AllowWorkspaceShellTerminalCommand
,
DisallowWorkspaceShellTerminalCommand
,
RenameTerminalAction
,
SelectAllTerminalAction
,
FocusTerminalFindWidgetAction
,
HideTerminalFindWidgetAction
,
ShowNextFindTermTerminalFindWidgetAction
,
ShowPreviousFindTermTerminalFindWidgetAction
,
DeleteWordLeftTerminalAction
,
DeleteWordRightTerminalAction
,
QuickOpenActionTermContributor
,
QuickOpenTermAction
,
TERMINAL_PICKER_PREFIX
,
MoveToLineStartTerminalAction
,
MoveToLineEndTerminalAction
,
SplitVerticalTerminalAction
,
FocusPreviousPaneTerminalAction
,
FocusNextPaneTerminalAction
}
from
'
vs/workbench/parts/terminal/electron-browser/terminalActions
'
;
import
{
KillTerminalAction
,
CopyTerminalSelectionAction
,
CreateNewTerminalAction
,
CreateNewInActiveWorkspaceTerminalAction
,
FocusActiveTerminalAction
,
FocusNextTerminalAction
,
FocusPreviousTerminalAction
,
SelectDefaultShellWindowsTerminalAction
,
RunSelectedTextInTerminalAction
,
RunActiveFileInTerminalAction
,
ScrollDownTerminalAction
,
ScrollDownPageTerminalAction
,
ScrollToBottomTerminalAction
,
ScrollUpTerminalAction
,
ScrollUpPageTerminalAction
,
ScrollToTopTerminalAction
,
TerminalPasteAction
,
ToggleTerminalAction
,
ClearTerminalAction
,
AllowWorkspaceShellTerminalCommand
,
DisallowWorkspaceShellTerminalCommand
,
RenameTerminalAction
,
SelectAllTerminalAction
,
FocusTerminalFindWidgetAction
,
HideTerminalFindWidgetAction
,
ShowNextFindTermTerminalFindWidgetAction
,
ShowPreviousFindTermTerminalFindWidgetAction
,
DeleteWordLeftTerminalAction
,
DeleteWordRightTerminalAction
,
QuickOpenActionTermContributor
,
QuickOpenTermAction
,
TERMINAL_PICKER_PREFIX
,
MoveToLineStartTerminalAction
,
MoveToLineEndTerminalAction
,
SplitVerticalTerminalAction
,
FocusPreviousPaneTerminalAction
,
FocusNextPaneTerminalAction
,
ResizePaneLeftTerminalAction
,
ResizePaneRightTerminalAction
,
ResizePaneUpTerminalAction
,
ResizePaneDownTerminalAction
}
from
'
vs/workbench/parts/terminal/electron-browser/terminalActions
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
ShowAllCommandsAction
}
from
'
vs/workbench/parts/quickopen/browser/commandsHandler
'
;
import
{
SyncActionDescriptor
}
from
'
vs/platform/actions/common/actions
'
;
...
...
@@ -275,7 +275,11 @@ configurationRegistry.registerConfiguration({
'
workbench.action.quickOpenView
'
,
SplitVerticalTerminalAction
.
ID
,
FocusPreviousPaneTerminalAction
.
ID
,
FocusNextPaneTerminalAction
.
ID
FocusNextPaneTerminalAction
.
ID
,
ResizePaneLeftTerminalAction
.
ID
,
ResizePaneRightTerminalAction
.
ID
,
ResizePaneUpTerminalAction
.
ID
,
ResizePaneDownTerminalAction
.
ID
].
sort
()
},
'
terminal.integrated.env.osx
'
:
{
...
...
@@ -424,6 +428,22 @@ actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(FocusNextPaneTer
primary
:
KeyMod
.
Alt
|
KeyCode
.
RightArrow
,
mac
:
{
primary
:
KeyMod
.
Alt
|
KeyMod
.
CtrlCmd
|
KeyCode
.
RightArrow
}
},
KEYBINDING_CONTEXT_TERMINAL_FOCUS
),
'
Terminal: Focus Next Pane
'
,
category
);
actionRegistry
.
registerWorkbenchAction
(
new
SyncActionDescriptor
(
ResizePaneLeftTerminalAction
,
ResizePaneLeftTerminalAction
.
ID
,
ResizePaneLeftTerminalAction
.
LABEL
,
{
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
Shift
|
KeyCode
.
LeftArrow
,
mac
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
WinCtrl
|
KeyCode
.
LeftArrow
}
},
KEYBINDING_CONTEXT_TERMINAL_FOCUS
),
'
Terminal: Resize Pane Left
'
,
category
);
actionRegistry
.
registerWorkbenchAction
(
new
SyncActionDescriptor
(
ResizePaneRightTerminalAction
,
ResizePaneRightTerminalAction
.
ID
,
ResizePaneRightTerminalAction
.
LABEL
,
{
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
Shift
|
KeyCode
.
RightArrow
,
mac
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
WinCtrl
|
KeyCode
.
RightArrow
}
},
KEYBINDING_CONTEXT_TERMINAL_FOCUS
),
'
Terminal: Resize Pane Right
'
,
category
);
actionRegistry
.
registerWorkbenchAction
(
new
SyncActionDescriptor
(
ResizePaneUpTerminalAction
,
ResizePaneUpTerminalAction
.
ID
,
ResizePaneUpTerminalAction
.
LABEL
,
{
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
Shift
|
KeyCode
.
UpArrow
,
mac
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
WinCtrl
|
KeyCode
.
UpArrow
}
},
KEYBINDING_CONTEXT_TERMINAL_FOCUS
),
'
Terminal: Resize Pane Up
'
,
category
);
actionRegistry
.
registerWorkbenchAction
(
new
SyncActionDescriptor
(
ResizePaneDownTerminalAction
,
ResizePaneDownTerminalAction
.
ID
,
ResizePaneDownTerminalAction
.
LABEL
,
{
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
Shift
|
KeyCode
.
DownArrow
,
mac
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
WinCtrl
|
KeyCode
.
DownArrow
}
},
KEYBINDING_CONTEXT_TERMINAL_FOCUS
),
'
Terminal: Resize Pane Down
'
,
category
);
terminalCommands
.
setup
();
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts
浏览文件 @
4f7ef0be
...
...
@@ -8,7 +8,7 @@ import * as os from 'os';
import
{
Action
,
IAction
}
from
'
vs/base/common/actions
'
;
import
{
EndOfLinePreference
}
from
'
vs/editor/common/model
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
ITerminalService
,
TERMINAL_PANEL_ID
,
ITerminalInstance
}
from
'
vs/workbench/parts/terminal/common/terminal
'
;
import
{
ITerminalService
,
TERMINAL_PANEL_ID
,
ITerminalInstance
,
Direction
}
from
'
vs/workbench/parts/terminal/common/terminal
'
;
import
{
SelectActionItem
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TogglePanelAction
}
from
'
vs/workbench/browser/panel
'
;
...
...
@@ -359,6 +359,72 @@ export class FocusNextPaneTerminalAction extends Action {
}
}
export
abstract
class
BaseFocusDirectionTerminalAction
extends
Action
{
constructor
(
id
:
string
,
label
:
string
,
private
_direction
:
Direction
,
@
ITerminalService
private
readonly
_terminalService
:
ITerminalService
)
{
super
(
id
,
label
);
}
public
run
(
event
?:
any
):
TPromise
<
any
>
{
const
tab
=
this
.
_terminalService
.
getActiveTab
();
if
(
tab
)
{
tab
.
resizePane
(
this
.
_direction
);
}
return
TPromise
.
as
(
void
0
);
}
}
export
class
ResizePaneLeftTerminalAction
extends
BaseFocusDirectionTerminalAction
{
public
static
readonly
ID
=
'
workbench.action.terminal.resizePaneLeft
'
;
public
static
readonly
LABEL
=
nls
.
localize
(
'
workbench.action.terminal.resizePaneLeft
'
,
"
Resize Pane Left
"
);
constructor
(
id
:
string
,
label
:
string
,
@
ITerminalService
readonly
terminalService
:
ITerminalService
)
{
super
(
id
,
label
,
Direction
.
Left
,
terminalService
);
}
}
export
class
ResizePaneRightTerminalAction
extends
BaseFocusDirectionTerminalAction
{
public
static
readonly
ID
=
'
workbench.action.terminal.resizePaneRight
'
;
public
static
readonly
LABEL
=
nls
.
localize
(
'
workbench.action.terminal.resizePaneRight
'
,
"
Resize Pane Right
"
);
constructor
(
id
:
string
,
label
:
string
,
@
ITerminalService
readonly
terminalService
:
ITerminalService
)
{
super
(
id
,
label
,
Direction
.
Right
,
terminalService
);
}
}
export
class
ResizePaneUpTerminalAction
extends
BaseFocusDirectionTerminalAction
{
public
static
readonly
ID
=
'
workbench.action.terminal.resizePaneUp
'
;
public
static
readonly
LABEL
=
nls
.
localize
(
'
workbench.action.terminal.resizePaneUp
'
,
"
Resize Pane Up
"
);
constructor
(
id
:
string
,
label
:
string
,
@
ITerminalService
readonly
terminalService
:
ITerminalService
)
{
super
(
id
,
label
,
Direction
.
Up
,
terminalService
);
}
}
export
class
ResizePaneDownTerminalAction
extends
BaseFocusDirectionTerminalAction
{
public
static
readonly
ID
=
'
workbench.action.terminal.resizePaneDown
'
;
public
static
readonly
LABEL
=
nls
.
localize
(
'
workbench.action.terminal.resizePaneDown
'
,
"
Resize Pane Down
"
);
constructor
(
id
:
string
,
label
:
string
,
@
ITerminalService
readonly
terminalService
:
ITerminalService
)
{
super
(
id
,
label
,
Direction
.
Down
,
terminalService
);
}
}
export
class
FocusActiveTerminalAction
extends
Action
{
public
static
readonly
ID
=
'
workbench.action.terminal.focus
'
;
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalTab.ts
浏览文件 @
4f7ef0be
...
...
@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
ITerminalInstance
,
IShellLaunchConfig
,
ITerminalTab
}
from
'
vs/workbench/parts/terminal/common/terminal
'
;
import
{
ITerminalInstance
,
IShellLaunchConfig
,
ITerminalTab
,
Direction
,
ITerminalService
}
from
'
vs/workbench/parts/terminal/common/terminal
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
TerminalConfigHelper
}
from
'
vs/workbench/parts/terminal/electron-browser/terminalConfigHelper
'
;
import
{
IContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
...
...
@@ -52,6 +52,44 @@ class SplitPaneContainer implements IView {
}
}
public
resizePane
(
index
:
number
,
direction
:
Direction
,
amount
:
number
):
void
{
// TODO: Should resize pane up/down resize the panel?
// Only resize the correct dimension
const
isHorizontal
=
direction
===
Direction
.
Left
||
direction
===
Direction
.
Right
;
if
(
isHorizontal
&&
this
.
orientation
!==
Orientation
.
HORIZONTAL
||
!
isHorizontal
&&
this
.
orientation
!==
Orientation
.
VERTICAL
)
{
return
;
}
// Only resize when there is mor ethan one pane
if
(
this
.
_children
.
length
<=
1
)
{
return
;
}
// Get sizes
const
sizes
=
[];
for
(
let
i
=
0
;
i
<
this
.
_splitView
.
length
;
i
++
)
{
sizes
.
push
(
this
.
_splitView
.
getViewSize
(
i
));
}
// Remove size from right pane, unless index is the last pane in which case use left pane
const
isSizingRightPane
=
index
!==
this
.
_children
.
length
-
1
;
const
indexToChange
=
isSizingRightPane
?
index
+
1
:
index
-
1
;
if
(
isSizingRightPane
&&
direction
===
Direction
.
Left
)
{
amount
*=
-
1
;
}
else
if
(
!
isSizingRightPane
&&
direction
===
Direction
.
Right
)
{
amount
*=
-
1
;
}
sizes
[
index
]
+=
amount
;
sizes
[
indexToChange
]
-=
amount
;
// Apply
for
(
let
i
=
0
;
i
<
this
.
_splitView
.
length
-
1
;
i
++
)
{
this
.
_splitView
.
resizeView
(
i
,
sizes
[
i
]);
}
}
private
_addChild
(
size
:
number
,
instance
:
ITerminalInstance
,
index
:
number
):
void
{
const
child
=
new
SplitPane
(
this
.
_height
);
child
.
orientation
=
this
.
orientation
;
...
...
@@ -181,7 +219,8 @@ export class TerminalTab extends Disposable implements ITerminalTab {
configHelper
:
TerminalConfigHelper
,
private
_container
:
HTMLElement
,
shellLaunchConfig
:
IShellLaunchConfig
,
@
IInstantiationService
private
readonly
_instantiationService
:
IInstantiationService
@
IInstantiationService
private
readonly
_instantiationService
:
IInstantiationService
,
@
ITerminalService
private
readonly
_terminalService
:
ITerminalService
)
{
super
();
this
.
_onDisposed
=
new
Emitter
<
ITerminalTab
>
();
...
...
@@ -349,4 +388,17 @@ export class TerminalTab extends Disposable implements ITerminalTab {
public
focusNextPane
():
void
{
this
.
setActiveInstanceByIndex
(
this
.
_activeInstanceIndex
+
1
);
}
public
resizePane
(
direction
:
Direction
):
void
{
if
(
!
this
.
_splitPaneContainer
)
{
return
;
}
const
isHorizontal
=
(
direction
===
Direction
.
Left
||
direction
===
Direction
.
Right
);
const
font
=
this
.
_terminalService
.
configHelper
.
getFont
();
const
amount
=
isHorizontal
?
font
.
charWidth
:
font
.
charHeight
;
if
(
amount
)
{
this
.
_splitPaneContainer
.
resizePane
(
this
.
_activeInstanceIndex
,
direction
,
amount
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录