提交 0785eecd 编写于 作者: M Martin Aeschlimann

Add 'include' to JSON schema

上级 8c846582
{
"name": "Dark+",
"include": "./dark_vs.json",
"settings": [
{
"name": "Types declaration and references",
"scope": ["meta.type.name", "meta.return.type", "meta.return-type", "meta.cast", "meta.type.annotation",
"support.type", "entity.name.class", "entity.name.type", "storage.type.cs", "storage.type.java"],
"scope": [
"meta.type.name",
"meta.return.type",
"meta.return-type",
"meta.cast",
"meta.type.annotation",
"support.type",
"entity.name.class",
"entity.name.type",
"storage.type.cs",
"storage.type.java"
],
"settings": {
"foreground": "#4EC9B0"
}
},
{
"name": "Function declarations",
"scope": ["entity.name.function", "entity.method.name"],
"scope": [
"entity.name.function",
"entity.method.name"
],
"settings": {
"foreground": "#DCDCAA"
}
......@@ -25,7 +39,12 @@
},
{
"name": "Variable and parameter name",
"scope": ["meta.parameter.type.variable", "variable.parameter", "variable", "variable.name"],
"scope": [
"meta.parameter.type.variable",
"variable.parameter",
"variable",
"variable.name"
],
"settings": {
"foreground": "#9CDCFE"
}
......@@ -39,7 +58,10 @@
},
{
"name": "CSS property value",
"scope": ["css.support.property-value", "css.constant.rgb-value"],
"scope": [
"css.support.property-value",
"css.constant.rgb-value"
],
"settings": {
"foreground": "#CE9178"
}
......
{
"name": "Dark Visual Studio",
"settings": [
{
"scope": "string",
"settings": {
"foreground": "#ce9178"
}
},
{
"scope": "string.escape",
"settings": {
"foreground": "#ce9178"
}
},
{
"scope": "emphasis",
"settings": {
"fontStyle": "italic"
}
},
{
"scope": "strong",
"settings": {
"fontStyle": "bold"
}
},
{
"scope": "header",
"settings": {
"foreground": "#000080"
}
},
{
"scope": "comment",
"settings": {
"foreground": "#608b4e"
}
},
{
"scope": "constant.language",
"settings": {
"foreground": "#569cd6"
}
},
{
"scope": "constant.numeric",
"settings": {
"foreground": "#b5cea8"
}
},
{
"scope": "constant.regexp",
"settings": {
"foreground": "#646695"
}
},
{
"scope": "constant.rgb-value",
"settings": {
"foreground": "#d4d4d4"
}
},
{
"scope": "entity.name.tag",
"settings": {
"foreground": "#569cd6"
}
},
{
"scope": "entity.name.function",
"settings": {
"foreground": "#d4d4d4"
}
},
{
"scope": "entity.name.class",
"settings": {
"foreground": "#d4d4d4"
}
},
{
"scope": "entity.name.selector",
"settings": {
"foreground": "#d7ba7d"
}
},
{
"scope": "entity.other.attribute-name",
"settings": {
"foreground": "#9cdcfe"
}
},
{
"scope": "entity.other.attribute-name.css",
"settings": {
"foreground": "#d7ba7d"
}
},
{
"scope": "invalid",
"settings": {
"foreground": "#f44747"
}
},
{
"scope": "markup.underline",
"settings": {
"fontStyle": "underline"
}
},
{
"scope": "markup.bold",
"settings": {
"fontStyle": "bold"
}
},
{
"scope": "markup.heading",
"settings": {
"foreground": "#6796e6"
}
},
{
"scope": "markup.italic",
"settings": {
"fontStyle": "italic"
}
},
{
"scope": "meta.selector",
"settings": {
"foreground": "#d7ba7d"
}
},
{
"scope": "meta.tag",
"settings": {
"foreground": "#808080"
}
},
{
"scope": "meta.preprocessor",
"settings": {
"foreground": "#569cd6"
}
},
{
"scope": "meta.preprocessor.string",
"settings": {
"foreground": "#ce9178"
}
},
{
"scope": "meta.preprocessor.numeric",
"settings": {
"foreground": "#b5cea8"
}
},
{
"scope": "meta.structure.dictionary.key.python",
"settings": {
"foreground": "#9cdcfe"
}
},
{
"scope": "storage",
"settings": {
"foreground": "#569cd6"
}
},
{
"scope": "storage.type",
"settings": {
"foreground": "#569cd6"
}
},
{
"scope": "storage.modifier",
"settings": {
"foreground": "#569cd6"
}
},
{
"scope": "string",
"settings": {
"foreground": "#ce9178"
}
},
{
"scope": "string.tag",
"settings": {
"foreground": "#ce9178"
}
},
{
"scope": "string.value",
"settings": {
"foreground": "#ce9178"
}
},
{
"scope": "string.regexp",
"settings": {
"foreground": "#d16969"
}
},
{
"scope": "support.type.property-name",
"settings": {
"foreground": "#9cdcfe"
}
},
{
"scope": "keyword",
"settings": {
"foreground": "#569cd6"
}
},
{
"scope": "keyword.control",
"settings": {
"foreground": "#569cd6"
}
},
{
"scope": "keyword.control.less",
"settings": {
"foreground": "#d7ba7d"
}
},
{
"scope": "keyword.operator",
"settings": {
"foreground": "#d4d4d4"
}
},
{
"scope": "keyword.operator.new",
"settings": {
"foreground": "#569cd6"
}
},
{
"scope": "keyword.other.unit",
"settings": {
"foreground": "#b5cea8"
}
}
]
}
\ No newline at end of file
{
"name": "Light+",
"include": "./light_vs.json",
"settings": [
{
"name": "Types declaration and references",
"scope": ["meta.type.name", "meta.return.type", "meta.return-type", "meta.cast", "meta.type.annotation",
"support.type", "entity.name.class", "entity.name.type", "storage.type.cs", "storage.type.java"],
"scope": [
"meta.type.name",
"meta.return.type",
"meta.return-type",
"meta.cast",
"meta.type.annotation",
"support.type",
"entity.name.class",
"entity.name.type",
"storage.type.cs",
"storage.type.java"
],
"settings": {
"foreground": "#267f99"
}
},
{
"name": "Function declarations",
"scope": ["entity.name.function", "entity.method.name"],
"scope": [
"entity.name.function",
"entity.method.name"
],
"settings": {
"foreground": "#795E26"
}
......@@ -25,7 +39,12 @@
},
{
"name": "Parameter name",
"scope": ["meta.parameter.type.variable", "variable.parameter", "variable", "variable.name"],
"scope": [
"meta.parameter.type.variable",
"variable.parameter",
"variable",
"variable.name"
],
"settings": {
"foreground": "#001080"
}
......@@ -39,7 +58,11 @@
},
{
"name": "CSS keys",
"scope": ["support.type.property-name.css", "support.type.property-name.less", "support.type.property-name.sass"],
"scope": [
"support.type.property-name.css",
"support.type.property-name.less",
"support.type.property-name.sass"
],
"settings": {
"foreground": "#FF0000"
}
......
{
"name": "Light Visual Studio",
"settings": [
{
"scope": "string",
"settings": {
"foreground": "#a31515"
}
},
{
"scope": "string.escape",
"settings": {
"foreground": "#a31515"
}
},
/* Markdown */
{
"scope": "emphasis",
"settings": {
"fontStyle": "italic"
}
},
{
"scope": "strong",
"settings": {
"fontStyle": "bold"
}
},
{
"scope": "header",
"settings": {
"foreground": "#000080"
}
},
{
"scope": "comment",
"settings": {
"foreground": "#008000"
}
},
{
"scope": "constant.language",
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "constant.numeric",
"settings": {
"foreground": "#09885a"
}
},
{
"scope": "constant.regexp",
"settings": {
"foreground": "#811f3f"
}
},
{
"scope": "constant.rgb-value",
"settings": {
"foreground": "#0451a5"
}
},
{
"name": "css tags in selectors, xml tags",
"scope": "entity.name.tag",
"settings": {
"foreground": "#800000"
}
},
{
"scope": "entity.other.attribute-name",
"settings": {
"foreground": "#ff0000"
}
},
{
"scope": "entity.other.attribute-name.css",
"settings": {
"foreground": "#800000"
}
},
{
"scope": "invalid",
"settings": {
"foreground": "#cd3131"
}
},
{
"scope": "markup.underline",
"settings": {
"fontStyle": "underline"
}
},
{
"scope": "markup.bold",
"settings": {
"fontStyle": "bold"
}
},
{
"scope": "markup.heading",
"settings": {
"foreground": "#000080"
}
},
{
"scope": "markup.italic",
"settings": {
"fontStyle": "italic"
}
},
{
"scope": "meta.selector",
"settings": {
"foreground": "#800000"
}
},
{
"scope": "meta.tag",
"settings": {
"foreground": "#800000"
}
},
{
"scope": "meta.preprocessor",
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "meta.preprocessor.string",
"settings": {
"foreground": "#a31515"
}
},
{
"scope": "meta.preprocessor.numeric",
"settings": {
"foreground": "#09885a"
}
},
{
"scope": "meta.structure.dictionary.key.python",
"settings": {
"foreground": "#0451a5"
}
},
{
"scope": "storage",
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "storage.type",
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "storage.modifier",
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "string",
"settings": {
"foreground": "#a31515"
}
},
{
"scope": "string.tag",
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "string.value",
"settings": {
"foreground": "#a31515"
}
},
{
"scope": "string.regexp",
"settings": {
"foreground": "#811f3f"
}
},
{
"scope": "support.property-value",
"settings": {
"foreground": "#0451a5"
}
},
{
"scope": "support.type.property-name.css, support.type.property-name.less, support.type.property-name.sass",
"settings": {
"foreground": "#ff0000"
}
},
{
"scope": "support.type.property-name",
"settings": {
"foreground": "#0451a5"
}
},
{
"scope": "keyword",
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "keyword.control",
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "keyword.operator",
"settings": {
"foreground": "#000000"
}
},
{
"scope": "keyword.operator.new",
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "keyword.other.unit",
"settings": {
"foreground": "#09885a"
}
},
{
"scope": "keyword.control.less",
"settings": {
"foreground": "#800000"
}
}
]
}
\ No newline at end of file
......@@ -65,18 +65,6 @@
/* TypeScript */
.monaco-editor.vs .token.entity.ts { color: black; }
/* VSXML */
.monaco-editor.vs .token.vs { color: #006400; }
.monaco-editor.vs .token.tag.vs { color: #aeb9ae; }
.monaco-editor.vs .token.attribute.name.vs { color: #aeb9ae; }
.monaco-editor.vs .token.attribute.value.vs { color: #2c51cc; }
.monaco-editor.vs .token.delimiter.vs { color: #708870; }
/* Jade */
.monaco-editor.vs .token.tag.id.jade,
.monaco-editor.vs .token.tag.class.jade { color: #4F76AC; }
.monaco-editor.vs .token.interpolation.jade { color: magenta; }
.monaco-editor.vs .token.interpolation.delimiter.jade { color: magenta; }
/* -------------------------------- End vs tokens -------------------------------- */
......@@ -84,8 +72,6 @@
/* -------------------------------- Begin vs-dark tokens -------------------------------- */
.monaco-editor.vs-dark .token { color: #D4D4D4; }
.monaco-editor.vs-dark .token.whitespace { color: rgba(227, 228, 226, 0.16) !important; }
.monaco-editor.vs-dark .token.terminal { color: #BD5050; }
.monaco-editor.vs-dark .token.terminal.code1 { font-weight: bold; }
.monaco-editor.vs-dark .token.string { color: #CE9178; }
.monaco-editor.vs-dark .token.string.escape { color: #CE9178; }
......@@ -368,7 +354,6 @@
.monaco-editor.vs-dark .token.constant.language { color: #569CD6; } /* null, true, false... */
.monaco-editor.vs-dark .token.constant.numeric { color: #B5CEA8; }
.monaco-editor.vs-dark .token.constant.language { color: #569CD6; }
.monaco-editor.vs-dark .token.constant.regexp { color: #646695; }
.monaco-editor.vs-dark .token.constant.rgb-value { color: #D4D4D4; }
......
......@@ -45,6 +45,28 @@ let themesExtPoint = ExtensionsRegistry.registerExtensionPoint<IThemeExtensionPo
}
});
interface ThemeSettingStyle {
background?: string;
foreground?: string;
fontStyle?: string;
caret?: string;
invisibles?: string;
lineHighlight?: string;
selection?: string;
}
interface ThemeSetting {
name?: string,
scope?: string | string[],
settings: ThemeSettingStyle[];
}
interface ThemeDocument {
name: string;
include: string;
settings: ThemeSetting[];
}
export class ThemeService implements IThemeService {
serviceId = IThemeService;
......@@ -121,6 +143,7 @@ export class ThemeService implements IThemeService {
}
}
function toCssSelector(str: string) {
return str.replace(/[^_\-a-zA-Z0-9]/g, '-');
}
......@@ -129,36 +152,47 @@ function applyTheme(theme: IThemeData): TPromise<boolean> {
if (theme.styleSheetContent) {
_applyRules(theme.styleSheetContent);
}
return _loadThemeDocument(theme.path).then(themeDocument => {
let styleSheetContent = _processThemeObject(theme.id, themeDocument);
theme.styleSheetContent = styleSheetContent;
_applyRules(styleSheetContent);
return true;
}, error => {
return TPromise.wrapError(nls.localize('error.cannotloadtheme', "Unable to load {0}", theme.path));
});
}
return pfs.readFile(theme.path).then(content => {
function _loadThemeDocument(themePath: string) : TPromise<ThemeDocument> {
return pfs.readFile(themePath).then(content => {
let contentValue: any;
if (Paths.extname(theme.path) === '.json') {
if (Paths.extname(themePath) === '.json') {
let errors: string[] = [];
contentValue = Json.parse(content.toString(), errors);
let contentValue = <ThemeDocument> Json.parse(content.toString(), errors);
if (errors.length > 0) {
return TPromise.wrapError(new Error(nls.localize('error.cannotparsejson', "Problems parsing json file: {0}", errors.join(', '))));
return TPromise.wrapError(new Error(nls.localize('error.cannotparsejson', "Problems parsing JSON theme file: {0}", errors.join(', '))));
}
if (contentValue.include) {
return _loadThemeDocument(Paths.join(Paths.dirname(themePath), contentValue.include)).then(includedValue => {
contentValue.settings = includedValue.settings.concat(contentValue.settings);
return TPromise.as(contentValue);
});
}
return TPromise.as(contentValue);
} else {
let parseResult = plist.parse(content.toString());
if (parseResult.errors && parseResult.errors.length) {
return TPromise.wrapError(new Error(nls.localize('error.cannotparse', "Problems parsing plist file: {0}", parseResult.errors.join(', '))));
}
contentValue = parseResult.value;
return TPromise.as(parseResult.value);
}
let styleSheetContent = _processThemeObject(theme.id, contentValue);
theme.styleSheetContent = styleSheetContent;
_applyRules(styleSheetContent);
return true;
}, error => {
return TPromise.wrapError(nls.localize('error.cannotloadtheme', "Unable to load {0}", theme.path));
});
}
function _processThemeObject(themeId: string, themeDocument: any): string {
function _processThemeObject(themeId: string, themeDocument: ThemeDocument): string {
let cssRules: string[] = [];
let themeSettings = themeDocument.settings;
let editorSettings = {
let themeSettings : ThemeSetting[] = themeDocument.settings;
let editorSettings : ThemeSettingStyle = {
background: void 0,
foreground: void 0,
caret: void 0,
......@@ -170,12 +204,12 @@ function _processThemeObject(themeId: string, themeDocument: any): string {
let themeSelector = `${Themes.getBaseThemeId(themeId)}.${Themes.getSyntaxThemeId(themeId)}`;
if (Array.isArray(themeSettings)) {
themeSettings.forEach((s, index, arr) => {
themeSettings.forEach((s : ThemeSetting, index, arr) => {
if (index === 0 && !s.scope) {
editorSettings = s.settings;
} else {
let scope: string | string[] = s.scope;
let settings: string = s.settings;
let settings = s.settings;
if (scope && settings) {
let rules = Array.isArray(scope) ? <string[]> scope : scope.split(',');
let statements = _settingsToStatements(settings);
......@@ -222,7 +256,7 @@ function _processThemeObject(themeId: string, themeDocument: any): string {
return cssRules.join('\n');
}
function _settingsToStatements(settings: any): string {
function _settingsToStatements(settings: ThemeSettingStyle): string {
let statements: string[] = [];
for (let settingName in settings) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册