Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8d53ee62
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,发现更多精彩内容 >>
提交
8d53ee62
编写于
5月 23, 2018
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#24396
💄
上级
06d50479
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
39 addition
and
52 deletion
+39
-52
src/vs/workbench/parts/preferences/browser/keybindingWidgets.ts
.../workbench/parts/preferences/browser/keybindingWidgets.ts
+34
-42
src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts
.../workbench/parts/preferences/browser/keybindingsEditor.ts
+3
-8
src/vs/workbench/parts/preferences/browser/media/keybindings.css
...workbench/parts/preferences/browser/media/keybindings.css
+2
-2
未找到文件。
src/vs/workbench/parts/preferences/browser/keybindingWidgets.ts
浏览文件 @
8d53ee62
...
...
@@ -137,7 +137,7 @@ export class DefineKeybindingWidget extends Widget {
private
_domNode
:
FastDomNode
<
HTMLElement
>
;
private
_keybindingInputWidget
:
KeybindingInputWidget
;
private
_outputNode
:
HTMLElement
;
private
_
conflict
Node
:
HTMLElement
;
private
_
showExistingKeybindings
Node
:
HTMLElement
;
private
_firstPart
:
ResolvedKeybinding
=
null
;
private
_chordPart
:
ResolvedKeybinding
=
null
;
...
...
@@ -148,8 +148,8 @@ export class DefineKeybindingWidget extends Widget {
private
_onDidChange
=
this
.
_register
(
new
Emitter
<
String
>
());
public
onDidChange
:
Event
<
String
>
=
this
.
_onDidChange
.
event
;
private
_on
LinkClick
=
this
.
_register
(
new
Emitter
<
String
>
());
public
readonly
on
LinkClick
:
Event
<
String
>
=
this
.
_onLinkClick
.
event
;
private
_on
ShowExistingKeybindings
=
this
.
_register
(
new
Emitter
<
String
>
());
public
readonly
on
ShowExistingKeybidings
:
Event
<
String
>
=
this
.
_onShowExistingKeybindings
.
event
;
constructor
(
parent
:
HTMLElement
,
...
...
@@ -178,19 +178,11 @@ export class DefineKeybindingWidget extends Widget {
this
.
_chordPart
=
null
;
this
.
_keybindingInputWidget
.
setInputValue
(
''
);
dom
.
clearNode
(
this
.
_outputNode
);
dom
.
clearNode
(
this
.
_
conflict
Node
);
dom
.
clearNode
(
this
.
_
showExistingKeybindings
Node
);
this
.
_keybindingInputWidget
.
focus
();
}
const
disposable
=
this
.
_onHide
.
event
(()
=>
{
if
(
this
.
_firstPart
)
{
let
r
=
this
.
_firstPart
.
getUserSettingsLabel
();
if
(
this
.
_chordPart
)
{
r
=
r
+
'
'
+
this
.
_chordPart
.
getUserSettingsLabel
();
}
c
(
r
);
}
else
{
c
(
null
);
}
c
(
this
.
getUserSettingsLabel
());
disposable
.
dispose
();
});
});
...
...
@@ -204,6 +196,21 @@ export class DefineKeybindingWidget extends Widget {
this
.
_domNode
.
setLeft
(
left
);
}
printExisting
(
numberOfExisting
:
number
):
void
{
if
(
numberOfExisting
>
0
)
{
let
outputString
:
string
=
nls
.
localize
(
'
defineKeybinding.existing
'
,
"
Existing
"
);
outputString
=
numberOfExisting
+
'
'
+
outputString
;
let
textNode
=
document
.
createTextNode
(
outputString
);
let
textSpan
=
document
.
createElement
(
'
span
'
);
dom
.
addClass
(
textSpan
,
'
existingText
'
);
textSpan
.
appendChild
(
textNode
);
this
.
_showExistingKeybindingsNode
.
appendChild
(
textSpan
);
textSpan
.
onmousedown
=
(
e
)
=>
{
e
.
preventDefault
();
};
textSpan
.
onmouseup
=
(
e
)
=>
{
e
.
preventDefault
();
};
textSpan
.
onclick
=
()
=>
{
this
.
_onShowExistingKeybindings
.
fire
(
this
.
getUserSettingsLabel
());
};
}
}
private
create
():
void
{
this
.
_domNode
=
createFastDomNode
(
document
.
createElement
(
'
div
'
));
this
.
_domNode
.
setDisplay
(
'
none
'
);
...
...
@@ -227,56 +234,41 @@ export class DefineKeybindingWidget extends Widget {
}));
this
.
_keybindingInputWidget
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
KeybindingInputWidget
,
this
.
_domNode
.
domNode
,
{}));
this
.
_register
(
this
.
_keybindingInputWidget
.
onKeybinding
(
keybinding
=>
{
this
.
printKeybinding
(
keybinding
);
this
.
processChange
(
keybinding
);
}
));
this
.
_register
(
this
.
_keybindingInputWidget
.
onKeybinding
(
keybinding
=>
this
.
onKeybinding
(
keybinding
)
));
this
.
_register
(
this
.
_keybindingInputWidget
.
onEnter
(()
=>
this
.
hide
()));
this
.
_register
(
this
.
_keybindingInputWidget
.
onEscape
(()
=>
this
.
onCancel
()));
this
.
_register
(
this
.
_keybindingInputWidget
.
onBlur
(()
=>
this
.
onCancel
()));
this
.
_outputNode
=
dom
.
append
(
this
.
_domNode
.
domNode
,
dom
.
$
(
'
.output
'
));
this
.
_
conflictNode
=
dom
.
append
(
this
.
_domNode
.
domNode
,
dom
.
$
(
'
.conflicts
'
));
this
.
_
showExistingKeybindingsNode
=
dom
.
append
(
this
.
_domNode
.
domNode
,
dom
.
$
(
'
.existing
'
));
}
private
processChange
(
keybinding
:
[
ResolvedKeybinding
,
ResolvedKeybinding
]):
void
{
const
[
firstPart
,
chordPart
]
=
keybinding
;
let
keybindingStr
=
'
"
'
+
firstPart
.
getAriaLabel
()
+
'
+
'
;
if
(
chordPart
)
{
keybindingStr
=
keybindingStr
+
chordPart
.
getAriaLabel
()
+
'
+
'
;
}
keybindingStr
=
keybindingStr
+
'
"
'
;
this
.
_onDidChange
.
fire
(
keybindingStr
);
}
private
printKeybinding
(
keybinding
:
[
ResolvedKeybinding
,
ResolvedKeybinding
]):
void
{
private
onKeybinding
(
keybinding
:
[
ResolvedKeybinding
,
ResolvedKeybinding
]):
void
{
const
[
firstPart
,
chordPart
]
=
keybinding
;
this
.
_firstPart
=
firstPart
;
this
.
_chordPart
=
chordPart
;
dom
.
clearNode
(
this
.
_outputNode
);
dom
.
clearNode
(
this
.
_
conflict
Node
);
dom
.
clearNode
(
this
.
_
showExistingKeybindings
Node
);
new
KeybindingLabel
(
this
.
_outputNode
,
OS
).
set
(
this
.
_firstPart
,
null
);
if
(
this
.
_chordPart
)
{
this
.
_outputNode
.
appendChild
(
document
.
createTextNode
(
nls
.
localize
(
'
defineKeybinding.chordsTo
'
,
"
chord to
"
)));
new
KeybindingLabel
(
this
.
_outputNode
,
OS
).
set
(
this
.
_chordPart
,
null
);
}
const
label
=
this
.
getUserSettingsLabel
();
if
(
label
)
{
this
.
_onDidChange
.
fire
(
label
);
}
}
public
printConflicts
(
numConflicts
:
Number
):
void
{
if
(
numConflicts
>
0
)
{
let
outputString
:
string
=
nls
.
localize
(
'
defineKeybinding.existing
'
,
"
Existing
"
);
outputString
=
numConflicts
+
'
'
+
outputString
;
let
textNode
=
document
.
createTextNode
(
outputString
);
let
textSpan
=
document
.
createElement
(
'
span
'
);
dom
.
addClass
(
textSpan
,
'
conflictText
'
);
textSpan
.
appendChild
(
textNode
);
let
linkBinding
=
this
.
_firstPart
.
getAriaLabel
();
private
getUserSettingsLabel
():
string
{
let
label
=
null
;
if
(
this
.
_firstPart
)
{
label
=
this
.
_firstPart
.
getUserSettingsLabel
();
if
(
this
.
_chordPart
)
{
l
inkBinding
+=
'
+
'
+
this
.
_chordPart
.
getAria
Label
();
l
abel
=
label
+
'
'
+
this
.
_chordPart
.
getUserSettings
Label
();
}
linkBinding
+=
'
+
'
;
this
.
_conflictNode
.
appendChild
(
textSpan
);
textSpan
.
onmousedown
=
(
e
)
=>
{
e
.
preventDefault
();
};
textSpan
.
onmouseup
=
(
e
)
=>
{
e
.
preventDefault
();
};
textSpan
.
onclick
=
()
=>
{
this
.
_onLinkClick
.
fire
(
linkBinding
);
};
}
return
label
;
}
private
onCancel
():
void
{
...
...
src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts
浏览文件 @
8d53ee62
...
...
@@ -260,25 +260,20 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
}
showSimilarKeybindings
(
keybindingEntry
:
IKeybindingItemEntry
):
TPromise
<
any
>
{
let
value
=
`"
${
keybindingEntry
.
keybindingItem
.
keybinding
.
getAriaLabel
().
replace
(
'
'
,
'
+
'
)}
+
"`
;
const
value
=
`"
${
keybindingEntry
.
keybindingItem
.
keybinding
.
getAriaLabel
()}
"`
;
if
(
value
!==
this
.
searchWidget
.
getValue
())
{
this
.
searchWidget
.
setValue
(
value
);
}
return
TPromise
.
as
(
null
);
}
private
showOverlayConflicts
(
keybindingStr
:
String
):
void
{
const
conflictsList
:
IKeybindingItemEntry
[]
=
this
.
keybindingsEditorModel
.
fetch
(
`
${
keybindingStr
}
`
,
this
.
sortByPrecedence
.
checked
);
this
.
defineKeybindingWidget
.
printConflicts
(
conflictsList
.
length
);
}
private
createOverlayContainer
(
parent
:
HTMLElement
):
void
{
this
.
overlayContainer
=
DOM
.
append
(
parent
,
$
(
'
.overlay-container
'
));
this
.
overlayContainer
.
style
.
position
=
'
absolute
'
;
this
.
overlayContainer
.
style
.
zIndex
=
'
10
'
;
this
.
defineKeybindingWidget
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
DefineKeybindingWidget
,
this
.
overlayContainer
));
this
.
_register
(
this
.
defineKeybindingWidget
.
onDidChange
(
keybindingStr
=>
this
.
showOverlayConflicts
(
keybindingStr
)));
this
.
_register
(
this
.
defineKeybindingWidget
.
on
LinkClick
(
keybindingStr
=>
{
this
.
showSimilarKeybindings
(
this
.
keybindingsEditorModel
.
fetch
(
`
${
keybindingStr
}
`
,
this
.
sortByPrecedence
.
checked
)[
0
]);
}
));
this
.
_register
(
this
.
defineKeybindingWidget
.
onDidChange
(
keybindingStr
=>
this
.
defineKeybindingWidget
.
printExisting
(
this
.
keybindingsEditorModel
.
fetch
(
`"
${
keybindingStr
}
"`
).
length
)));
this
.
_register
(
this
.
defineKeybindingWidget
.
on
ShowExistingKeybidings
(
keybindingStr
=>
this
.
searchWidget
.
setValue
(
`"
${
keybindingStr
}
"`
)
));
this
.
hideOverlayContainer
();
}
...
...
src/vs/workbench/parts/preferences/browser/media/keybindings.css
浏览文件 @
8d53ee62
...
...
@@ -15,7 +15,7 @@
.defineKeybindingWidget
.monaco-inputbox
,
.defineKeybindingWidget
.output
,
.defineKeybindingWidget
.
conflicts
{
.defineKeybindingWidget
.
existing
{
margin-top
:
10px
;
width
:
400px
;
display
:
block
;
...
...
@@ -31,7 +31,7 @@
justify-content
:
center
;
}
.defineKeybindingWidget
.
conflicts
.conflict
Text
{
.defineKeybindingWidget
.
existing
.existing
Text
{
text-decoration
:
underline
;
cursor
:
pointer
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录