Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
7b013e01
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,发现更多精彩内容 >>
提交
7b013e01
编写于
12月 15, 2015
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #1275: Render both keybindings.json string and UI label in define keybinding widget
上级
da0f76eb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
65 addition
and
23 deletion
+65
-23
src/vs/editor/contrib/defineKeybinding/browser/defineKeybinding.css
...tor/contrib/defineKeybinding/browser/defineKeybinding.css
+2
-3
src/vs/editor/contrib/defineKeybinding/browser/defineKeybinding.ts
...itor/contrib/defineKeybinding/browser/defineKeybinding.ts
+63
-20
未找到文件。
src/vs/editor/contrib/defineKeybinding/browser/defineKeybinding.css
浏览文件 @
7b013e01
...
@@ -13,8 +13,6 @@
...
@@ -13,8 +13,6 @@
.monaco-editor
.defineKeybindingWidget
{
.monaco-editor
.defineKeybindingWidget
{
font-family
:
'Segoe WPC'
,
'Segoe UI'
,
"SFUIText-Light"
,
HelveticaNeue-Light
,
sans-serif
,
"Droid Sans Fallback"
;
font-family
:
'Segoe WPC'
,
'Segoe UI'
,
"SFUIText-Light"
,
HelveticaNeue-Light
,
sans-serif
,
"Droid Sans Fallback"
;
width
:
340px
;
height
:
60px
;
padding
:
10px
;
padding
:
10px
;
}
}
...
@@ -23,7 +21,8 @@
...
@@ -23,7 +21,8 @@
text-align
:
center
;
text-align
:
center
;
}
}
.monaco-editor
.defineKeybindingWidget
.input
{
.monaco-editor
.defineKeybindingWidget
.input
,
.monaco-editor
.defineKeybindingWidget
.output
{
margin-top
:
10px
;
margin-top
:
10px
;
width
:
320px
;
width
:
320px
;
display
:
block
;
display
:
block
;
...
...
src/vs/editor/contrib/defineKeybinding/browser/defineKeybinding.ts
浏览文件 @
7b013e01
...
@@ -23,6 +23,7 @@ import {IKeybindingService} from 'vs/platform/keybinding/common/keybindingServic
...
@@ -23,6 +23,7 @@ import {IKeybindingService} from 'vs/platform/keybinding/common/keybindingServic
import
{
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
import
{
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
import
{
IOSupport
}
from
'
vs/platform/keybinding/common/commonKeybindingResolver
'
;
import
{
IOSupport
}
from
'
vs/platform/keybinding/common/commonKeybindingResolver
'
;
import
{
IHTMLContentElement
}
from
'
vs/base/common/htmlContent
'
;
import
{
IHTMLContentElement
}
from
'
vs/base/common/htmlContent
'
;
import
{
renderHtml
}
from
'
vs/base/browser/htmlContentRenderer
'
;
const
NLS_LAUNCH_MESSAGE
=
nls
.
localize
(
'
defineKeybinding.start
'
,
"
Define Keybinding
"
);
const
NLS_LAUNCH_MESSAGE
=
nls
.
localize
(
'
defineKeybinding.start
'
,
"
Define Keybinding
"
);
const
NLS_DEFINE_MESSAGE
=
nls
.
localize
(
'
defineKeybinding.initial
'
,
"
Press desired key combination and ENTER
"
);
const
NLS_DEFINE_MESSAGE
=
nls
.
localize
(
'
defineKeybinding.initial
'
,
"
Press desired key combination and ENTER
"
);
...
@@ -56,7 +57,7 @@ export class DefineKeybindingController implements EditorCommon.IEditorContribut
...
@@ -56,7 +57,7 @@ export class DefineKeybindingController implements EditorCommon.IEditorContribut
this
.
_keybindingService
=
keybindingService
;
this
.
_keybindingService
=
keybindingService
;
this
.
_toDispose
=
[];
this
.
_toDispose
=
[];
this
.
_launchWidget
=
new
DefineKeybindingLauncherWidget
(
this
.
_editor
,
keybindingService
,
()
=>
this
.
launch
());
this
.
_launchWidget
=
new
DefineKeybindingLauncherWidget
(
this
.
_editor
,
keybindingService
,
()
=>
this
.
launch
());
this
.
_defineWidget
=
new
DefineKeybindingWidget
(
this
.
_editor
,
(
keybinding
)
=>
this
.
_onAccepted
(
keybinding
));
this
.
_defineWidget
=
new
DefineKeybindingWidget
(
this
.
_editor
,
keybindingService
,
(
keybinding
)
=>
this
.
_onAccepted
(
keybinding
));
this
.
_toDispose
.
push
(
this
.
_editor
.
addListener2
(
EditorCommon
.
EventType
.
ModelChanged
,
(
e
)
=>
{
this
.
_toDispose
.
push
(
this
.
_editor
.
addListener2
(
EditorCommon
.
EventType
.
ModelChanged
,
(
e
)
=>
{
if
(
isInterestingEditorModel
(
this
.
_editor
))
{
if
(
isInterestingEditorModel
(
this
.
_editor
))
{
...
@@ -286,31 +287,41 @@ class DefineKeybindingLauncherWidget implements EditorBrowser.IOverlayWidget {
...
@@ -286,31 +287,41 @@ class DefineKeybindingLauncherWidget implements EditorBrowser.IOverlayWidget {
}
}
}
}
class
DefineKeybindingWidget
implements
EditorBrowser
.
IContentWidget
{
class
DefineKeybindingWidget
implements
EditorBrowser
.
IOverlayWidget
{
private
static
ID
=
'
editor.contrib.defineKeybindingWidget
'
;
private
static
ID
=
'
editor.contrib.defineKeybindingWidget
'
;
private
static
WIDTH
=
340
;
private
static
HEIGHT
=
90
;
private
_editor
:
EditorBrowser
.
ICodeEditor
;
private
_editor
:
EditorBrowser
.
ICodeEditor
;
private
_keybindingService
:
IKeybindingService
;
private
_domNode
:
HTMLElement
;
private
_domNode
:
HTMLElement
;
private
_toDispose
:
IDisposable
[];
private
_toDispose
:
IDisposable
[];
private
_position
:
EditorCommon
.
IPosition
;
private
_messageNode
:
HTMLElement
;
private
_messageNode
:
HTMLElement
;
private
_inputNode
:
HTMLInputElement
;
private
_inputNode
:
HTMLInputElement
;
private
_outputNode
:
HTMLElement
;
private
_lastKeybinding
:
Keybinding
;
private
_lastKeybinding
:
Keybinding
;
private
_onAccepted
:
(
keybinding
:
string
)
=>
void
;
private
_onAccepted
:
(
keybinding
:
string
)
=>
void
;
private
_isVisible
:
boolean
;
constructor
(
editor
:
EditorBrowser
.
ICodeEditor
,
onAccepted
:(
keybinding
:
string
)
=>
void
)
{
constructor
(
editor
:
EditorBrowser
.
ICodeEditor
,
keybindingService
:
IKeybindingService
,
onAccepted
:(
keybinding
:
string
)
=>
void
)
{
this
.
_editor
=
editor
;
this
.
_editor
=
editor
;
this
.
_keybindingService
=
keybindingService
;
this
.
_onAccepted
=
onAccepted
;
this
.
_onAccepted
=
onAccepted
;
this
.
_toDispose
=
[];
this
.
_toDispose
=
[];
this
.
_position
=
null
;
this
.
_lastKeybinding
=
null
;
this
.
_lastKeybinding
=
null
;
this
.
_domNode
=
document
.
createElement
(
'
div
'
);
this
.
_domNode
=
document
.
createElement
(
'
div
'
);
this
.
_domNode
.
className
=
'
defineKeybindingWidget
'
;
this
.
_domNode
.
className
=
'
defineKeybindingWidget
'
;
DomUtils
.
StyleMutator
.
setWidth
(
this
.
_domNode
,
DefineKeybindingWidget
.
WIDTH
);
DomUtils
.
StyleMutator
.
setHeight
(
this
.
_domNode
,
DefineKeybindingWidget
.
HEIGHT
);
this
.
_domNode
.
style
.
display
=
'
none
'
;
this
.
_isVisible
=
false
;
this
.
_messageNode
=
document
.
createElement
(
'
div
'
);
this
.
_messageNode
=
document
.
createElement
(
'
div
'
);
this
.
_messageNode
.
className
=
'
message
'
;
this
.
_messageNode
.
className
=
'
message
'
;
...
@@ -321,6 +332,10 @@ class DefineKeybindingWidget implements EditorBrowser.IContentWidget {
...
@@ -321,6 +332,10 @@ class DefineKeybindingWidget implements EditorBrowser.IContentWidget {
this
.
_inputNode
.
className
=
'
input
'
;
this
.
_inputNode
.
className
=
'
input
'
;
this
.
_domNode
.
appendChild
(
this
.
_inputNode
);
this
.
_domNode
.
appendChild
(
this
.
_inputNode
);
this
.
_outputNode
=
document
.
createElement
(
'
div
'
);
this
.
_outputNode
.
className
=
'
output
'
;
this
.
_domNode
.
appendChild
(
this
.
_outputNode
);
this
.
_toDispose
.
push
(
DomUtils
.
addDisposableListener
(
this
.
_inputNode
,
'
keydown
'
,
(
e
)
=>
{
this
.
_toDispose
.
push
(
DomUtils
.
addDisposableListener
(
this
.
_inputNode
,
'
keydown
'
,
(
e
)
=>
{
let
keyEvent
=
new
StandardKeyboardEvent
(
e
);
let
keyEvent
=
new
StandardKeyboardEvent
(
e
);
keyEvent
.
preventDefault
();
keyEvent
.
preventDefault
();
...
@@ -344,15 +359,24 @@ class DefineKeybindingWidget implements EditorBrowser.IContentWidget {
...
@@ -344,15 +359,24 @@ class DefineKeybindingWidget implements EditorBrowser.IContentWidget {
this
.
_inputNode
.
value
=
this
.
_lastKeybinding
.
toUserSettingsLabel
().
toLowerCase
();
this
.
_inputNode
.
value
=
this
.
_lastKeybinding
.
toUserSettingsLabel
().
toLowerCase
();
this
.
_inputNode
.
title
=
'
keyCode:
'
+
keyEvent
.
browserEvent
.
keyCode
;
this
.
_inputNode
.
title
=
'
keyCode:
'
+
keyEvent
.
browserEvent
.
keyCode
;
DomUtils
.
clearNode
(
this
.
_outputNode
);
let
htmlkb
=
this
.
_keybindingService
.
getHTMLLabelFor
(
this
.
_lastKeybinding
);
htmlkb
.
forEach
((
item
)
=>
this
.
_outputNode
.
appendChild
(
renderHtml
(
item
)));
}));
}));
this
.
_toDispose
.
push
(
this
.
_editor
.
addListener2
(
EditorCommon
.
EventType
.
ConfigurationChanged
,
(
e
)
=>
{
if
(
this
.
_isVisible
)
{
this
.
_layout
();
}
}))
this
.
_toDispose
.
push
(
DomUtils
.
addDisposableListener
(
this
.
_inputNode
,
'
blur
'
,
(
e
)
=>
this
.
_stop
()));
this
.
_toDispose
.
push
(
DomUtils
.
addDisposableListener
(
this
.
_inputNode
,
'
blur
'
,
(
e
)
=>
this
.
_stop
()));
this
.
_editor
.
add
Content
Widget
(
this
);
this
.
_editor
.
add
Overlay
Widget
(
this
);
}
}
public
dispose
():
void
{
public
dispose
():
void
{
this
.
_editor
.
remove
Content
Widget
(
this
);
this
.
_editor
.
remove
Overlay
Widget
(
this
);
this
.
_toDispose
=
disposeAll
(
this
.
_toDispose
);
this
.
_toDispose
=
disposeAll
(
this
.
_toDispose
);
}
}
...
@@ -364,23 +388,43 @@ class DefineKeybindingWidget implements EditorBrowser.IContentWidget {
...
@@ -364,23 +388,43 @@ class DefineKeybindingWidget implements EditorBrowser.IContentWidget {
return
this
.
_domNode
;
return
this
.
_domNode
;
}
}
public
getPosition
():
EditorBrowser
.
IContentWidgetPosition
{
public
getPosition
():
EditorBrowser
.
IOverlayWidgetPosition
{
if
(
!
this
.
_position
)
{
return
null
;
}
return
{
return
{
position
:
this
.
_position
,
preference
:
null
preference
:
[
EditorBrowser
.
ContentWidgetPositionPreference
.
BELOW
]
};
};
}
}
private
_show
():
void
{
if
(
this
.
_isVisible
)
{
return
;
}
this
.
_isVisible
=
true
;
this
.
_layout
();
this
.
_domNode
.
style
.
display
=
'
block
'
;
}
private
_hide
():
void
{
if
(
!
this
.
_isVisible
)
{
return
;
}
this
.
_isVisible
=
false
;
this
.
_domNode
.
style
.
display
=
'
none
'
;
}
private
_layout
():
void
{
let
editorLayout
=
this
.
_editor
.
getLayoutInfo
();
let
top
=
Math
.
round
((
editorLayout
.
height
-
DefineKeybindingWidget
.
HEIGHT
)
/
2
);
DomUtils
.
StyleMutator
.
setTop
(
this
.
_domNode
,
top
);
let
left
=
Math
.
round
((
editorLayout
.
width
-
DefineKeybindingWidget
.
WIDTH
)
/
2
);
DomUtils
.
StyleMutator
.
setLeft
(
this
.
_domNode
,
left
);
}
public
start
():
void
{
public
start
():
void
{
this
.
_position
=
this
.
_editor
.
getPosition
();
this
.
_editor
.
revealPositionInCenterIfOutsideViewport
(
this
.
_editor
.
getPosition
());
this
.
_editor
.
revealPositionInCenterIfOutsideViewport
(
this
.
_position
);
this
.
_editor
.
layoutContentWidget
(
this
);
// Force a view render
this
.
_show
();
this
.
_editor
.
getOffsetForColumn
(
this
.
_position
.
lineNumber
,
this
.
_position
.
column
);
this
.
_lastKeybinding
=
null
;
this
.
_lastKeybinding
=
null
;
this
.
_inputNode
.
value
=
''
;
this
.
_inputNode
.
value
=
''
;
...
@@ -389,8 +433,7 @@ class DefineKeybindingWidget implements EditorBrowser.IContentWidget {
...
@@ -389,8 +433,7 @@ class DefineKeybindingWidget implements EditorBrowser.IContentWidget {
private
_stop
():
void
{
private
_stop
():
void
{
this
.
_editor
.
focus
();
this
.
_editor
.
focus
();
this
.
_position
=
null
;
this
.
_hide
();
this
.
_editor
.
layoutContentWidget
(
this
);
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录