From 0785eecda38f5c51514d13a9eb8ed8aad375ba44 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Sun, 13 Mar 2016 18:32:18 +0100 Subject: [PATCH] Add 'include' to JSON schema --- .../themes/dark_plus.json | 32 ++- .../themes/dark_vs.json | 253 ++++++++++++++++++ .../themes/light_plus.json | 33 ++- .../themes/light_vs.json | 251 +++++++++++++++++ src/vs/editor/browser/widget/media/tokens.css | 15 -- .../services/themes/node/themeService.ts | 68 +++-- 6 files changed, 610 insertions(+), 42 deletions(-) create mode 100644 extensions/theme-colorful-defaults/themes/dark_vs.json create mode 100644 extensions/theme-colorful-defaults/themes/light_vs.json diff --git a/extensions/theme-colorful-defaults/themes/dark_plus.json b/extensions/theme-colorful-defaults/themes/dark_plus.json index 96f8ade7904..e409307ec05 100644 --- a/extensions/theme-colorful-defaults/themes/dark_plus.json +++ b/extensions/theme-colorful-defaults/themes/dark_plus.json @@ -1,17 +1,31 @@ { "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" } diff --git a/extensions/theme-colorful-defaults/themes/dark_vs.json b/extensions/theme-colorful-defaults/themes/dark_vs.json new file mode 100644 index 00000000000..2ebfe58ddd5 --- /dev/null +++ b/extensions/theme-colorful-defaults/themes/dark_vs.json @@ -0,0 +1,253 @@ +{ + "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 diff --git a/extensions/theme-colorful-defaults/themes/light_plus.json b/extensions/theme-colorful-defaults/themes/light_plus.json index 463a9c67f7d..af00c9aaab1 100644 --- a/extensions/theme-colorful-defaults/themes/light_plus.json +++ b/extensions/theme-colorful-defaults/themes/light_plus.json @@ -1,17 +1,31 @@ { "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" } diff --git a/extensions/theme-colorful-defaults/themes/light_vs.json b/extensions/theme-colorful-defaults/themes/light_vs.json new file mode 100644 index 00000000000..749b4ba386f --- /dev/null +++ b/extensions/theme-colorful-defaults/themes/light_vs.json @@ -0,0 +1,251 @@ +{ + "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 diff --git a/src/vs/editor/browser/widget/media/tokens.css b/src/vs/editor/browser/widget/media/tokens.css index 99b406f87dc..3d0edd0d666 100644 --- a/src/vs/editor/browser/widget/media/tokens.css +++ b/src/vs/editor/browser/widget/media/tokens.css @@ -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; } diff --git a/src/vs/workbench/services/themes/node/themeService.ts b/src/vs/workbench/services/themes/node/themeService.ts index 0fb41e5f0d2..203c3ef7cfc 100644 --- a/src/vs/workbench/services/themes/node/themeService.ts +++ b/src/vs/workbench/services/themes/node/themeService.ts @@ -45,6 +45,28 @@ let themesExtPoint = ExtensionsRegistry.registerExtensionPoint { 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 { + 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 = 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) ? 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) { -- GitLab