Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
7493a604
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,发现更多精彩内容 >>
未验证
提交
7493a604
编写于
12月 31, 2019
作者:
D
Daniel Imms
提交者:
GitHub
12月 31, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #83620 from jmbockhorst/followLink
Make terminal link behavior consistent with the editor
上级
13098717
6f20f227
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
76 addition
and
26 deletion
+76
-26
src/vs/workbench/contrib/terminal/browser/media/widgets.css
src/vs/workbench/contrib/terminal/browser/media/widgets.css
+10
-3
src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
...vs/workbench/contrib/terminal/browser/terminalInstance.ts
+4
-2
src/vs/workbench/contrib/terminal/browser/terminalLinkHandler.ts
...workbench/contrib/terminal/browser/terminalLinkHandler.ts
+20
-9
src/vs/workbench/contrib/terminal/browser/terminalWidgetManager.ts
...rkbench/contrib/terminal/browser/terminalWidgetManager.ts
+42
-12
未找到文件。
src/vs/workbench/contrib/terminal/browser/media/widgets.css
浏览文件 @
7493a604
...
...
@@ -8,15 +8,22 @@
left
:
0
;
right
:
0
;
bottom
:
0
;
pointer-events
:
none
;
}
.monaco-workbench
.terminal-message-widget
{
font-size
:
12px
;
line-height
:
19px
;
padding
:
4px
5
px
;
padding
:
4px
8
px
;
animation
:
fadein
100ms
linear
;
white-space
:
nowrap
;
/* Must be drawn on the top of the terminal's canvases */
z-index
:
20
;
}
\ No newline at end of file
}
.monaco-workbench
.terminal-message-widget
p
{
margin
:
0px
;
}
.monaco-workbench
.terminal-message-widget
a
{
color
:
#3794ff
;
}
src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
浏览文件 @
7493a604
...
...
@@ -39,6 +39,7 @@ import { CommandTrackerAddon } from 'vs/workbench/contrib/terminal/browser/addon
import
{
NavigationModeAddon
}
from
'
vs/workbench/contrib/terminal/browser/addons/navigationModeAddon
'
;
import
{
XTermCore
}
from
'
vs/workbench/contrib/terminal/browser/xterm-private
'
;
import
{
IEditorOptions
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
// How long in milliseconds should an average frame take to render for a notification to appear
// which suggests the fallback DOM-based renderer
...
...
@@ -286,7 +287,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
@
IConfigurationService
private
readonly
_configurationService
:
IConfigurationService
,
@
ILogService
private
readonly
_logService
:
ILogService
,
@
IStorageService
private
readonly
_storageService
:
IStorageService
,
@
IAccessibilityService
private
readonly
_accessibilityService
:
IAccessibilityService
@
IAccessibilityService
private
readonly
_accessibilityService
:
IAccessibilityService
,
@
IOpenerService
private
readonly
_openerService
:
IOpenerService
)
{
super
();
...
...
@@ -666,7 +668,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this
.
_refreshSelectionContextKey
();
}));
const
widgetManager
=
new
TerminalWidgetManager
(
this
.
_wrapperElement
);
const
widgetManager
=
new
TerminalWidgetManager
(
this
.
_wrapperElement
,
this
.
_openerService
);
this
.
_widgetManager
=
widgetManager
;
this
.
_processManager
.
onProcessReady
(()
=>
this
.
_linkHandler
?.
setWidgetManager
(
widgetManager
));
...
...
src/vs/workbench/contrib/terminal/browser/terminalLinkHandler.ts
浏览文件 @
7493a604
...
...
@@ -18,6 +18,7 @@ import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts';
import
{
posix
,
win32
}
from
'
vs/base/common/path
'
;
import
{
ITerminalInstanceService
}
from
'
vs/workbench/contrib/terminal/browser/terminal
'
;
import
{
OperatingSystem
,
isMacintosh
}
from
'
vs/base/common/platform
'
;
import
{
IMarkdownString
,
MarkdownString
}
from
'
vs/base/common/htmlContent
'
;
const
pathPrefix
=
'
(
\\
.
\\
.?|
\\
~)
'
;
const
pathSeparatorClause
=
'
\\
/
'
;
...
...
@@ -116,7 +117,7 @@ export class TerminalLinkHandler {
const
leftPosition
=
location
.
start
.
x
*
(
charWidth
!
+
(
font
.
letterSpacing
/
window
.
devicePixelRatio
));
const
bottomPosition
=
offsetRow
*
(
Math
.
ceil
(
charHeight
!
*
window
.
devicePixelRatio
)
*
font
.
lineHeight
)
/
window
.
devicePixelRatio
;
this
.
_widgetManager
.
showMessage
(
leftPosition
,
bottomPosition
,
this
.
_getLinkHoverString
(),
verticalAlignment
);
this
.
_widgetManager
.
showMessage
(
leftPosition
,
bottomPosition
,
this
.
_getLinkHoverString
(
uri
),
verticalAlignment
);
}
else
{
const
target
=
(
e
.
target
as
HTMLElement
);
const
colWidth
=
target
.
offsetWidth
/
this
.
_xterm
.
cols
;
...
...
@@ -124,7 +125,7 @@ export class TerminalLinkHandler {
const
leftPosition
=
location
.
start
.
x
*
colWidth
;
const
bottomPosition
=
offsetRow
*
rowHeight
;
this
.
_widgetManager
.
showMessage
(
leftPosition
,
bottomPosition
,
this
.
_getLinkHoverString
(),
verticalAlignment
);
this
.
_widgetManager
.
showMessage
(
leftPosition
,
bottomPosition
,
this
.
_getLinkHoverString
(
uri
),
verticalAlignment
);
}
};
this
.
_leaveCallback
=
()
=>
{
...
...
@@ -277,19 +278,29 @@ export class TerminalLinkHandler {
return
isMacintosh
?
event
.
metaKey
:
event
.
ctrlKey
;
}
private
_getLinkHoverString
(
):
s
tring
{
private
_getLinkHoverString
(
uri
:
string
):
IMarkdownS
tring
{
const
editorConf
=
this
.
_configurationService
.
getValue
<
{
multiCursorModifier
:
'
ctrlCmd
'
|
'
alt
'
}
>
(
'
editor
'
);
let
label
=
''
;
if
(
editorConf
.
multiCursorModifier
===
'
ctrlCmd
'
)
{
if
(
isMacintosh
)
{
return
nls
.
localize
(
'
terminalLinkHandler.followLinkAlt.mac
'
,
"
Option + click to follow lin
k
"
);
label
=
nls
.
localize
(
'
terminalLinkHandler.followLinkAlt.mac
'
,
"
Option + clic
k
"
);
}
else
{
return
nls
.
localize
(
'
terminalLinkHandler.followLinkAlt
'
,
"
Alt + click to follow link
"
);
label
=
nls
.
localize
(
'
terminalLinkHandler.followLinkAlt
'
,
"
Alt + click
"
);
}
}
else
{
if
(
isMacintosh
)
{
label
=
nls
.
localize
(
'
terminalLinkHandler.followLinkCmd
'
,
"
Cmd + click
"
);
}
else
{
label
=
nls
.
localize
(
'
terminalLinkHandler.followLinkCtrl
'
,
"
Ctrl + click
"
);
}
}
if
(
isMacintosh
)
{
return
nls
.
localize
(
'
terminalLinkHandler.followLinkCmd
'
,
"
Cmd + click to follow link
"
);
}
return
nls
.
localize
(
'
terminalLinkHandler.followLinkCtrl
'
,
"
Ctrl + click to follow link
"
);
const
message
:
IMarkdownString
=
new
MarkdownString
(
`[Follow Link](
${
uri
}
) (
${
label
}
)`
,
true
);
message
.
uris
=
{
[
uri
]:
URI
.
parse
(
uri
).
toJSON
()
};
return
message
;
}
private
get
osPath
():
IPath
{
...
...
src/vs/workbench/contrib/terminal/browser/terminalWidgetManager.ts
浏览文件 @
7493a604
...
...
@@ -4,6 +4,10 @@
*--------------------------------------------------------------------------------------------*/
import
{
IDisposable
,
dispose
,
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
import
{
IMarkdownString
}
from
'
vs/base/common/htmlContent
'
;
import
{
renderMarkdown
}
from
'
vs/base/browser/markdownRenderer
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
export
enum
WidgetVerticalAlignment
{
Bottom
,
...
...
@@ -20,7 +24,8 @@ export class TerminalWidgetManager implements IDisposable {
private
readonly
_messageListeners
=
new
DisposableStore
();
constructor
(
terminalWrapper
:
HTMLElement
terminalWrapper
:
HTMLElement
,
private
readonly
_openerService
:
IOpenerService
)
{
this
.
_container
=
document
.
createElement
(
'
div
'
);
this
.
_container
.
classList
.
add
(
'
terminal-widget-overlay
'
);
...
...
@@ -48,20 +53,22 @@ export class TerminalWidgetManager implements IDisposable {
mutationObserver
.
observe
(
this
.
_xtermViewport
,
{
attributes
:
true
,
attributeFilter
:
[
'
style
'
]
});
}
public
showMessage
(
left
:
number
,
y
:
number
,
text
:
s
tring
,
verticalAlignment
:
WidgetVerticalAlignment
=
WidgetVerticalAlignment
.
Bottom
):
void
{
public
showMessage
(
left
:
number
,
y
:
number
,
text
:
IMarkdownS
tring
,
verticalAlignment
:
WidgetVerticalAlignment
=
WidgetVerticalAlignment
.
Bottom
):
void
{
if
(
!
this
.
_container
)
{
return
;
}
dispose
(
this
.
_messageWidget
);
this
.
_messageListeners
.
clear
();
this
.
_messageWidget
=
new
MessageWidget
(
this
.
_container
,
left
,
y
,
text
,
verticalAlignment
);
this
.
_messageWidget
=
new
MessageWidget
(
this
.
_container
,
left
,
y
,
text
,
verticalAlignment
,
this
.
_openerService
);
}
public
closeMessage
():
void
{
this
.
_messageListeners
.
clear
();
if
(
this
.
_messageWidget
)
{
this
.
_messageListeners
.
add
(
MessageWidget
.
fadeOut
(
this
.
_messageWidget
));
}
setTimeout
(()
=>
{
if
(
this
.
_messageWidget
&&
!
this
.
_messageWidget
.
mouseOver
)
{
this
.
_messageListeners
.
add
(
MessageWidget
.
fadeOut
(
this
.
_messageWidget
));
}
},
50
);
}
private
_refreshHeight
():
void
{
...
...
@@ -73,13 +80,16 @@ export class TerminalWidgetManager implements IDisposable {
}
class
MessageWidget
{
private
_domNode
:
HTMLDivElement
;
private
_domNode
:
HTMLElement
;
private
_mouseOver
=
false
;
private
readonly
_messageListeners
=
new
DisposableStore
();
public
get
left
():
number
{
return
this
.
_left
;
}
public
get
y
():
number
{
return
this
.
_y
;
}
public
get
text
():
s
tring
{
return
this
.
_text
;
}
public
get
text
():
IMarkdownS
tring
{
return
this
.
_text
;
}
public
get
domNode
():
HTMLElement
{
return
this
.
_domNode
;
}
public
get
verticalAlignment
():
WidgetVerticalAlignment
{
return
this
.
_verticalAlignment
;
}
public
get
mouseOver
():
boolean
{
return
this
.
_mouseOver
;
}
public
static
fadeOut
(
messageWidget
:
MessageWidget
):
IDisposable
{
let
handle
:
any
;
...
...
@@ -98,10 +108,16 @@ class MessageWidget {
private
_container
:
HTMLElement
,
private
_left
:
number
,
private
_y
:
number
,
private
_text
:
string
,
private
_verticalAlignment
:
WidgetVerticalAlignment
private
_text
:
IMarkdownString
,
private
_verticalAlignment
:
WidgetVerticalAlignment
,
private
readonly
_openerService
:
IOpenerService
)
{
this
.
_domNode
=
document
.
createElement
(
'
div
'
);
this
.
_domNode
=
renderMarkdown
(
this
.
_text
,
{
actionHandler
:
{
callback
:
this
.
_handleLinkClicked
.
bind
(
this
),
disposeables
:
this
.
_messageListeners
}
});
this
.
_domNode
.
style
.
position
=
'
absolute
'
;
this
.
_domNode
.
style
.
left
=
`
${
_left
}
px`
;
...
...
@@ -114,7 +130,15 @@ class MessageWidget {
}
this
.
_domNode
.
classList
.
add
(
'
terminal-message-widget
'
,
'
fadeIn
'
);
this
.
_domNode
.
textContent
=
_text
;
this
.
_domNode
.
addEventListener
(
'
mouseenter
'
,
()
=>
{
this
.
_mouseOver
=
true
;
});
this
.
_domNode
.
addEventListener
(
'
mouseleave
'
,
()
=>
{
this
.
_mouseOver
=
false
;
this
.
_messageListeners
.
add
(
MessageWidget
.
fadeOut
(
this
));
});
this
.
_container
.
appendChild
(
this
.
_domNode
);
}
...
...
@@ -122,5 +146,11 @@ class MessageWidget {
if
(
this
.
domNode
.
parentElement
===
this
.
_container
)
{
this
.
_container
.
removeChild
(
this
.
domNode
);
}
this
.
_messageListeners
.
dispose
();
}
private
_handleLinkClicked
(
content
:
string
)
{
this
.
_openerService
.
open
(
URI
.
parse
(
content
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录