Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
071ccc6d
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,体验更适合开发者的 AI 搜索 >>
提交
071ccc6d
编写于
3月 10, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move keybinding reading out of keybindingLabel
上级
95844db8
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
87 addition
and
94 deletion
+87
-94
src/vs/platform/keybinding/common/keybindingIO.ts
src/vs/platform/keybinding/common/keybindingIO.ts
+82
-2
src/vs/platform/keybinding/common/keybindingLabels.ts
src/vs/platform/keybinding/common/keybindingLabels.ts
+1
-88
src/vs/workbench/parts/extensions/browser/extensionEditor.ts
src/vs/workbench/parts/extensions/browser/extensionEditor.ts
+2
-2
src/vs/workbench/parts/update/electron-browser/update.ts
src/vs/workbench/parts/update/electron-browser/update.ts
+2
-2
未找到文件。
src/vs/platform/keybinding/common/keybindingIO.ts
浏览文件 @
071ccc6d
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
Keybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
Keybinding
,
KeyMod
,
KeyChord
,
USER_SETTINGS
}
from
'
vs/base/common/keyCodes
'
;
import
{
ISimplifiedPlatform
,
KeybindingLabels
}
from
'
vs/platform/keybinding/common/keybindingLabels
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
{
IKeybindingItem
,
IUserFriendlyKeybinding
}
from
'
vs/platform/keybinding/common/keybinding
'
;
...
...
@@ -66,7 +66,87 @@ export class KeybindingIO {
}
public
static
readKeybinding
(
input
:
string
,
Platform
:
ISimplifiedPlatform
=
platform
):
number
{
return
KeybindingLabels
.
fromUserSettingsLabel
(
input
,
Platform
);
if
(
!
input
)
{
return
null
;
}
input
=
input
.
toLowerCase
().
trim
();
let
ctrlCmd
=
false
,
shift
=
false
,
alt
=
false
,
winCtrl
=
false
,
key
:
string
=
''
;
while
(
/^
(
ctrl|shift|alt|meta|win|cmd
)(\+
|
\-)
/
.
test
(
input
))
{
if
(
/^ctrl
(\+
|
\-)
/
.
test
(
input
))
{
if
(
Platform
.
isMacintosh
)
{
winCtrl
=
true
;
}
else
{
ctrlCmd
=
true
;
}
input
=
input
.
substr
(
'
ctrl-
'
.
length
);
}
if
(
/^shift
(\+
|
\-)
/
.
test
(
input
))
{
shift
=
true
;
input
=
input
.
substr
(
'
shift-
'
.
length
);
}
if
(
/^alt
(\+
|
\-)
/
.
test
(
input
))
{
alt
=
true
;
input
=
input
.
substr
(
'
alt-
'
.
length
);
}
if
(
/^meta
(\+
|
\-)
/
.
test
(
input
))
{
if
(
Platform
.
isMacintosh
)
{
ctrlCmd
=
true
;
}
else
{
winCtrl
=
true
;
}
input
=
input
.
substr
(
'
meta-
'
.
length
);
}
if
(
/^win
(\+
|
\-)
/
.
test
(
input
))
{
if
(
Platform
.
isMacintosh
)
{
ctrlCmd
=
true
;
}
else
{
winCtrl
=
true
;
}
input
=
input
.
substr
(
'
win-
'
.
length
);
}
if
(
/^cmd
(\+
|
\-)
/
.
test
(
input
))
{
if
(
Platform
.
isMacintosh
)
{
ctrlCmd
=
true
;
}
else
{
winCtrl
=
true
;
}
input
=
input
.
substr
(
'
cmd-
'
.
length
);
}
}
let
chord
:
number
=
0
;
let
firstSpaceIdx
=
input
.
indexOf
(
'
'
);
if
(
firstSpaceIdx
>
0
)
{
key
=
input
.
substring
(
0
,
firstSpaceIdx
);
chord
=
KeybindingIO
.
readKeybinding
(
input
.
substring
(
firstSpaceIdx
),
Platform
);
}
else
{
key
=
input
;
}
let
keyCode
=
USER_SETTINGS
.
toKeyCode
(
key
);
let
result
=
0
;
if
(
ctrlCmd
)
{
result
|=
KeyMod
.
CtrlCmd
;
}
if
(
shift
)
{
result
|=
KeyMod
.
Shift
;
}
if
(
alt
)
{
result
|=
KeyMod
.
Alt
;
}
if
(
winCtrl
)
{
result
|=
KeyMod
.
WinCtrl
;
}
result
|=
keyCode
;
return
KeyChord
(
result
,
chord
);
}
}
...
...
src/vs/platform/keybinding/common/keybindingLabels.ts
浏览文件 @
071ccc6d
...
...
@@ -8,7 +8,7 @@
import
*
as
nls
from
'
vs/nls
'
;
import
*
as
defaultPlatform
from
'
vs/base/common/platform
'
;
import
{
IHTMLContentElement
}
from
'
vs/base/common/htmlContent
'
;
import
{
Keybinding
,
SimpleKeybinding
,
KeyCode
,
Key
Mod
,
KeyChord
,
Key
CodeUtils
,
USER_SETTINGS
}
from
'
vs/base/common/keyCodes
'
;
import
{
Keybinding
,
SimpleKeybinding
,
KeyCode
,
KeyCodeUtils
,
USER_SETTINGS
}
from
'
vs/base/common/keyCodes
'
;
export
interface
ISimplifiedPlatform
{
isMacintosh
:
boolean
;
...
...
@@ -54,93 +54,6 @@ export class KeybindingLabels {
return
result
;
}
/**
* @internal
*/
public
static
fromUserSettingsLabel
(
input
:
string
,
Platform
:
ISimplifiedPlatform
=
defaultPlatform
):
number
{
if
(
!
input
)
{
return
null
;
}
input
=
input
.
toLowerCase
().
trim
();
let
ctrlCmd
=
false
,
shift
=
false
,
alt
=
false
,
winCtrl
=
false
,
key
:
string
=
''
;
while
(
/^
(
ctrl|shift|alt|meta|win|cmd
)(\+
|
\-)
/
.
test
(
input
))
{
if
(
/^ctrl
(\+
|
\-)
/
.
test
(
input
))
{
if
(
Platform
.
isMacintosh
)
{
winCtrl
=
true
;
}
else
{
ctrlCmd
=
true
;
}
input
=
input
.
substr
(
'
ctrl-
'
.
length
);
}
if
(
/^shift
(\+
|
\-)
/
.
test
(
input
))
{
shift
=
true
;
input
=
input
.
substr
(
'
shift-
'
.
length
);
}
if
(
/^alt
(\+
|
\-)
/
.
test
(
input
))
{
alt
=
true
;
input
=
input
.
substr
(
'
alt-
'
.
length
);
}
if
(
/^meta
(\+
|
\-)
/
.
test
(
input
))
{
if
(
Platform
.
isMacintosh
)
{
ctrlCmd
=
true
;
}
else
{
winCtrl
=
true
;
}
input
=
input
.
substr
(
'
meta-
'
.
length
);
}
if
(
/^win
(\+
|
\-)
/
.
test
(
input
))
{
if
(
Platform
.
isMacintosh
)
{
ctrlCmd
=
true
;
}
else
{
winCtrl
=
true
;
}
input
=
input
.
substr
(
'
win-
'
.
length
);
}
if
(
/^cmd
(\+
|
\-)
/
.
test
(
input
))
{
if
(
Platform
.
isMacintosh
)
{
ctrlCmd
=
true
;
}
else
{
winCtrl
=
true
;
}
input
=
input
.
substr
(
'
cmd-
'
.
length
);
}
}
let
chord
:
number
=
0
;
let
firstSpaceIdx
=
input
.
indexOf
(
'
'
);
if
(
firstSpaceIdx
>
0
)
{
key
=
input
.
substring
(
0
,
firstSpaceIdx
);
chord
=
KeybindingLabels
.
fromUserSettingsLabel
(
input
.
substring
(
firstSpaceIdx
),
Platform
);
}
else
{
key
=
input
;
}
let
keyCode
=
USER_SETTINGS
.
toKeyCode
(
key
);
let
result
=
0
;
if
(
ctrlCmd
)
{
result
|=
KeyMod
.
CtrlCmd
;
}
if
(
shift
)
{
result
|=
KeyMod
.
Shift
;
}
if
(
alt
)
{
result
|=
KeyMod
.
Alt
;
}
if
(
winCtrl
)
{
result
|=
KeyMod
.
WinCtrl
;
}
result
|=
keyCode
;
return
KeyChord
(
result
,
chord
);
}
/**
* Format the binding to a format appropiate for rendering in the UI
* @internal
...
...
src/vs/workbench/parts/extensions/browser/extensionEditor.ts
浏览文件 @
071ccc6d
...
...
@@ -37,7 +37,7 @@ import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import
{
CombinedInstallAction
,
UpdateAction
,
EnableAction
,
DisableAction
,
BuiltinStatusLabelAction
,
ReloadAction
}
from
'
vs/workbench/parts/extensions/browser/extensionsActions
'
;
import
WebView
from
'
vs/workbench/parts/html/browser/webview
'
;
import
{
createKeybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
Keybinding
Labels
}
from
'
vs/platform/keybinding/common/keybindingLabels
'
;
import
{
Keybinding
IO
}
from
'
vs/platform/keybinding/common/keybindingIO
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
DomScrollableElement
}
from
'
vs/base/browser/ui/scrollbar/scrollableElement
'
;
import
{
IMessageService
}
from
'
vs/platform/message/common/message
'
;
...
...
@@ -669,7 +669,7 @@ export class ExtensionEditor extends BaseEditor {
case
'
darwin
'
:
key
=
rawKeyBinding
.
mac
;
break
;
}
const
keyBinding
=
createKeybinding
(
Keybinding
Labels
.
fromUserSettingsLabel
(
key
||
rawKeyBinding
.
key
));
const
keyBinding
=
createKeybinding
(
Keybinding
IO
.
readKeybinding
(
key
||
rawKeyBinding
.
key
));
const
resolvedKeybinding
=
this
.
keybindingService
.
resolveKeybinding
(
keyBinding
);
const
result
=
resolvedKeybinding
.
getLabel
();
return
result
===
'
unknown
'
?
null
:
result
;
...
...
src/vs/workbench/parts/update/electron-browser/update.ts
浏览文件 @
071ccc6d
...
...
@@ -20,7 +20,7 @@ import { IRequestService } from 'vs/platform/request/node/request';
import
{
asText
}
from
'
vs/base/node/request
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
createKeybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
Keybinding
Labels
}
from
'
vs/platform/keybinding/common/keybindingLabels
'
;
import
{
Keybinding
IO
}
from
'
vs/platform/keybinding/common/keybindingIO
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
IWorkbenchContribution
}
from
'
vs/workbench/common/contributions
'
;
import
{
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
...
...
@@ -73,7 +73,7 @@ export function loadReleaseNotes(accessor: ServicesAccessor, version: string): T
};
const
kbstyle
=
(
match
:
string
,
kb
:
string
)
=>
{
const
code
=
Keybinding
Labels
.
fromUserSettingsLabel
(
kb
);
const
code
=
Keybinding
IO
.
readKeybinding
(
kb
);
if
(
!
code
)
{
return
unassigned
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录