Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
46df55c9
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,发现更多精彩内容 >>
提交
46df55c9
编写于
10月 08, 2016
作者:
D
Daniel Imms
提交者:
GitHub
10月 08, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #13169 from Microsoft/tyriar/6979_terminal_themes
Enable terminal themes via tmTheme
上级
cb8e95c0
349b95cd
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
70 addition
and
1 deletion
+70
-1
src/vs/workbench/services/themes/electron-browser/stylesContributions.ts
...h/services/themes/electron-browser/stylesContributions.ts
+68
-0
src/vs/workbench/services/themes/electron-browser/themeService.ts
...orkbench/services/themes/electron-browser/themeService.ts
+2
-1
未找到文件。
src/vs/workbench/services/themes/electron-browser/stylesContributions.ts
浏览文件 @
46df55c9
...
...
@@ -34,6 +34,23 @@ interface ThemeGlobalSettings {
referenceHighlight
?:
string
;
activeLinkForeground
?:
string
;
ansiBlack
?:
string
;
ansiRed
?:
string
;
ansiGreen
?:
string
;
ansiYellow
?:
string
;
ansiBlue
?:
string
;
ansiMagenta
?:
string
;
ansiCyan
?:
string
;
ansiWhite
?:
string
;
ansiBrightBlack
?:
string
;
ansiBrightRed
?:
string
;
ansiBrightGreen
?:
string
;
ansiBrightYellow
?:
string
;
ansiBrightBlue
?:
string
;
ansiBrightMagenta
?:
string
;
ansiBrightCyan
?:
string
;
ansiBrightWhite
?:
string
;
}
class
Theme
{
...
...
@@ -170,6 +187,57 @@ export class SearchViewStylesContribution {
}
}
export
class
TerminalStylesContribution
{
private
static
ansiColorMap
=
{
ansiBlack
:
0
,
ansiRed
:
1
,
ansiGreen
:
2
,
ansiYellow
:
3
,
ansiBlue
:
4
,
ansiMagenta
:
5
,
ansiCyan
:
6
,
ansiWhite
:
7
,
ansiBrightBlack
:
8
,
ansiBrightRed
:
9
,
ansiBrightGreen
:
10
,
ansiBrightYellow
:
11
,
ansiBrightBlue
:
12
,
ansiBrightMagenta
:
13
,
ansiBrightCyan
:
14
,
ansiBrightWhite
:
15
};
/**
* Converts a CSS hex color (#rrggbb) to a CSS rgba color (rgba(r, g, b, a)).
*/
private
_convertHexCssColorToRgba
(
hex
:
string
,
alpha
:
number
):
string
{
const
r
=
parseInt
(
hex
.
substr
(
1
,
2
),
16
);
const
g
=
parseInt
(
hex
.
substr
(
3
,
2
),
16
);
const
b
=
parseInt
(
hex
.
substr
(
5
,
2
),
16
);
return
`rgba(
${
r
}
,
${
g
}
,
${
b
}
,
${
alpha
}
)`
;
}
public
contributeStyles
(
themeId
:
string
,
themeDocument
:
IThemeDocument
,
cssRules
:
string
[]):
void
{
const
theme
=
new
Theme
(
themeId
,
themeDocument
);
if
(
theme
.
hasGlobalSettings
())
{
const
keys
=
Object
.
keys
(
theme
.
getGlobalSettings
());
keys
.
filter
(
key
=>
key
.
indexOf
(
'
ansi
'
)
===
0
).
forEach
(
key
=>
{
if
(
key
in
TerminalStylesContribution
.
ansiColorMap
)
{
const
color
=
theme
.
getGlobalSettings
()[
key
];
const
index
=
TerminalStylesContribution
.
ansiColorMap
[
key
];
const
rgba
=
this
.
_convertHexCssColorToRgba
(
color
,
0.996
);
cssRules
.
push
(
`.
${
theme
.
getSelector
()}
.panel.integrated-terminal .xterm .xterm-color-
${
index
}
{ color:
${
color
}
; }`
);
cssRules
.
push
(
`.
${
theme
.
getSelector
()}
.panel.integrated-terminal .xterm .xterm-color-
${
index
}
::selection { background-color:
${
rgba
}
; }`
);
cssRules
.
push
(
`.
${
theme
.
getSelector
()}
.panel.integrated-terminal .xterm .xterm-bg-color-
${
index
}
{ background-color:
${
color
}
; }`
);
cssRules
.
push
(
`.
${
theme
.
getSelector
()}
.panel.integrated-terminal .xterm .xterm-bg-color-
${
index
}
::selection { color:
${
color
}
; }`
);
}
});
}
}
}
abstract
class
EditorStyleRules
extends
StyleRules
{
protected
addBackgroundColorRule
(
theme
:
Theme
,
selector
:
string
,
color
:
string
|
Color
,
rules
:
string
[]):
void
{
...
...
src/vs/workbench/services/themes/electron-browser/themeService.ts
浏览文件 @
46df55c9
...
...
@@ -12,7 +12,7 @@ import { IThemeExtensionPoint } from 'vs/platform/theme/common/themeExtensionPoi
import
{
IExtensionService
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
ExtensionsRegistry
,
IExtensionMessageCollector
}
from
'
vs/platform/extensions/common/extensionsRegistry
'
;
import
{
IThemeService
,
IThemeData
,
IThemeSetting
,
IThemeDocument
}
from
'
vs/workbench/services/themes/common/themeService
'
;
import
{
TokenStylesContribution
,
EditorStylesContribution
,
SearchViewStylesContribution
}
from
'
vs/workbench/services/themes/electron-browser/stylesContributions
'
;
import
{
TokenStylesContribution
,
EditorStylesContribution
,
SearchViewStylesContribution
,
TerminalStylesContribution
}
from
'
vs/workbench/services/themes/electron-browser/stylesContributions
'
;
import
{
getBaseThemeId
}
from
'
vs/platform/theme/common/themes
'
;
import
{
IWindowService
}
from
'
vs/workbench/services/window/electron-browser/windowService
'
;
import
{
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
...
...
@@ -637,6 +637,7 @@ function _processThemeObject(themeId: string, themeDocument: IThemeDocument): st
new
TokenStylesContribution
().
contributeStyles
(
themeId
,
themeDocument
,
cssRules
);
new
EditorStylesContribution
().
contributeStyles
(
themeId
,
themeDocument
,
cssRules
);
new
SearchViewStylesContribution
().
contributeStyles
(
themeId
,
themeDocument
,
cssRules
);
new
TerminalStylesContribution
().
contributeStyles
(
themeId
,
themeDocument
,
cssRules
);
}
return
cssRules
.
join
(
'
\n
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录