Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
6ded24bc
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,发现更多精彩内容 >>
提交
6ded24bc
编写于
1月 23, 2019
作者:
M
Martin Aeschlimann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make color contribution point dynamic
上级
6220dcd9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
76 addition
and
32 deletion
+76
-32
extensions/rust/package.json
extensions/rust/package.json
+11
-11
src/vs/platform/theme/common/colorRegistry.ts
src/vs/platform/theme/common/colorRegistry.ts
+43
-9
src/vs/workbench/services/themes/common/colorExtensionPoint.ts
...s/workbench/services/themes/common/colorExtensionPoint.ts
+22
-12
未找到文件。
extensions/rust/package.json
浏览文件 @
6ded24bc
...
...
@@ -9,16 +9,16 @@
"update-grammar"
:
"node ../../build/npm/update-grammar.js zargony/atom-language-rust grammars/rust.cson ./syntaxes/rust.tmLanguage.json"
},
"contributes"
:
{
"languages"
:
[{
"id"
:
"rust"
,
"extensions"
:
[
".rs"
]
,
"aliases"
:
[
"Rust"
,
"rust"
]
,
"configuration"
:
"./language-configuration.json"
}]
,
"grammars"
:
[{
"language"
:
"rust"
,
"path"
:
"./syntaxes/rust.tmLanguage.json"
,
"scopeName"
:
"source.rust"
}
]
"colors"
:
[
{
"id"
:
"rub.addedResourceForeground"
,
"description"
:
"%colors.added%"
,
"defaults"
:
{
"light"
:
"#587c0c"
,
"dark"
:
"#81b88b"
,
"highContrast"
:
"#1b5225"
}
}
]
}
}
\ No newline at end of file
src/vs/platform/theme/common/colorRegistry.ts
浏览文件 @
6ded24bc
...
...
@@ -4,12 +4,14 @@
*--------------------------------------------------------------------------------------------*/
import
*
as
platform
from
'
vs/platform/registry/common/platform
'
;
import
{
IJSONSchema
}
from
'
vs/base/common/jsonSchema
'
;
import
{
IJSONSchema
,
IJSONSchemaMap
}
from
'
vs/base/common/jsonSchema
'
;
import
{
Color
,
RGBA
}
from
'
vs/base/common/color
'
;
import
{
ITheme
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
{
Extensions
as
JSONExtensions
,
IJSONContributionRegistry
}
from
'
vs/platform/jsonschemas/common/jsonContributionRegistry
'
;
import
{
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
// ------ API types
...
...
@@ -46,14 +48,21 @@ export const Extensions = {
export
interface
IColorRegistry
{
readonly
onDidChangeSchema
:
Event
<
void
>
;
/**
* Register a color to the registry.
* @param id The color id as used in theme descrition files
* @param id The color id as used in theme descri
p
tion files
* @param defaults The default values
* @description the description
*/
registerColor
(
id
:
string
,
defaults
:
ColorDefaults
,
description
:
string
):
ColorIdentifier
;
/**
* Register a color to the registry.
*/
deregisterColor
(
id
:
string
);
/**
* Get all color contributions
*/
...
...
@@ -65,12 +74,12 @@ export interface IColorRegistry {
resolveDefaultColor
(
id
:
ColorIdentifier
,
theme
:
ITheme
):
Color
|
null
;
/**
* JSON schema for an object to assign color values to one of the color contrbutions.
* JSON schema for an object to assign color values to one of the color contr
i
butions.
*/
getColorSchema
():
IJSONSchema
;
/**
* JSON schema to for a reference to a color contrbution.
* JSON schema to for a reference to a color contr
i
bution.
*/
getColorReferenceSchema
():
IJSONSchema
;
...
...
@@ -79,9 +88,13 @@ export interface IColorRegistry {
class
ColorRegistry
implements
IColorRegistry
{
private
readonly
_onDidChangeSchema
=
new
Emitter
<
void
>
();
readonly
onDidChangeSchema
:
Event
<
void
>
=
this
.
_onDidChangeSchema
.
event
;
private
colorsById
:
{
[
key
:
string
]:
ColorContribution
};
private
colorSchema
:
IJSONSchema
=
{
type
:
'
object
'
,
properties
:
{}
};
private
colorReferenceSchema
:
IJSONSchema
=
{
type
:
'
string
'
,
enum
:
[],
enumDescriptions
:
[]
};
private
colorSchema
:
IJSONSchema
&
{
properties
:
IJSONSchemaMap
}
=
{
type
:
'
object
'
,
properties
:
{}
};
private
colorReferenceSchema
:
IJSONSchema
&
{
enum
:
string
[],
enumDescriptions
:
string
[]
}
=
{
type
:
'
string
'
,
enum
:
[],
enumDescriptions
:
[]
};
constructor
()
{
this
.
colorsById
=
{};
...
...
@@ -94,12 +107,26 @@ class ColorRegistry implements IColorRegistry {
if
(
deprecationMessage
)
{
propertySchema
.
deprecationMessage
=
deprecationMessage
;
}
this
.
colorSchema
.
properties
!
[
id
]
=
propertySchema
;
this
.
colorReferenceSchema
.
enum
!
.
push
(
id
);
this
.
colorReferenceSchema
.
enumDescriptions
!
.
push
(
description
);
this
.
colorSchema
.
properties
[
id
]
=
propertySchema
;
this
.
colorReferenceSchema
.
enum
.
push
(
id
);
this
.
colorReferenceSchema
.
enumDescriptions
.
push
(
description
);
this
.
_onDidChangeSchema
.
fire
();
return
id
;
}
public
deregisterColor
(
id
:
string
):
void
{
delete
this
.
colorsById
[
id
];
delete
this
.
colorSchema
.
properties
[
id
];
const
index
=
this
.
colorReferenceSchema
.
enum
.
indexOf
(
id
);
if
(
index
!==
-
1
)
{
this
.
colorReferenceSchema
.
enum
.
splice
(
index
,
1
);
this
.
colorReferenceSchema
.
enumDescriptions
.
splice
(
index
,
1
);
}
this
.
_onDidChangeSchema
.
fire
();
}
public
getColors
():
ColorContribution
[]
{
return
Object
.
keys
(
this
.
colorsById
).
map
(
id
=>
this
.
colorsById
[
id
]);
}
...
...
@@ -449,6 +476,13 @@ export const workbenchColorsSchemaId = 'vscode://schemas/workbench-colors';
let
schemaRegistry
=
platform
.
Registry
.
as
<
IJSONContributionRegistry
>
(
JSONExtensions
.
JSONContribution
);
schemaRegistry
.
registerSchema
(
workbenchColorsSchemaId
,
colorRegistry
.
getColorSchema
());
const
delayer
=
new
RunOnceScheduler
(()
=>
schemaRegistry
.
notifySchemaChanged
(
workbenchColorsSchemaId
),
200
);
colorRegistry
.
onDidChangeSchema
(()
=>
{
if
(
!
delayer
.
isScheduled
())
{
delayer
.
schedule
();
}
});
// setTimeout(_ => console.log(colorRegistry.toString()), 5000);
...
...
src/vs/workbench/services/themes/common/colorExtensionPoint.ts
浏览文件 @
6ded24bc
...
...
@@ -5,8 +5,9 @@
import
*
as
nls
from
'
vs/nls
'
;
import
{
ExtensionsRegistry
}
from
'
vs/workbench/services/extensions/common/extensionsRegistry
'
;
import
{
registerColor
,
getColorRegistry
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
IColorRegistry
,
Extensions
as
ColorRegistryExtensions
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
Color
}
from
'
vs/base/common/color
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
interface
IColorExtensionPoint
{
id
:
string
;
...
...
@@ -14,11 +15,14 @@ interface IColorExtensionPoint {
defaults
:
{
light
:
string
,
dark
:
string
,
highContrast
:
string
};
}
const
colorReferenceSchema
=
getColorRegistry
().
getColorReferenceSchema
();
const
colorRegistry
:
IColorRegistry
=
Registry
.
as
<
IColorRegistry
>
(
ColorRegistryExtensions
.
ColorContribution
);
const
colorReferenceSchema
=
colorRegistry
.
getColorReferenceSchema
();
const
colorIdPattern
=
'
^
\\
w+[.
\\
w+]*$
'
;
const
configurationExtPoint
=
ExtensionsRegistry
.
registerExtensionPoint
<
IColorExtensionPoint
[]
>
({
extensionPoint
:
'
colors
'
,
isDynamic
:
true
,
jsonSchema
:
{
description
:
nls
.
localize
(
'
contributes.color
'
,
'
Contributes extension defined themable colors
'
),
type
:
'
array
'
,
...
...
@@ -72,8 +76,8 @@ const configurationExtPoint = ExtensionsRegistry.registerExtensionPoint<IColorEx
export
class
ColorExtensionPoint
{
constructor
()
{
configurationExtPoint
.
setHandler
((
extensions
)
=>
{
for
(
const
extension
of
extensions
)
{
configurationExtPoint
.
setHandler
((
extensions
,
delta
)
=>
{
for
(
const
extension
of
delta
.
added
)
{
const
extensionValue
=
<
IColorExtensionPoint
[]
>
extension
.
value
;
const
collector
=
extension
.
collector
;
...
...
@@ -93,30 +97,36 @@ export class ColorExtensionPoint {
return
Color
.
red
;
};
extensionValue
.
forEach
(
extension
=>
{
if
(
typeof
extension
.
id
!==
'
string
'
||
extens
ion
.
id
.
length
===
0
)
{
for
(
const
colorContribution
of
extensionValue
)
{
if
(
typeof
colorContribution
.
id
!==
'
string
'
||
colorContribut
ion
.
id
.
length
===
0
)
{
collector
.
error
(
nls
.
localize
(
'
invalid.id
'
,
"
'configuration.colors.id' must be defined and can not be empty
"
));
return
;
}
if
(
!
extens
ion
.
id
.
match
(
colorIdPattern
))
{
if
(
!
colorContribut
ion
.
id
.
match
(
colorIdPattern
))
{
collector
.
error
(
nls
.
localize
(
'
invalid.id.format
'
,
"
'configuration.colors.id' must follow the word[.word]*
"
));
return
;
}
if
(
typeof
extension
.
description
!==
'
string
'
||
extens
ion
.
id
.
length
===
0
)
{
if
(
typeof
colorContribution
.
description
!==
'
string
'
||
colorContribut
ion
.
id
.
length
===
0
)
{
collector
.
error
(
nls
.
localize
(
'
invalid.description
'
,
"
'configuration.colors.description' must be defined and can not be empty
"
));
return
;
}
let
defaults
=
extens
ion
.
defaults
;
let
defaults
=
colorContribut
ion
.
defaults
;
if
(
!
defaults
||
typeof
defaults
!==
'
object
'
||
typeof
defaults
.
light
!==
'
string
'
||
typeof
defaults
.
dark
!==
'
string
'
||
typeof
defaults
.
highContrast
!==
'
string
'
)
{
collector
.
error
(
nls
.
localize
(
'
invalid.defaults
'
,
"
'configuration.colors.defaults' must be defined and must contain 'light', 'dark' and 'highContrast'
"
));
return
;
}
registerColor
(
extens
ion
.
id
,
{
colorRegistry
.
registerColor
(
colorContribut
ion
.
id
,
{
light
:
parseColorValue
(
defaults
.
light
,
'
configuration.colors.defaults.light
'
),
dark
:
parseColorValue
(
defaults
.
dark
,
'
configuration.colors.defaults.dark
'
),
hc
:
parseColorValue
(
defaults
.
highContrast
,
'
configuration.colors.defaults.highContrast
'
)
},
extension
.
description
);
});
},
colorContribution
.
description
);
}
}
for
(
const
extension
of
delta
.
removed
)
{
const
extensionValue
=
<
IColorExtensionPoint
[]
>
extension
.
value
;
for
(
const
colorContribution
of
extensionValue
)
{
colorRegistry
.
deregisterColor
(
colorContribution
.
id
);
}
}
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录