Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
5b70dcfb
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,发现更多精彩内容 >>
提交
5b70dcfb
编写于
11月 21, 2019
作者:
M
Martin Aeschlimann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use token color map in textmate service
上级
ff72b610
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
19 addition
and
15 deletion
+19
-15
src/vs/workbench/services/textMate/browser/abstractTextMateService.ts
...ench/services/textMate/browser/abstractTextMateService.ts
+9
-5
src/vs/workbench/services/textMate/common/TMGrammarFactory.ts
...vs/workbench/services/textMate/common/TMGrammarFactory.ts
+2
-2
src/vs/workbench/services/textMate/electron-browser/textMateService.ts
...nch/services/textMate/electron-browser/textMateService.ts
+6
-6
src/vs/workbench/services/textMate/electron-browser/textMateWorker.ts
...ench/services/textMate/electron-browser/textMateWorker.ts
+2
-2
未找到文件。
src/vs/workbench/services/textMate/browser/abstractTextMateService.ts
浏览文件 @
5b70dcfb
...
...
@@ -10,6 +10,7 @@ import { onUnexpectedError } from 'vs/base/common/errors';
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
*
as
resources
from
'
vs/base/common/resources
'
;
import
*
as
types
from
'
vs/base/common/types
'
;
import
{
equals
as
equalArray
}
from
'
vs/base/common/arrays
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
TokenizationResult
,
TokenizationResult2
}
from
'
vs/editor/common/core/token
'
;
import
{
IState
,
ITokenizationSupport
,
LanguageId
,
TokenMetadata
,
TokenizationRegistry
,
StandardTokenType
,
LanguageIdentifier
}
from
'
vs/editor/common/modes
'
;
...
...
@@ -44,6 +45,7 @@ export abstract class AbstractTextMateService extends Disposable implements ITex
private
_grammarFactory
:
TMGrammarFactory
|
null
;
private
_tokenizersRegistrations
:
IDisposable
[];
protected
_currentTheme
:
IRawTheme
|
null
;
protected
_currentTokenColorMap
:
string
[]
|
null
;
constructor
(
@
IModeService
private
readonly
_modeService
:
IModeService
,
...
...
@@ -65,6 +67,7 @@ export abstract class AbstractTextMateService extends Disposable implements ITex
this
.
_tokenizersRegistrations
=
[];
this
.
_currentTheme
=
null
;
this
.
_currentTokenColorMap
=
null
;
grammarsExtPoint
.
setHandler
((
extensions
)
=>
{
this
.
_grammarDefinitions
=
null
;
...
...
@@ -245,16 +248,17 @@ export abstract class AbstractTextMateService extends Disposable implements ITex
}
private
_updateTheme
(
grammarFactory
:
TMGrammarFactory
,
colorTheme
:
IColorTheme
,
forceUpdate
:
boolean
):
void
{
if
(
!
forceUpdate
&&
this
.
_currentTheme
&&
AbstractTextMateService
.
equalsTokenRules
(
this
.
_currentTheme
.
settings
,
colorTheme
.
tokenColors
))
{
if
(
!
forceUpdate
&&
this
.
_currentTheme
&&
this
.
_currentTokenColorMap
&&
AbstractTextMateService
.
equalsTokenRules
(
this
.
_currentTheme
.
settings
,
colorTheme
.
tokenColors
)
&&
equalArray
(
this
.
_currentTokenColorMap
,
colorTheme
.
tokenColorMap
))
{
return
;
}
this
.
_currentTheme
=
{
name
:
colorTheme
.
label
,
settings
:
colorTheme
.
tokenColors
};
this
.
_doUpdateTheme
(
grammarFactory
,
this
.
_currentTheme
);
this
.
_currentTokenColorMap
=
colorTheme
.
tokenColorMap
;
this
.
_doUpdateTheme
(
grammarFactory
,
this
.
_currentTheme
,
this
.
_currentTokenColorMap
);
}
protected
_doUpdateTheme
(
grammarFactory
:
TMGrammarFactory
,
theme
:
IRawTheme
):
void
{
grammarFactory
.
setTheme
(
theme
);
let
colorMap
=
AbstractTextMateService
.
_toColorMap
(
grammarFactory
.
getColorMap
()
);
protected
_doUpdateTheme
(
grammarFactory
:
TMGrammarFactory
,
theme
:
IRawTheme
,
tokenColorMap
:
string
[]
):
void
{
grammarFactory
.
setTheme
(
theme
,
tokenColorMap
);
let
colorMap
=
AbstractTextMateService
.
_toColorMap
(
tokenColorMap
);
let
cssRules
=
generateTokensCSSForColorMap
(
colorMap
);
this
.
_styleElement
.
innerHTML
=
cssRules
;
TokenizationRegistry
.
setColorMap
(
colorMap
);
...
...
src/vs/workbench/services/textMate/common/TMGrammarFactory.ts
浏览文件 @
5b70dcfb
...
...
@@ -102,8 +102,8 @@ export class TMGrammarFactory extends Disposable {
return
this
.
_languageToScope2
[
languageId
]
?
true
:
false
;
}
public
setTheme
(
theme
:
IRawTheme
):
void
{
this
.
_grammarRegistry
.
setTheme
(
theme
);
public
setTheme
(
theme
:
IRawTheme
,
colorMap
:
string
[]
):
void
{
this
.
_grammarRegistry
.
setTheme
(
theme
,
colorMap
);
}
public
getColorMap
():
string
[]
{
...
...
src/vs/workbench/services/textMate/electron-browser/textMateService.ts
浏览文件 @
5b70dcfb
...
...
@@ -206,18 +206,18 @@ export class TextMateService extends AbstractTextMateService {
return
;
}
this
.
_workerProxy
=
proxy
;
if
(
this
.
_currentTheme
)
{
this
.
_workerProxy
.
acceptTheme
(
this
.
_currentTheme
);
if
(
this
.
_currentTheme
&&
this
.
_currentTokenColorMap
)
{
this
.
_workerProxy
.
acceptTheme
(
this
.
_currentTheme
,
this
.
_currentTokenColorMap
);
}
this
.
_modelService
.
getModels
().
forEach
((
model
)
=>
this
.
_onModelAdded
(
model
));
});
}
}
protected
_doUpdateTheme
(
grammarFactory
:
TMGrammarFactory
,
theme
:
IRawTheme
):
void
{
super
.
_doUpdateTheme
(
grammarFactory
,
theme
);
if
(
this
.
_currentTheme
&&
this
.
_workerProxy
)
{
this
.
_workerProxy
.
acceptTheme
(
this
.
_currentTheme
);
protected
_doUpdateTheme
(
grammarFactory
:
TMGrammarFactory
,
theme
:
IRawTheme
,
colorMap
:
string
[]
):
void
{
super
.
_doUpdateTheme
(
grammarFactory
,
theme
,
colorMap
);
if
(
this
.
_currentTheme
&&
this
.
_
currentTokenColorMap
&&
this
.
_
workerProxy
)
{
this
.
_workerProxy
.
acceptTheme
(
this
.
_currentTheme
,
this
.
_currentTokenColorMap
);
}
}
...
...
src/vs/workbench/services/textMate/electron-browser/textMateWorker.ts
浏览文件 @
5b70dcfb
...
...
@@ -185,9 +185,9 @@ export class TextMateWorker {
return
this
.
_grammarCache
[
languageId
];
}
public
acceptTheme
(
theme
:
IRawTheme
):
void
{
public
acceptTheme
(
theme
:
IRawTheme
,
colorMap
:
string
[]
):
void
{
if
(
this
.
_grammarFactory
)
{
this
.
_grammarFactory
.
setTheme
(
theme
);
this
.
_grammarFactory
.
setTheme
(
theme
,
colorMap
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录