Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
339e2f02
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,发现更多精彩内容 >>
提交
339e2f02
编写于
7月 18, 2017
作者:
T
t-amqi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add terminal quick picker
上级
81813b2c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
152 addition
and
0 deletion
+152
-0
src/vs/workbench/parts/terminal/browser/terminalQuickOpen.ts
src/vs/workbench/parts/terminal/browser/terminalQuickOpen.ts
+137
-0
src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts
.../parts/terminal/electron-browser/terminal.contribution.ts
+15
-0
未找到文件。
src/vs/workbench/parts/terminal/browser/terminalQuickOpen.ts
0 → 100644
浏览文件 @
339e2f02
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
nls
=
require
(
'
vs/nls
'
);
import
errors
=
require
(
'
vs/base/common/errors
'
);
import
strings
=
require
(
'
vs/base/common/strings
'
);
import
scorer
=
require
(
'
vs/base/common/scorer
'
);
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Mode
,
IEntryRunContext
,
IAutoFocus
,
IQuickNavigateConfiguration
,
IModel
}
from
'
vs/base/parts/quickopen/common/quickOpen
'
;
import
{
QuickOpenModel
,
QuickOpenEntryGroup
,
QuickOpenEntry
}
from
'
vs/base/parts/quickopen/browser/quickOpenModel
'
;
import
{
QuickOpenHandler
}
from
'
vs/workbench/browser/quickopen
'
;
import
{
ITerminalService
}
from
'
vs/workbench/parts/terminal/common/terminal
'
;
import
{
IPanelService
}
from
'
vs/workbench/services/panel/common/panelService
'
;
export
const
TERMINAL_PICKER_PREFIX
=
'
term
'
;
export
class
TerminalEntry
extends
QuickOpenEntryGroup
{
constructor
(
private
label
:
string
,
private
category
:
string
,
private
open
:
()
=>
void
)
{
super
();
}
public
getLabel
():
string
{
return
this
.
label
;
}
public
getCategory
():
string
{
return
this
.
category
;
}
public
getAriaLabel
():
string
{
return
nls
.
localize
(
'
entryAriaLabel
'
,
"
{0}, terminal picker
"
,
this
.
getLabel
());
}
public
run
(
mode
:
Mode
,
context
:
IEntryRunContext
):
boolean
{
if
(
mode
===
Mode
.
OPEN
)
{
return
this
.
runOpen
(
context
);
}
return
super
.
run
(
mode
,
context
);
}
private
runOpen
(
context
:
IEntryRunContext
):
boolean
{
setTimeout
(()
=>
{
this
.
open
();
},
0
);
return
true
;
}
}
export
class
TerminalPickerHandler
extends
QuickOpenHandler
{
constructor
(
@
ITerminalService
private
terminalService
:
ITerminalService
,
@
IPanelService
private
panelService
:
IPanelService
)
{
super
();
}
public
getResults
(
searchValue
:
string
):
TPromise
<
QuickOpenModel
>
{
searchValue
=
searchValue
.
trim
();
const
normalizedSearchValueLowercase
=
strings
.
stripWildcards
(
searchValue
).
toLowerCase
();
const
terminalEntries
=
this
.
getTerminals
();
const
entries
=
terminalEntries
.
filter
(
e
=>
{
if
(
!
searchValue
)
{
return
true
;
}
if
(
!
scorer
.
matches
(
e
.
getLabel
(),
normalizedSearchValueLowercase
)
&&
!
scorer
.
matches
(
e
.
getCategory
(),
normalizedSearchValueLowercase
))
{
return
false
;
}
const
{
labelHighlights
,
descriptionHighlights
}
=
QuickOpenEntry
.
highlight
(
e
,
searchValue
);
e
.
setHighlights
(
labelHighlights
,
descriptionHighlights
);
return
true
;
});
let
lastCategory
:
string
;
entries
.
forEach
((
e
,
index
)
=>
{
if
(
lastCategory
!==
e
.
getCategory
())
{
lastCategory
=
e
.
getCategory
();
e
.
setShowBorder
(
index
>
0
);
e
.
setGroupLabel
(
lastCategory
);
}
else
{
e
.
setShowBorder
(
false
);
e
.
setGroupLabel
(
void
0
);
}
});
return
TPromise
.
as
(
new
QuickOpenModel
(
entries
));
}
private
getTerminals
():
TerminalEntry
[]
{
const
termninalEntries
:
TerminalEntry
[]
=
[];
const
taskEntries
:
TerminalEntry
[]
=
[];
const
terminals
=
this
.
terminalService
.
terminalInstances
;
terminals
.
forEach
((
terminal
,
index
)
=>
{
const
terminalsCategory
=
nls
.
localize
(
'
terminals
'
,
"
Terminal
"
);
const
taskCategory
=
nls
.
localize
(
'
task
'
,
"
Task
"
);
if
(
terminal
.
title
.
indexOf
(
'
Task
'
)
>=
0
)
{
taskEntries
.
push
(
new
TerminalEntry
(
nls
.
localize
(
'
terminalTitle
'
,
"
{0}: {1}
"
,
index
+
1
,
terminal
.
title
),
taskCategory
,
()
=>
{
this
.
terminalService
.
showPanel
(
true
).
done
(()
=>
{
this
.
terminalService
.
setActiveInstance
(
terminal
);
},
errors
.
onUnexpectedError
);
}));
}
else
{
termninalEntries
.
push
(
new
TerminalEntry
(
nls
.
localize
(
'
terminalTitle
'
,
"
{0}: {1}
"
,
index
+
1
,
terminal
.
title
),
terminalsCategory
,
()
=>
{
this
.
terminalService
.
showPanel
(
true
).
done
(()
=>
{
this
.
terminalService
.
setActiveInstance
(
terminal
);
},
errors
.
onUnexpectedError
);
}));
}
});
return
termninalEntries
.
concat
(
taskEntries
);
}
public
getAutoFocus
(
searchValue
:
string
,
context
:
{
model
:
IModel
<
QuickOpenEntry
>
,
quickNavigateConfiguration
?:
IQuickNavigateConfiguration
}):
IAutoFocus
{
return
{
autoFocusFirstEntry
:
!!
searchValue
||
!!
context
.
quickNavigateConfiguration
};
}
}
\ No newline at end of file
src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts
浏览文件 @
339e2f02
...
...
@@ -7,6 +7,7 @@ import 'vs/css!./media/scrollbar';
import
'
vs/css!./media/terminal
'
;
import
'
vs/css!./media/xterm
'
;
import
'
vs/css!./media/widgets
'
;
import
'
vs/workbench/parts/terminal/browser/terminalQuickOpen
'
;
import
*
as
debugActions
from
'
vs/workbench/parts/debug/browser/debugActions
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
*
as
panel
from
'
vs/workbench/browser/panel
'
;
...
...
@@ -30,6 +31,19 @@ import { EDITOR_FONT_DEFAULTS } from 'vs/editor/common/config/editorOptions';
import
{
registerColors
}
from
'
./terminalColorRegistry
'
;
import
{
NavigateUpAction
,
NavigateDownAction
,
NavigateLeftAction
,
NavigateRightAction
}
from
"
vs/workbench/electron-browser/actions
"
;
import
{
QUICKOPEN_ACTION_ID
}
from
"
vs/workbench/browser/parts/quickopen/quickopen
"
;
import
{
IQuickOpenRegistry
,
Extensions
as
QuickOpenExtensions
,
QuickOpenHandlerDescriptor
}
from
'
vs/workbench/browser/quickopen
'
;
const
quickOpenRegistry
=
(
<
IQuickOpenRegistry
>
Registry
.
as
(
QuickOpenExtensions
.
Quickopen
));
quickOpenRegistry
.
registerQuickOpenHandler
(
new
QuickOpenHandlerDescriptor
(
'
vs/workbench/parts/terminal/browser/terminalQuickOpen
'
,
'
TerminalPickerHandler
'
,
'
term
'
,
'
inTerminalPicker
'
,
nls
.
localize
(
'
quickOpen.terminal
'
,
"
Quickpick Terminal
"
)
)
);
let
configurationRegistry
=
<
IConfigurationRegistry
>
Registry
.
as
(
Extensions
.
Configuration
);
configurationRegistry
.
registerConfiguration
({
...
...
@@ -317,3 +331,4 @@ actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(DeleteWordRightT
mac
:
{
primary
:
KeyMod
.
Alt
|
KeyCode
.
Delete
}
},
KEYBINDING_CONTEXT_TERMINAL_FOCUS
),
'
Terminal: Delete Word After Cursor
'
,
category
);
registerColors
();
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录