Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8f8d9919
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,发现更多精彩内容 >>
提交
8f8d9919
编写于
5月 14, 2020
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Push more into base hover widget
上级
5007d890
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
39 addition
and
57 deletion
+39
-57
src/vs/base/browser/ui/hover/hoverWidget.ts
src/vs/base/browser/ui/hover/hoverWidget.ts
+32
-1
src/vs/editor/contrib/hover/hoverWidgets.ts
src/vs/editor/contrib/hover/hoverWidgets.ts
+1
-30
src/vs/editor/contrib/hover/modesContentHover.ts
src/vs/editor/contrib/hover/modesContentHover.ts
+1
-1
src/vs/workbench/contrib/terminal/browser/widgets/hoverWidget.ts
...workbench/contrib/terminal/browser/widgets/hoverWidget.ts
+5
-25
未找到文件。
src/vs/base/browser/ui/hover/hoverWidget.ts
浏览文件 @
8f8d9919
...
...
@@ -7,12 +7,41 @@ import 'vs/css!./hover';
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
Widget
}
from
'
vs/base/browser/ui/widget
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
DomScrollableElement
}
from
'
vs/base/browser/ui/scrollbar/scrollableElement
'
;
import
{
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
IKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
const
$
=
dom
.
$
;
export
class
HoverWidget
extends
Widget
{
export
abstract
class
HoverWidget
extends
Widget
{
protected
readonly
_containerDomNode
:
HTMLElement
;
protected
readonly
_domNode
:
HTMLElement
;
private
readonly
_scrollbar
:
DomScrollableElement
;
constructor
()
{
super
();
this
.
_containerDomNode
=
document
.
createElement
(
'
div
'
);
this
.
_containerDomNode
.
classList
.
add
(
'
terminal-hover-widget
'
,
'
fadeIn
'
,
'
monaco-editor-hover
'
,
'
xterm-hover
'
);
this
.
_containerDomNode
.
tabIndex
=
0
;
this
.
_containerDomNode
.
setAttribute
(
'
role
'
,
'
tooltip
'
);
this
.
_domNode
=
document
.
createElement
(
'
div
'
);
this
.
_domNode
.
className
=
'
monaco-editor-hover-content
'
;
this
.
_scrollbar
=
new
DomScrollableElement
(
this
.
_domNode
,
{});
this
.
_register
(
this
.
_scrollbar
);
this
.
_containerDomNode
.
appendChild
(
this
.
_scrollbar
.
getDomNode
());
this
.
onkeydown
(
this
.
_containerDomNode
,
(
e
:
IKeyboardEvent
)
=>
{
if
(
e
.
equals
(
KeyCode
.
Escape
))
{
this
.
hide
();
}
});
}
protected
_onContentsChange
():
void
{
this
.
_scrollbar
.
scanDomNode
();
}
protected
_renderAction
(
parent
:
HTMLElement
,
actionOptions
:
{
label
:
string
,
iconClass
?:
string
,
run
:
(
target
:
HTMLElement
)
=>
void
,
commandId
:
string
},
keybindingLabel
:
string
|
null
):
IDisposable
{
...
...
@@ -31,4 +60,6 @@ export class HoverWidget extends Widget {
actionOptions
.
run
(
actionContainer
);
});
}
protected
abstract
hide
():
void
;
}
src/vs/editor/contrib/hover/hoverWidgets.ts
浏览文件 @
8f8d9919
...
...
@@ -4,10 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
IKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
DomScrollableElement
}
from
'
vs/base/browser/ui/scrollbar/scrollableElement
'
;
import
{
Widget
}
from
'
vs/base/browser/ui/widget
'
;
import
{
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
IContentWidget
,
ICodeEditor
,
IContentWidgetPosition
,
ContentWidgetPositionPreference
,
IOverlayWidget
,
IOverlayWidgetPosition
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ConfigurationChangedEvent
,
EditorOption
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
...
...
@@ -21,12 +18,9 @@ export class ContentHoverWidget extends HoverWidget implements IContentWidget {
private
readonly
_id
:
string
;
protected
_editor
:
ICodeEditor
;
private
_isVisible
:
boolean
;
private
readonly
_containerDomNode
:
HTMLElement
;
protected
readonly
_domNode
:
HTMLElement
;
protected
_showAtPosition
:
Position
|
null
;
protected
_showAtRange
:
Range
|
null
;
private
_stoleFocus
:
boolean
;
private
readonly
scrollbar
:
DomScrollableElement
;
// Editor.IContentWidget.allowEditorOverflow
public
allowEditorOverflow
=
true
;
...
...
@@ -52,24 +46,6 @@ export class ContentHoverWidget extends HoverWidget implements IContentWidget {
this
.
_isVisible
=
false
;
this
.
_stoleFocus
=
false
;
this
.
_containerDomNode
=
document
.
createElement
(
'
div
'
);
this
.
_containerDomNode
.
className
=
'
monaco-editor-hover hidden
'
;
this
.
_containerDomNode
.
tabIndex
=
0
;
this
.
_containerDomNode
.
setAttribute
(
'
role
'
,
'
tooltip
'
);
this
.
_domNode
=
document
.
createElement
(
'
div
'
);
this
.
_domNode
.
className
=
'
monaco-editor-hover-content
'
;
this
.
scrollbar
=
new
DomScrollableElement
(
this
.
_domNode
,
{});
this
.
_register
(
this
.
scrollbar
);
this
.
_containerDomNode
.
appendChild
(
this
.
scrollbar
.
getDomNode
());
this
.
onkeydown
(
this
.
_containerDomNode
,
(
e
:
IKeyboardEvent
)
=>
{
if
(
e
.
equals
(
KeyCode
.
Escape
))
{
this
.
hide
();
}
});
this
.
_register
(
this
.
_editor
.
onDidChangeConfiguration
((
e
:
ConfigurationChangedEvent
)
=>
{
if
(
e
.
hasChanged
(
EditorOption
.
fontInfo
))
{
this
.
updateFont
();
...
...
@@ -152,20 +128,15 @@ export class ContentHoverWidget extends HoverWidget implements IContentWidget {
this
.
updateFont
();
this
.
_editor
.
layoutContentWidget
(
this
);
this
.
onContentsChange
();
this
.
_
onContentsChange
();
}
protected
_renderAction
(
parent
:
HTMLElement
,
actionOptions
:
{
label
:
string
,
iconClass
?:
string
,
run
:
(
target
:
HTMLElement
)
=>
void
,
commandId
:
string
}):
IDisposable
{
const
keybinding
=
this
.
_keybindingService
.
lookupKeybinding
(
actionOptions
.
commandId
);
const
keybindingLabel
=
keybinding
?
keybinding
.
getLabel
()
:
null
;
return
super
.
_renderAction
(
parent
,
actionOptions
,
keybindingLabel
);
}
protected
onContentsChange
():
void
{
this
.
scrollbar
.
scanDomNode
();
}
private
layout
():
void
{
const
height
=
Math
.
max
(
this
.
_editor
.
getLayoutInfo
().
height
/
4
,
250
);
const
{
fontSize
,
lineHeight
}
=
this
.
_editor
.
getOption
(
EditorOption
.
fontInfo
);
...
...
src/vs/editor/contrib/hover/modesContentHover.ts
浏览文件 @
8f8d9919
...
...
@@ -461,7 +461,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
const
renderer
=
markdownDisposeables
.
add
(
new
MarkdownRenderer
(
this
.
_editor
,
this
.
_modeService
,
this
.
_openerService
));
markdownDisposeables
.
add
(
renderer
.
onDidRenderCodeBlock
(()
=>
{
hoverContentsElement
.
className
=
'
hover-contents code-hover-contents
'
;
this
.
onContentsChange
();
this
.
_
onContentsChange
();
}));
const
renderedContents
=
markdownDisposeables
.
add
(
renderer
.
render
(
contents
));
hoverContentsElement
.
appendChild
(
renderedContents
.
element
);
...
...
src/vs/workbench/contrib/terminal/browser/widgets/hoverWidget.ts
浏览文件 @
8f8d9919
...
...
@@ -12,8 +12,6 @@ import { editorHoverHighlight, editorHoverBackground, editorHoverBorder, textLin
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IHoverTarget
,
HorizontalAnchorSide
,
VerticalAnchorSide
}
from
'
vs/workbench/contrib/terminal/browser/widgets/widgets
'
;
import
{
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
DomScrollableElement
}
from
'
vs/base/browser/ui/scrollbar/scrollableElement
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
EDITOR_FONT_DEFAULTS
,
IEditorOptions
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
HoverWidget
as
BaseHoverWidget
}
from
'
vs/base/browser/ui/hover/hoverWidget
'
;
...
...
@@ -22,11 +20,8 @@ import { Widget } from 'vs/base/browser/ui/widget';
const
$
=
dom
.
$
;
export
class
HoverWidget
extends
BaseHoverWidget
{
private
readonly
_containerDomNode
:
HTMLElement
;
private
readonly
_domNode
:
HTMLElement
;
private
readonly
_messageListeners
=
new
DisposableStore
();
private
readonly
_mouseTracker
:
CompositeMouseTracker
;
private
readonly
_scrollbar
:
DomScrollableElement
;
private
_isDisposed
:
boolean
=
false
;
...
...
@@ -47,29 +42,10 @@ export class HoverWidget extends BaseHoverWidget {
)
{
super
();
this
.
_containerDomNode
=
document
.
createElement
(
'
div
'
);
this
.
_containerDomNode
.
classList
.
add
(
'
terminal-hover-widget
'
,
'
fadeIn
'
,
'
monaco-editor-hover
'
,
'
xterm-hover
'
);
this
.
_containerDomNode
.
tabIndex
=
0
;
this
.
_containerDomNode
.
setAttribute
(
'
role
'
,
'
tooltip
'
);
this
.
_domNode
=
document
.
createElement
(
'
div
'
);
this
.
_domNode
.
className
=
'
monaco-editor-hover-content
'
;
this
.
_scrollbar
=
new
DomScrollableElement
(
this
.
_domNode
,
{});
this
.
_register
(
this
.
_scrollbar
);
this
.
_containerDomNode
.
appendChild
(
this
.
_scrollbar
.
getDomNode
());
// Don't allow mousedown out of the widget, otherwise preventDefault will call and text will
// not be selected.
this
.
onmousedown
(
this
.
_containerDomNode
,
e
=>
e
.
stopPropagation
());
// Hide hover on escape
this
.
onkeydown
(
this
.
_containerDomNode
,
e
=>
{
if
(
e
.
equals
(
KeyCode
.
Escape
))
{
this
.
dispose
();
}
});
const
rowElement
=
$
(
'
div.hover-row.markdown-hover
'
);
const
contentsElement
=
$
(
'
div.hover-contents
'
);
const
markdownElement
=
renderMarkdown
(
this
.
_text
,
{
...
...
@@ -152,13 +128,17 @@ export class HoverWidget extends BaseHoverWidget {
this
.
_containerDomNode
.
style
.
top
=
`
${
anchor
.
y
}
px`
;
}
}
this
.
_
scrollbar
.
scanDomNod
e
();
this
.
_
onContentsChang
e
();
}
public
focus
()
{
this
.
_containerDomNode
.
focus
();
}
public
hide
():
void
{
this
.
dispose
();
}
public
dispose
():
void
{
if
(
!
this
.
_isDisposed
)
{
this
.
_onDispose
.
fire
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录