[theme] conversion script

This commit is contained in:
Martin Aeschlimann 2017-03-08 23:02:21 +01:00
parent 1eb8278296
commit 99ab6e8d7b
3 changed files with 245 additions and 2 deletions

View file

@ -9,6 +9,11 @@ var path = require('path');
var fs = require('fs');
var plist = require('fast-plist');
var mappings = {
"ansiBlack": ["terminalAnsiBlack"], "ansiRed": ["terminalAnsiRed"], "ansiGreen": ["terminalAnsiGreen"], "ansiYellow": ["terminalAnsiYellow"], "ansiBlue": ["terminalAnsiBlue"], "ansiMagenta": ["terminalAnsiMagenta"], "ansiCyan": ["terminalAnsiCyan"], "ansiWhite": ["terminalAnsiWhite"], "ansiBrightBlack": ["terminalAnsiBrightBlack"], "ansiBrightRed": ["terminalAnsiBrightRed"], "ansiBrightGreen": ["terminalAnsiBrightGreen"], "ansiBrightYellow": ["terminalAnsiBrightYellow"], "ansiBrightBlue": ["terminalAnsiBrightBlue"], "ansiBrightMagenta": ["terminalAnsiBrightMagenta"], "ansiBrightCyan": ["terminalAnsiBrightCyan"], "ansiBrightWhite": ["terminalAnsiBrightWhite"], "background": ["editorBackground"],
"hoverHighlight": ["editorHoverHighlight", "editorHoverHighlight"], "linkForeground": ["editorLinkForeground"], "selection": ["editorSelection"], "inactiveSelection": ["editorInactiveSelection"], "selectionHighlightColor": ["editorSelectionHighlightColor"], "wordHighlight": ["editorWordHighlight"], "wordHighlightStrong": ["editorWordHighlightStrong"], "findMatchHighlight": ["editorFindMatchHighlight", "referencesFindMatchHighlight"], "currentFindMatchHighlight": ["editorCurrentFindMatchHighlight"], "findRangeHighlight": ["editorFindRangeHighlight"], "referenceHighlight": ["referencesReferenceHighlight"], "lineHighlight": ["editorLineHighlight"], "rangeHighlight": ["editorRangeHighlight"], "caret": ["editorCursor"], "invisibles": ["editorInvisibles"], "guide": ["editorGuide"]
};
exports.update = function (srcName, destName) {
try {
console.log('reading ', srcName);
@ -17,6 +22,7 @@ exports.update = function (srcName, destName) {
let theme = plist.parse(plistContent);
let settings = theme.settings;
if (Array.isArray(settings)) {
let colorMap = {};
for (let entry of settings) {
let scope = entry.scope;
if (scope) {
@ -24,10 +30,25 @@ exports.update = function (srcName, destName) {
if (parts.length > 1) {
entry.scope = parts;
}
} else {
var entrySettings = entry.settings;
for (let entry in entrySettings) {
let mapping = mappings[entry];
if (mapping) {
for (let newKey of mapping) {
colorMap[newKey] = entrySettings[entry];
}
if (entry !== 'foreground' && entry !== 'background') {
delete entrySettings[entry];
}
}
}
}
}
result.name = theme.name;
result.syntaxTokens = settings;
result.colors = {};
result.colors = colorMap;
}
fs.writeFileSync(destName, JSON.stringify(result, null, '\t'));
} catch (e) {

View file

@ -8,7 +8,7 @@
{
"label": "Abyss",
"uiTheme": "vs-dark",
"path": "./themes/Abyss.tmTheme"
"path": "./themes/abyss-color-theme.json"
}
]
}

View file

@ -0,0 +1,222 @@
{
"name": "Ofer 1",
"syntaxTokens": [
{
"settings": {
"background": "#000c18",
"foreground": "#6688cc"
}
},
{
"name": "Comment",
"scope": "comment",
"settings": {
"foreground": "#223355"
}
},
{
"name": "String",
"scope": "string",
"settings": {
"foreground": "#22aa44"
}
},
{
"name": "Number",
"scope": "constant.numeric",
"settings": {
"foreground": "#f280d0"
}
},
{
"name": "Built-in constant",
"scope": "constant.language",
"settings": {
"foreground": "#f280d0"
}
},
{
"name": "User-defined constant",
"scope": [
"constant.character",
"constant.other"
],
"settings": {
"foreground": "#f280d0"
}
},
{
"name": "Variable",
"scope": "variable",
"settings": {
"fontStyle": ""
}
},
{
"name": "Keyword",
"scope": "keyword",
"settings": {
"foreground": "#225588"
}
},
{
"name": "Storage",
"scope": "storage",
"settings": {
"fontStyle": "",
"foreground": "#225588"
}
},
{
"name": "Storage type",
"scope": "storage.type",
"settings": {
"fontStyle": "italic",
"foreground": "#9966b8"
}
},
{
"name": "Class name",
"scope": [
"entity.name.class",
"entity.name.type"
],
"settings": {
"fontStyle": "underline",
"foreground": "#ffeebb"
}
},
{
"name": "Inherited class",
"scope": "entity.other.inherited-class",
"settings": {
"fontStyle": "italic underline",
"foreground": "#ddbb88"
}
},
{
"name": "Function name",
"scope": "entity.name.function",
"settings": {
"fontStyle": "",
"foreground": "#ddbb88"
}
},
{
"name": "Function argument",
"scope": "variable.parameter",
"settings": {
"fontStyle": "italic",
"foreground": "#2277ff"
}
},
{
"name": "Tag name",
"scope": "entity.name.tag",
"settings": {
"fontStyle": "",
"foreground": "#225588"
}
},
{
"name": "Tag attribute",
"scope": "entity.other.attribute-name",
"settings": {
"fontStyle": "",
"foreground": "#ddbb88"
}
},
{
"name": "Library function",
"scope": "support.function",
"settings": {
"fontStyle": "",
"foreground": "#9966b8"
}
},
{
"name": "Library constant",
"scope": "support.constant",
"settings": {
"fontStyle": "",
"foreground": "#9966b8"
}
},
{
"name": "Library class/type",
"scope": [
"support.type",
"support.class"
],
"settings": {
"fontStyle": "italic",
"foreground": "#9966b8"
}
},
{
"name": "Library variable",
"scope": "support.other.variable",
"settings": {
"fontStyle": ""
}
},
{
"name": "Invalid",
"scope": "invalid",
"settings": {
"background": "#F92672",
"fontStyle": "",
"foreground": "#F8F8F0"
}
},
{
"name": "Invalid deprecated",
"scope": "invalid.deprecated",
"settings": {
"background": "#AE81FF",
"foreground": "#F8F8F0"
}
},
{
"name": "Markup Quote",
"scope": "markup.quote",
"settings": {
"foreground": "#22aa44"
}
},
{
"name": "Markup Styling",
"scope": [
"markup.bold",
"markup.italic"
],
"settings": {
"foreground": "#22aa44"
}
},
{
"name": "Markup Inline",
"scope": "markup.inline.raw",
"settings": {
"fontStyle": "",
"foreground": "#9966b8"
}
},
{
"name": "Markup Setext Header",
"scope": "markup.heading.setext",
"settings": {
"fontStyle": "",
"foreground": "#ddbb88"
}
}
],
"colors": {
"editorBackground": "#000c18",
"editorCursor": "#ddbb88",
"editorInvisibles": "#002040",
"editorLineHighlight": "#082050",
"editorSelection": "#770811",
"editorGuide": "#002952"
}
}