Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
d4d94b1d
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,发现更多精彩内容 >>
提交
d4d94b1d
编写于
5月 21, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #27019
上级
6b1a8e89
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
53 addition
and
26 deletion
+53
-26
src/vs/workbench/parts/preferences/browser/keybindingsEditorContribution.ts
...arts/preferences/browser/keybindingsEditorContribution.ts
+53
-26
未找到文件。
src/vs/workbench/parts/preferences/browser/keybindingsEditorContribution.ts
浏览文件 @
d4d94b1d
...
...
@@ -42,51 +42,82 @@ export class DefineKeybindingController extends Disposable implements editorComm
return
editor
.
getContribution
<
DefineKeybindingController
>
(
DefineKeybindingController
.
ID
);
}
private
_keybindingEditorRenderer
:
KeybindingEditorRenderer
;
private
_keybindingWidgetRenderer
:
KeybindingWidgetRenderer
;
private
_keybindingDecorationRenderer
:
KeybindingEditorDecorationsRenderer
;
constructor
(
private
_editor
:
ICodeEditor
,
@
IKeybindingService
keybindingService
:
IKeybindingService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
@
IInstantiationService
private
_instantiationService
:
IInstantiationService
)
{
super
();
this
.
_register
(
this
.
_editor
.
onDidChangeModel
(
e
=>
this
.
_renderKeybindingEditor
()));
this
.
_renderKeybindingEditor
();
this
.
_keybindingWidgetRenderer
=
null
;
this
.
_keybindingDecorationRenderer
=
null
;
this
.
_register
(
this
.
_editor
.
onDidChangeModel
(
e
=>
this
.
_update
()));
this
.
_update
();
}
public
getId
():
string
{
return
DefineKeybindingController
.
ID
;
}
public
get
keybinding
EditorRenderer
():
KeybindingEditor
Renderer
{
return
this
.
_keybinding
Editor
Renderer
;
public
get
keybinding
WidgetRenderer
():
KeybindingWidget
Renderer
{
return
this
.
_keybinding
Widget
Renderer
;
}
public
dispose
():
void
{
this
.
_disposeKeybindingEditorRenderer
();
this
.
_disposeKeybindingWidgetRenderer
();
this
.
_disposeKeybindingDecorationRenderer
();
super
.
dispose
();
}
private
_renderKeybindingEditor
():
void
{
if
(
isInterestingEditorModel
(
this
.
_editor
))
{
if
(
!
this
.
_keybindingEditorRenderer
)
{
this
.
_keybindingEditorRenderer
=
this
.
instantiationService
.
createInstance
(
KeybindingEditorRenderer
,
this
.
_editor
);
private
_update
():
void
{
if
(
!
isInterestingEditorModel
(
this
.
_editor
))
{
this
.
_disposeKeybindingWidgetRenderer
();
this
.
_disposeKeybindingDecorationRenderer
();
return
;
}
// Decorations are shown for the default keybindings.json **and** for the user keybindings.json
this
.
_createKeybindingDecorationRenderer
();
// The button to define keybindings is shown only for the user keybindings.json
if
(
!
this
.
_editor
.
getConfiguration
().
readOnly
)
{
this
.
_createKeybindingWidgetRenderer
();
}
else
{
this
.
_disposeKeybindingEditorRenderer
();
this
.
_disposeKeybindingWidgetRenderer
();
}
}
private
_createKeybindingWidgetRenderer
():
void
{
if
(
!
this
.
_keybindingWidgetRenderer
)
{
this
.
_keybindingWidgetRenderer
=
this
.
_instantiationService
.
createInstance
(
KeybindingWidgetRenderer
,
this
.
_editor
);
}
}
private
_disposeKeybindingEditorRenderer
():
void
{
if
(
this
.
_keybindingEditorRenderer
)
{
this
.
_keybindingEditorRenderer
.
dispose
();
this
.
_keybindingEditorRenderer
=
null
;
private
_disposeKeybindingWidgetRenderer
():
void
{
if
(
this
.
_keybindingWidgetRenderer
)
{
this
.
_keybindingWidgetRenderer
.
dispose
();
this
.
_keybindingWidgetRenderer
=
null
;
}
}
private
_createKeybindingDecorationRenderer
():
void
{
if
(
!
this
.
_keybindingDecorationRenderer
)
{
this
.
_keybindingDecorationRenderer
=
this
.
_instantiationService
.
createInstance
(
KeybindingEditorDecorationsRenderer
,
this
.
_editor
);
}
}
private
_disposeKeybindingDecorationRenderer
():
void
{
if
(
this
.
_keybindingDecorationRenderer
)
{
this
.
_keybindingDecorationRenderer
.
dispose
();
this
.
_keybindingDecorationRenderer
=
null
;
}
}
}
export
class
Keybinding
Editor
Renderer
extends
Disposable
{
export
class
Keybinding
Widget
Renderer
extends
Disposable
{
private
_launchWidget
:
FloatingClickWidget
;
private
_defineWidget
:
DefineKeybindingOverlayWidget
;
...
...
@@ -100,7 +131,6 @@ export class KeybindingEditorRenderer extends Disposable {
this
.
_register
(
this
.
_launchWidget
.
onClick
(()
=>
this
.
showDefineKeybindingWidget
()));
this
.
_defineWidget
=
this
.
_register
(
this
.
_instantiationService
.
createInstance
(
DefineKeybindingOverlayWidget
,
this
.
_editor
));
this
.
_register
(
this
.
_instantiationService
.
createInstance
(
KeybindingEditorDecorationsRenderer
,
this
.
_editor
));
this
.
_launchWidget
.
render
();
}
...
...
@@ -314,20 +344,17 @@ class DefineKeybindingCommand extends EditorCommand {
}
public
runEditorCommand
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
):
void
{
if
(
!
isInterestingEditorModel
(
editor
))
{
if
(
!
isInterestingEditorModel
(
editor
)
||
editor
.
getConfiguration
().
readOnly
)
{
return
;
}
let
controller
=
DefineKeybindingController
.
get
(
editor
);
if
(
controller
&&
controller
.
keybinding
Editor
Renderer
)
{
controller
.
keybinding
Editor
Renderer
.
showDefineKeybindingWidget
();
if
(
controller
&&
controller
.
keybinding
Widget
Renderer
)
{
controller
.
keybinding
Widget
Renderer
.
showDefineKeybindingWidget
();
}
}
}
function
isInterestingEditorModel
(
editor
:
editorCommon
.
ICommonCodeEditor
):
boolean
{
if
(
editor
.
getConfiguration
().
readOnly
)
{
return
false
;
}
let
model
=
editor
.
getModel
();
if
(
!
model
)
{
return
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录