Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
b0ef72d1
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,发现更多精彩内容 >>
提交
b0ef72d1
编写于
2月 18, 2016
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
editor: make hover accessible
上级
90da6715
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
65 addition
and
6 deletion
+65
-6
src/vs/editor/contrib/hover/browser/hover.ts
src/vs/editor/contrib/hover/browser/hover.ts
+40
-3
src/vs/editor/contrib/hover/browser/hoverWidgets.ts
src/vs/editor/contrib/hover/browser/hoverWidgets.ts
+21
-1
src/vs/editor/contrib/hover/browser/modesContentHover.ts
src/vs/editor/contrib/hover/browser/modesContentHover.ts
+4
-2
未找到文件。
src/vs/editor/contrib/hover/browser/hover.ts
浏览文件 @
b0ef72d1
...
@@ -6,17 +6,22 @@
...
@@ -6,17 +6,22 @@
'
use strict
'
;
'
use strict
'
;
import
'
vs/css!./hover
'
;
import
'
vs/css!./hover
'
;
import
nls
=
require
(
'
vs/nls
'
);
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
EditorBrowserRegistry
}
from
'
vs/editor/browser/editorBrowserExtensions
'
;
import
{
EditorBrowserRegistry
}
from
'
vs/editor/browser/editorBrowserExtensions
'
;
import
EventEmitter
=
require
(
'
vs/base/common/eventEmitter
'
);
import
EventEmitter
=
require
(
'
vs/base/common/eventEmitter
'
);
import
{
CommonEditorRegistry
,
ContextKey
,
EditorActionDescriptor
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
EditorBrowser
=
require
(
'
vs/editor/browser/editorBrowser
'
);
import
EditorBrowser
=
require
(
'
vs/editor/browser/editorBrowser
'
);
import
EditorCommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
EditorCommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
{
EditorAction
,
Behaviour
}
from
'
vs/editor/common/editorAction
'
;
import
Platform
=
require
(
'
vs/base/common/platform
'
);
import
Platform
=
require
(
'
vs/base/common/platform
'
);
import
ModesContentHover
=
require
(
'
./modesContentHover
'
);
import
ModesContentHover
=
require
(
'
./modesContentHover
'
);
import
ModesGlyphHover
=
require
(
'
./modesGlyphHover
'
);
import
ModesGlyphHover
=
require
(
'
./modesGlyphHover
'
);
import
Keyboard
=
require
(
'
vs/base/browser/keyboardEvent
'
);
import
Keyboard
=
require
(
'
vs/base/browser/keyboardEvent
'
);
import
{
IEditorService
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditorService
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybindingService
'
;
import
{
IKeybindingService
,
KbExpr
}
from
'
vs/platform/keybinding/common/keybindingService
'
;
import
{
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
KeyCode
,
KeyMod
}
from
'
vs/base/common/keyCodes
'
;
class
ModesHoverController
implements
EditorCommon
.
IEditorContribution
{
class
ModesHoverController
implements
EditorCommon
.
IEditorContribution
{
...
@@ -28,6 +33,10 @@ class ModesHoverController implements EditorCommon.IEditorContribution {
...
@@ -28,6 +33,10 @@ class ModesHoverController implements EditorCommon.IEditorContribution {
private
_contentWidget
:
ModesContentHover
.
ModesContentHoverWidget
;
private
_contentWidget
:
ModesContentHover
.
ModesContentHoverWidget
;
private
_glyphWidget
:
ModesGlyphHover
.
ModesGlyphHoverWidget
;
private
_glyphWidget
:
ModesGlyphHover
.
ModesGlyphHoverWidget
;
static
getModesHoverController
(
editor
:
EditorCommon
.
ICommonCodeEditor
):
ModesHoverController
{
return
<
ModesHoverController
>
editor
.
getContribution
(
ModesHoverController
.
ID
);
}
constructor
(
editor
:
EditorBrowser
.
ICodeEditor
,
constructor
(
editor
:
EditorBrowser
.
ICodeEditor
,
@
IEditorService
editorService
:
IEditorService
,
@
IEditorService
editorService
:
IEditorService
,
@
IKeybindingService
keybindingService
:
IKeybindingService
@
IKeybindingService
keybindingService
:
IKeybindingService
...
@@ -87,7 +96,7 @@ class ModesHoverController implements EditorCommon.IEditorContribution {
...
@@ -87,7 +96,7 @@ class ModesHoverController implements EditorCommon.IEditorContribution {
if
(
this
.
_editor
.
getConfiguration
().
hover
&&
targetType
===
EditorCommon
.
MouseTargetType
.
CONTENT_TEXT
)
{
if
(
this
.
_editor
.
getConfiguration
().
hover
&&
targetType
===
EditorCommon
.
MouseTargetType
.
CONTENT_TEXT
)
{
this
.
_glyphWidget
.
hide
();
this
.
_glyphWidget
.
hide
();
this
.
_contentWidget
.
startShowingAt
(
mouseEvent
.
target
.
range
);
this
.
_contentWidget
.
startShowingAt
(
mouseEvent
.
target
.
range
,
false
);
}
else
if
(
targetType
===
EditorCommon
.
MouseTargetType
.
GUTTER_GLYPH_MARGIN
)
{
}
else
if
(
targetType
===
EditorCommon
.
MouseTargetType
.
GUTTER_GLYPH_MARGIN
)
{
this
.
_contentWidget
.
hide
();
this
.
_contentWidget
.
hide
();
this
.
_glyphWidget
.
startShowingAt
(
mouseEvent
.
target
.
position
.
lineNumber
);
this
.
_glyphWidget
.
startShowingAt
(
mouseEvent
.
target
.
position
.
lineNumber
);
...
@@ -109,6 +118,10 @@ class ModesHoverController implements EditorCommon.IEditorContribution {
...
@@ -109,6 +118,10 @@ class ModesHoverController implements EditorCommon.IEditorContribution {
this
.
_contentWidget
.
hide
();
this
.
_contentWidget
.
hide
();
}
}
public
showContentHover
(
range
:
EditorCommon
.
IEditorRange
,
focus
:
boolean
):
void
{
this
.
_contentWidget
.
startShowingAt
(
range
,
focus
);
}
public
getId
():
string
{
public
getId
():
string
{
return
ModesHoverController
.
ID
;
return
ModesHoverController
.
ID
;
}
}
...
@@ -128,4 +141,28 @@ class ModesHoverController implements EditorCommon.IEditorContribution {
...
@@ -128,4 +141,28 @@ class ModesHoverController implements EditorCommon.IEditorContribution {
}
}
}
}
class
ShowHoverAction
extends
EditorAction
{
static
ID
=
'
editor.action.showHover
'
;
constructor
(
descriptor
:
EditorCommon
.
IEditorActionDescriptorData
,
editor
:
EditorCommon
.
ICommonCodeEditor
,
@
IEditorService
editorService
:
IEditorService
)
{
super
(
descriptor
,
editor
,
Behaviour
.
TextFocus
);
}
public
run
():
TPromise
<
any
>
{
const
position
=
this
.
editor
.
getPosition
();
const
word
=
this
.
editor
.
getModel
().
getWordAtPosition
(
position
);
if
(
word
)
{
const
range
=
new
Range
(
position
.
lineNumber
,
position
.
column
,
position
.
lineNumber
,
word
.
endColumn
);
(
<
ModesHoverController
>
this
.
editor
.
getContribution
(
ModesHoverController
.
ID
)).
showContentHover
(
range
,
true
);
}
return
TPromise
.
as
(
null
);
}
}
EditorBrowserRegistry
.
registerEditorContribution
(
ModesHoverController
);
EditorBrowserRegistry
.
registerEditorContribution
(
ModesHoverController
);
CommonEditorRegistry
.
registerEditorAction
(
new
EditorActionDescriptor
(
ShowHoverAction
,
ShowHoverAction
.
ID
,
nls
.
localize
(
'
showHover
'
,
"
Show Hover
"
),
{
context
:
ContextKey
.
EditorTextFocus
,
kbExpr
:
KbExpr
.
has
(
EditorCommon
.
KEYBINDING_CONTEXT_EDITOR_TEXT_FOCUS
),
primary
:
KeyMod
.
chord
(
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_K
,
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_I
)
}));
src/vs/editor/contrib/hover/browser/hoverWidgets.ts
浏览文件 @
b0ef72d1
...
@@ -4,6 +4,9 @@
...
@@ -4,6 +4,9 @@
*--------------------------------------------------------------------------------------------*/
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
'
use strict
'
;
import
lifecycle
=
require
(
'
vs/base/common/lifecycle
'
);
import
{
CommonKeybindings
}
from
'
vs/base/common/keyCodes
'
;
import
dom
=
require
(
'
vs/base/browser/dom
'
);
import
EditorBrowser
=
require
(
'
vs/editor/browser/editorBrowser
'
);
import
EditorBrowser
=
require
(
'
vs/editor/browser/editorBrowser
'
);
import
EditorCommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
EditorCommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
...
@@ -17,6 +20,8 @@ export class ContentHoverWidget implements EditorBrowser.IContentWidget {
...
@@ -17,6 +20,8 @@ export class ContentHoverWidget implements EditorBrowser.IContentWidget {
private
_containerDomNode
:
HTMLElement
;
private
_containerDomNode
:
HTMLElement
;
_domNode
:
HTMLElement
;
_domNode
:
HTMLElement
;
_showAtPosition
:
EditorCommon
.
IEditorPosition
;
_showAtPosition
:
EditorCommon
.
IEditorPosition
;
private
_stoleFocus
:
boolean
;
private
_toDispose
:
lifecycle
.
IDisposable
[];
// Editor.IContentWidget.allowEditorOverflow
// Editor.IContentWidget.allowEditorOverflow
public
allowEditorOverflow
=
true
;
public
allowEditorOverflow
=
true
;
...
@@ -32,6 +37,13 @@ export class ContentHoverWidget implements EditorBrowser.IContentWidget {
...
@@ -32,6 +37,13 @@ export class ContentHoverWidget implements EditorBrowser.IContentWidget {
this
.
_domNode
=
document
.
createElement
(
'
div
'
);
this
.
_domNode
=
document
.
createElement
(
'
div
'
);
this
.
_domNode
.
style
.
display
=
'
inline-block
'
;
this
.
_domNode
.
style
.
display
=
'
inline-block
'
;
this
.
_containerDomNode
.
appendChild
(
this
.
_domNode
);
this
.
_containerDomNode
.
appendChild
(
this
.
_domNode
);
this
.
_domNode
.
tabIndex
=
0
;
this
.
_toDispose
=
[];
this
.
_toDispose
.
push
(
dom
.
addStandardDisposableListener
(
this
.
_domNode
,
'
keydown
'
,
(
e
:
dom
.
IKeyboardEvent
)
=>
{
if
(
e
.
equals
(
CommonKeybindings
.
ESCAPE
))
{
this
.
hide
();
}
}));
this
.
_editor
.
addContentWidget
(
this
);
this
.
_editor
.
addContentWidget
(
this
);
this
.
_showAtPosition
=
null
;
this
.
_showAtPosition
=
null
;
...
@@ -45,7 +57,7 @@ export class ContentHoverWidget implements EditorBrowser.IContentWidget {
...
@@ -45,7 +57,7 @@ export class ContentHoverWidget implements EditorBrowser.IContentWidget {
return
this
.
_containerDomNode
;
return
this
.
_containerDomNode
;
}
}
public
showAt
(
position
:
EditorCommon
.
IPosition
):
void
{
public
showAt
(
position
:
EditorCommon
.
IPosition
,
focus
:
boolean
):
void
{
// Position has changed
// Position has changed
this
.
_showAtPosition
=
new
Position
(
position
.
lineNumber
,
position
.
column
);
this
.
_showAtPosition
=
new
Position
(
position
.
lineNumber
,
position
.
column
);
...
@@ -67,6 +79,10 @@ export class ContentHoverWidget implements EditorBrowser.IContentWidget {
...
@@ -67,6 +79,10 @@ export class ContentHoverWidget implements EditorBrowser.IContentWidget {
// Simply force a synchronous render on the editor
// Simply force a synchronous render on the editor
// such that the widget does not really render with left = '0px'
// such that the widget does not really render with left = '0px'
this
.
_editor
.
render
();
this
.
_editor
.
render
();
this
.
_stoleFocus
=
focus
;
if
(
focus
)
{
this
.
_domNode
.
focus
();
}
}
}
public
hide
():
void
{
public
hide
():
void
{
...
@@ -75,6 +91,9 @@ export class ContentHoverWidget implements EditorBrowser.IContentWidget {
...
@@ -75,6 +91,9 @@ export class ContentHoverWidget implements EditorBrowser.IContentWidget {
}
}
this
.
_isVisible
=
false
;
this
.
_isVisible
=
false
;
this
.
_editor
.
layoutContentWidget
(
this
);
this
.
_editor
.
layoutContentWidget
(
this
);
if
(
this
.
_stoleFocus
)
{
this
.
_editor
.
focus
();
}
}
}
public
getPosition
():
EditorBrowser
.
IContentWidgetPosition
{
public
getPosition
():
EditorBrowser
.
IContentWidgetPosition
{
...
@@ -92,6 +111,7 @@ export class ContentHoverWidget implements EditorBrowser.IContentWidget {
...
@@ -92,6 +111,7 @@ export class ContentHoverWidget implements EditorBrowser.IContentWidget {
public
dispose
():
void
{
public
dispose
():
void
{
this
.
hide
();
this
.
hide
();
this
.
_toDispose
=
lifecycle
.
disposeAll
(
this
.
_toDispose
);
}
}
}
}
...
...
src/vs/editor/contrib/hover/browser/modesContentHover.ts
浏览文件 @
b0ef72d1
...
@@ -125,6 +125,7 @@ export class ModesContentHoverWidget extends HoverWidget.ContentHoverWidget {
...
@@ -125,6 +125,7 @@ export class ModesContentHoverWidget extends HoverWidget.ContentHoverWidget {
private
_isChangingDecorations
:
boolean
;
private
_isChangingDecorations
:
boolean
;
private
_editorService
:
IEditorService
;
private
_editorService
:
IEditorService
;
private
_keybindingService
:
IKeybindingService
;
private
_keybindingService
:
IKeybindingService
;
private
_shouldFocus
:
boolean
;
constructor
(
editor
:
EditorBrowser
.
ICodeEditor
,
editorService
:
IEditorService
,
keybindingService
:
IKeybindingService
)
{
constructor
(
editor
:
EditorBrowser
.
ICodeEditor
,
editorService
:
IEditorService
,
keybindingService
:
IKeybindingService
)
{
super
(
ModesContentHoverWidget
.
ID
,
editor
);
super
(
ModesContentHoverWidget
.
ID
,
editor
);
...
@@ -156,7 +157,7 @@ export class ModesContentHoverWidget extends HoverWidget.ContentHoverWidget {
...
@@ -156,7 +157,7 @@ export class ModesContentHoverWidget extends HoverWidget.ContentHoverWidget {
}
}
}
}
public
startShowingAt
(
range
:
EditorCommon
.
IEditorRange
):
void
{
public
startShowingAt
(
range
:
EditorCommon
.
IEditorRange
,
focus
:
boolean
):
void
{
if
(
this
.
_lastRange
)
{
if
(
this
.
_lastRange
)
{
if
(
this
.
_lastRange
.
equalsRange
(
range
))
{
if
(
this
.
_lastRange
.
equalsRange
(
range
))
{
// We have to show the widget at the exact same range as before, so no work is needed
// We have to show the widget at the exact same range as before, so no work is needed
...
@@ -191,6 +192,7 @@ export class ModesContentHoverWidget extends HoverWidget.ContentHoverWidget {
...
@@ -191,6 +192,7 @@ export class ModesContentHoverWidget extends HoverWidget.ContentHoverWidget {
this
.
_lastRange
=
range
;
this
.
_lastRange
=
range
;
this
.
_computer
.
setRange
(
range
);
this
.
_computer
.
setRange
(
range
);
this
.
_shouldFocus
=
focus
;
this
.
_hoverOperation
.
start
();
this
.
_hoverOperation
.
start
();
}
}
...
@@ -284,7 +286,7 @@ export class ModesContentHoverWidget extends HoverWidget.ContentHoverWidget {
...
@@ -284,7 +286,7 @@ export class ModesContentHoverWidget extends HoverWidget.ContentHoverWidget {
this
.
showAt
({
this
.
showAt
({
lineNumber
:
renderRange
.
startLineNumber
,
lineNumber
:
renderRange
.
startLineNumber
,
column
:
renderColumn
column
:
renderColumn
});
}
,
this
.
_shouldFocus
);
this
.
_isChangingDecorations
=
true
;
this
.
_isChangingDecorations
=
true
;
this
.
_highlightDecorations
=
this
.
_editor
.
deltaDecorations
(
this
.
_highlightDecorations
,
[{
this
.
_highlightDecorations
=
this
.
_editor
.
deltaDecorations
(
this
.
_highlightDecorations
,
[{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录