Teach tmtheme.js how to convert a non-built-in theme
You can now pass a .tmTheme file on the command line to have it converted.
This commit is contained in:
parent
d097d41144
commit
f471e54ef0
1 changed files with 23 additions and 7 deletions
|
|
@ -282,9 +282,13 @@ var themes = {
|
||||||
"xcode": "Xcode_default"
|
"xcode": "Xcode_default"
|
||||||
};
|
};
|
||||||
|
|
||||||
function convertTheme(name) {
|
function convertBuiltinTheme(name) {
|
||||||
|
return convertTheme(name, __dirname + "/tmthemes/" + themes[name] + ".tmTheme", __dirname + "/../lib/ace/theme");
|
||||||
|
}
|
||||||
|
|
||||||
|
function convertTheme(name, tmThemePath, outputDirectory) {
|
||||||
console.log("Converting " + name);
|
console.log("Converting " + name);
|
||||||
var tmTheme = fs.readFileSync(__dirname + "/tmthemes/" + themes[name] + ".tmTheme", "utf8");
|
var tmTheme = fs.readFileSync(tmThemePath, "utf8");
|
||||||
parseTheme(tmTheme, function(theme) {
|
parseTheme(tmTheme, function(theme) {
|
||||||
var styles = extractStyles(theme);
|
var styles = extractStyles(theme);
|
||||||
|
|
||||||
|
|
@ -305,7 +309,7 @@ function convertTheme(name) {
|
||||||
// this way, we preserve all hand-modified rules in the <theme>.css rules,
|
// this way, we preserve all hand-modified rules in the <theme>.css rules,
|
||||||
// (because some exist, for collab1 and ace_indentation_guide
|
// (because some exist, for collab1 and ace_indentation_guide
|
||||||
try {
|
try {
|
||||||
var outThemeCss = fs.readFileSync(__dirname + "/../lib/ace/theme/" + name + ".css");
|
var outThemeCss = fs.readFileSync(outputDirectory + "/" + name + ".css");
|
||||||
var oldRules = cssParse(outThemeCss).stylesheet.rules;
|
var oldRules = cssParse(outThemeCss).stylesheet.rules;
|
||||||
var newRules = cssParse(css).stylesheet.rules;
|
var newRules = cssParse(css).stylesheet.rules;
|
||||||
|
|
||||||
|
|
@ -342,13 +346,25 @@ function convertTheme(name) {
|
||||||
isDark: styles.isDark
|
isDark: styles.isDark
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.writeFileSync(__dirname + "/../lib/ace/theme/" + name + ".js", js);
|
fs.writeFileSync(outputDirectory + "/" + name + ".js", js);
|
||||||
fs.writeFileSync(__dirname + "/../lib/ace/theme/" + name + ".css", css);
|
fs.writeFileSync(outputDirectory + "/" + name + ".css", css);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var name in themes) {
|
if (process.argv.length > 1) {
|
||||||
convertTheme(name);
|
var args = process.argv.splice(2);
|
||||||
|
if (args.length < 3) {
|
||||||
|
console.error("Usage: node tmtheme.js [theme_name, path/to/theme.tmTheme path/to/output/directory]");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
var name = args[0];
|
||||||
|
var themePath = args[1];
|
||||||
|
var outputDirectory = args[2];
|
||||||
|
convertTheme(name, themePath, outputDirectory);
|
||||||
|
} else {
|
||||||
|
for (var name in themes) {
|
||||||
|
convertBuiltinTheme(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var sortedUnsupportedScopes = {};
|
var sortedUnsupportedScopes = {};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue