Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
3aa0a3dc
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,发现更多精彩内容 >>
提交
3aa0a3dc
编写于
9月 06, 2016
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pimp up glyph hover
上级
dbbadcd0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
65 addition
and
39 deletion
+65
-39
src/vs/editor/contrib/hover/browser/hover.ts
src/vs/editor/contrib/hover/browser/hover.ts
+1
-1
src/vs/editor/contrib/hover/browser/hoverWidgets.ts
src/vs/editor/contrib/hover/browser/hoverWidgets.ts
+38
-17
src/vs/editor/contrib/hover/browser/modesGlyphHover.ts
src/vs/editor/contrib/hover/browser/modesGlyphHover.ts
+26
-21
未找到文件。
src/vs/editor/contrib/hover/browser/hover.ts
浏览文件 @
3aa0a3dc
...
...
@@ -60,7 +60,7 @@ class ModesHoverController implements editorCommon.IEditorContribution {
}));
this
.
_contentWidget
=
new
ModesContentHoverWidget
(
editor
,
openerService
,
modeService
);
this
.
_glyphWidget
=
new
ModesGlyphHoverWidget
(
editor
);
this
.
_glyphWidget
=
new
ModesGlyphHoverWidget
(
editor
,
openerService
,
modeService
);
}
}
...
...
src/vs/editor/contrib/hover/browser/hoverWidgets.ts
浏览文件 @
3aa0a3dc
...
...
@@ -156,8 +156,8 @@ export class GlyphHoverWidget extends Widget implements editorBrowser.IOverlayWi
private
_id
:
string
;
protected
_editor
:
editorBrowser
.
ICodeEditor
;
pr
otected
_isVisible
:
boolean
;
pr
otected
_domNode
:
HTMLElement
;
pr
ivate
_isVisible
:
boolean
;
pr
ivate
_domNode
:
HTMLElement
;
protected
_showAtLineNumber
:
number
;
constructor
(
id
:
string
,
editor
:
editorBrowser
.
ICodeEditor
)
{
...
...
@@ -167,23 +167,30 @@ export class GlyphHoverWidget extends Widget implements editorBrowser.IOverlayWi
this
.
_isVisible
=
false
;
this
.
_domNode
=
document
.
createElement
(
'
div
'
);
this
.
_domNode
.
className
=
'
monaco-editor-hover monaco-editor-background
'
;
this
.
_domNode
.
style
.
display
=
'
none
'
;
this
.
_domNode
.
className
=
'
monaco-editor-hover hidden
'
;
this
.
_domNode
.
setAttribute
(
'
aria-hidden
'
,
'
true
'
);
this
.
_domNode
.
setAttribute
(
'
role
'
,
'
presentation
'
);
this
.
_showAtLineNumber
=
-
1
;
this
.
_editor
.
applyFontInfo
(
this
.
_domNode
);
this
.
_register
(
this
.
_editor
.
onDidChangeConfiguration
((
e
:
IConfigurationChangedEvent
)
=>
{
if
(
e
.
fontInfo
)
{
this
.
_editor
.
applyFontInfo
(
this
.
_domNode
);
this
.
updateFont
(
);
}
}));
this
.
_editor
.
addOverlayWidget
(
this
);
}
protected
get
isVisible
():
boolean
{
return
this
.
_isVisible
;
}
protected
set
isVisible
(
value
:
boolean
)
{
this
.
_isVisible
=
value
;
toggleClass
(
this
.
_domNode
,
'
hidden
'
,
!
this
.
_isVisible
);
}
public
getId
():
string
{
return
this
.
_id
;
}
...
...
@@ -195,25 +202,26 @@ export class GlyphHoverWidget extends Widget implements editorBrowser.IOverlayWi
public
showAt
(
lineNumber
:
number
):
void
{
this
.
_showAtLineNumber
=
lineNumber
;
if
(
!
this
.
_isVisible
)
{
this
.
_isVisible
=
true
;
this
.
_domNode
.
style
.
display
=
'
block
'
;
if
(
!
this
.
isVisible
)
{
this
.
isVisible
=
true
;
}
let
editorLayout
=
this
.
_editor
.
getLayoutInfo
();
let
topForLineNumber
=
this
.
_editor
.
getTopForLineNumber
(
this
.
_showAtLineNumber
);
let
editorScrollTop
=
this
.
_editor
.
getScrollTop
();
const
editorLayout
=
this
.
_editor
.
getLayoutInfo
();
const
topForLineNumber
=
this
.
_editor
.
getTopForLineNumber
(
this
.
_showAtLineNumber
);
const
editorScrollTop
=
this
.
_editor
.
getScrollTop
();
const
lineHeight
=
this
.
_editor
.
getConfiguration
().
lineHeight
;
const
nodeHeight
=
this
.
_domNode
.
clientHeight
;
const
top
=
topForLineNumber
-
editorScrollTop
-
((
nodeHeight
-
lineHeight
)
/
2
);
this
.
_domNode
.
style
.
left
=
(
editorLayout
.
glyphMarginLeft
+
editorLayout
.
glyphMarginWidth
)
+
'
px
'
;
this
.
_domNode
.
style
.
top
=
(
topForLineNumber
-
editorScrollTop
)
+
'
px
'
;
this
.
_domNode
.
style
.
left
=
`
${
editorLayout
.
glyphMarginLeft
+
editorLayout
.
glyphMarginWidth
}
px`
;
this
.
_domNode
.
style
.
top
=
`
${
Math
.
max
(
Math
.
round
(
top
),
0
)
}
px`
;
}
public
hide
():
void
{
if
(
!
this
.
_
isVisible
)
{
if
(
!
this
.
isVisible
)
{
return
;
}
this
.
_isVisible
=
false
;
this
.
_domNode
.
style
.
display
=
'
none
'
;
this
.
isVisible
=
false
;
}
public
getPosition
():
editorBrowser
.
IOverlayWidgetPosition
{
...
...
@@ -224,4 +232,17 @@ export class GlyphHoverWidget extends Widget implements editorBrowser.IOverlayWi
this
.
_editor
.
removeOverlayWidget
(
this
);
super
.
dispose
();
}
private
updateFont
():
void
{
const
codeTags
:
HTMLPhraseElement
[]
=
Array
.
prototype
.
slice
.
call
(
this
.
_domNode
.
getElementsByTagName
(
'
code
'
));
const
codeClasses
:
HTMLElement
[]
=
Array
.
prototype
.
slice
.
call
(
this
.
_domNode
.
getElementsByClassName
(
'
code
'
));
[...
codeTags
,
...
codeClasses
].
forEach
(
node
=>
this
.
_editor
.
applyFontInfo
(
node
));
}
protected
updateContents
(
node
:
Node
):
void
{
this
.
_domNode
.
textContent
=
''
;
this
.
_domNode
.
appendChild
(
node
);
this
.
updateFont
();
}
}
src/vs/editor/contrib/hover/browser/modesGlyphHover.ts
浏览文件 @
3aa0a3dc
...
...
@@ -8,6 +8,13 @@ import {IModelDecoration, IRange} from 'vs/editor/common/editorCommon';
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
HoverOperation
,
IHoverComputer
}
from
'
./hoverOperation
'
;
import
{
GlyphHoverWidget
}
from
'
./hoverWidgets
'
;
import
{
$
}
from
'
vs/base/browser/dom
'
;
import
{
renderMarkedString
}
from
'
vs/base/browser/htmlContentRenderer
'
;
import
{
IOpenerService
,
NullOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
tokenizeToString
}
from
'
vs/editor/common/modes/textToHtmlTokenizer
'
;
export
interface
IHoverMessage
{
value
?:
string
;
...
...
@@ -77,9 +84,11 @@ export class ModesGlyphHoverWidget extends GlyphHoverWidget {
private
_computer
:
MarginComputer
;
private
_hoverOperation
:
HoverOperation
<
IHoverMessage
[]
>
;
constructor
(
editor
:
ICodeEditor
)
{
constructor
(
editor
:
ICodeEditor
,
private
openerService
:
IOpenerService
,
private
modeService
:
IModeService
)
{
super
(
ModesGlyphHoverWidget
.
ID
,
editor
);
this
.
openerService
=
openerService
||
NullOpenerService
;
this
.
_lastLineNumber
=
-
1
;
this
.
_computer
=
new
MarginComputer
(
this
.
_editor
);
...
...
@@ -99,7 +108,7 @@ export class ModesGlyphHoverWidget extends GlyphHoverWidget {
}
public
onModelDecorationsChanged
():
void
{
if
(
this
.
_
isVisible
)
{
if
(
this
.
isVisible
)
{
// The decorations have changed and the hover is visible,
// we need to recompute the displayed text
this
.
_hoverOperation
.
cancel
();
...
...
@@ -141,29 +150,25 @@ export class ModesGlyphHoverWidget extends GlyphHoverWidget {
private
_renderMessages
(
lineNumber
:
number
,
messages
:
IHoverMessage
[]):
void
{
var
fragment
=
document
.
createDocumentFragment
();
const
fragment
=
document
.
createDocumentFragment
();
messages
.
forEach
((
msg
)
=>
{
var
row
:
HTMLElement
=
document
.
createElement
(
'
div
'
);
var
span
:
HTMLElement
=
null
;
if
(
msg
.
className
)
{
span
=
document
.
createElement
(
'
span
'
);
span
.
textContent
=
msg
.
value
;
span
.
className
=
msg
.
className
;
row
.
appendChild
(
span
);
}
else
{
row
.
textContent
=
msg
.
value
;
}
fragment
.
appendChild
(
row
);
const
renderedContents
=
renderMarkedString
(
msg
.
value
,
{
actionCallback
:
content
=>
this
.
openerService
.
open
(
URI
.
parse
(
content
)),
codeBlockRenderer
:
(
modeId
,
value
):
string
|
TPromise
<
string
>
=>
{
const
mode
=
this
.
modeService
.
getMode
(
modeId
||
this
.
_editor
.
getModel
().
getModeId
());
const
getMode
=
mode
=>
mode
?
TPromise
.
as
(
mode
)
:
this
.
modeService
.
getOrCreateMode
(
modeId
);
return
getMode
(
mode
)
.
then
(
null
,
err
=>
null
)
.
then
(
mode
=>
`<div class="code">
${
tokenizeToString
(
value
,
mode
)
}
</div>`
);
}
});
fragment
.
appendChild
(
$
(
'
div.hover-row
'
,
null
,
renderedContents
));
});
this
.
_domNode
.
textContent
=
''
;
this
.
_domNode
.
appendChild
(
fragment
);
// show
this
.
updateContents
(
fragment
);
this
.
showAt
(
lineNumber
);
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录