Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
736e6f4e
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,发现更多精彩内容 >>
提交
736e6f4e
编写于
3月 10, 2017
作者:
M
Martin Aeschlimann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
color defaults API
上级
15280c34
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
65 addition
and
4 deletion
+65
-4
src/vs/platform/theme/common/themeService.ts
src/vs/platform/theme/common/themeService.ts
+1
-1
src/vs/platform/theme/common/themingRegistry.ts
src/vs/platform/theme/common/themingRegistry.ts
+64
-3
未找到文件。
src/vs/platform/theme/common/themeService.ts
浏览文件 @
736e6f4e
...
...
@@ -14,7 +14,7 @@ export let IThemeService = createDecorator<IThemeService>('themeService');
export
interface
ITheme
{
readonly
selector
:
string
;
readonly
label
:
string
;
getColor
(
color
Id
:
string
):
Color
;
getColor
(
color
:
string
):
Color
;
isLightTheme
():
boolean
;
isDarkTheme
():
boolean
;
...
...
src/vs/platform/theme/common/themingRegistry.ts
浏览文件 @
736e6f4e
...
...
@@ -6,6 +6,9 @@
import
platform
=
require
(
'
vs/platform/platform
'
);
import
{
IJSONSchema
}
from
'
vs/base/common/jsonSchema
'
;
import
{
Color
}
from
'
vs/base/common/color
'
;
import
{
ITheme
}
from
'
vs/platform/theme/common/themeService
'
;
import
nls
=
require
(
'
vs/nls
'
);
...
...
@@ -16,20 +19,39 @@ export const Extensions = {
export
interface
IColorContribution
{
readonly
id
:
string
;
readonly
description
:
string
;
readonly
defaults
:
ColorDefaults
;
}
export
interface
DerivedColor
{
(
theme
:
ITheme
):
Color
;
}
export
interface
ColorDefaults
{
light
:
ColorDescription
;
dark
:
ColorDescription
;
hc
:
ColorDescription
;
}
export
type
ColorDescription
=
string
|
IColorContribution
|
DerivedColor
;
export
interface
IThemingRegistry
{
/**
* Register a color to the registry.
*/
registerColor
(
id
:
string
,
description
:
string
):
IColorContribution
;
registerColor
(
id
:
string
,
description
:
string
,
defaults
?:
ColorDefaults
):
IColorContribution
;
/**
* Get all color contributions
*/
getColors
():
IColorContribution
[];
/**
* Gets the color of the given id
*/
getColor
(
id
:
string
):
IColorContribution
;
/**
* JSON schema of all colors
*/
...
...
@@ -37,6 +59,16 @@ export interface IThemingRegistry {
}
export
function
darken
(
colorDesc
:
ColorDescription
,
factor
:
number
):
DerivedColor
{
return
(
theme
)
=>
{
let
color
=
resolveDescription
(
theme
,
colorDesc
);
if
(
color
)
{
return
color
.
darken
(
factor
);
}
return
null
;
};
}
class
ThemingRegistry
implements
IThemingRegistry
{
private
colorsById
:
{
[
key
:
string
]:
IColorContribution
};
...
...
@@ -46,8 +78,8 @@ class ThemingRegistry implements IThemingRegistry {
this
.
colorsById
=
{};
}
public
registerColor
(
id
:
string
,
description
:
string
):
IColorContribution
{
let
colorContribution
:
IColorContribution
=
{
id
,
description
};
public
registerColor
(
id
:
string
,
description
:
string
,
defaults
:
ColorDefaults
)
{
let
colorContribution
:
IColorContribution
=
{
id
,
description
,
defaults
};
this
.
colorsById
[
id
]
=
colorContribution
;
this
.
colorSchema
.
properties
[
id
]
=
{
type
:
'
string
'
,
description
};
return
colorContribution
;
...
...
@@ -57,11 +89,40 @@ class ThemingRegistry implements IThemingRegistry {
return
Object
.
keys
(
this
.
colorsById
).
map
(
id
=>
this
.
colorsById
[
id
]);
}
public
getColor
(
id
:
string
):
IColorContribution
{
return
this
.
colorsById
[
id
];
}
public
getColorSchema
():
IJSONSchema
{
return
this
.
colorSchema
;
}
}
function
resolveDescription
(
theme
:
ITheme
,
colorDesc
:
ColorDescription
):
Color
{
if
(
typeof
colorDesc
===
'
string
'
)
{
return
Color
.
fromHex
(
colorDesc
);
}
else
if
(
typeof
colorDesc
===
'
object
'
&&
colorDesc
!==
null
)
{
let
defaults
=
colorDesc
.
defaults
;
if
(
!
defaults
)
{
return
null
;
}
if
(
theme
.
isDarkTheme
())
{
return
resolveDescription
(
theme
,
defaults
.
dark
);
}
else
if
(
theme
.
isLightTheme
())
{
return
resolveDescription
(
theme
,
defaults
.
light
);
}
else
{
return
resolveDescription
(
theme
,
defaults
.
hc
);
}
}
else
if
(
typeof
colorDesc
===
'
function
'
)
{
return
colorDesc
(
theme
);
}
else
{
return
null
;
}
}
const
themingRegistry
=
new
ThemingRegistry
();
platform
.
Registry
.
add
(
Extensions
.
ThemingContribution
,
themingRegistry
);
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录