update themes and theme conversion tool to add missing styles for folds
This commit is contained in:
parent
b2dcbf9fa3
commit
448fde5d4b
15 changed files with 150 additions and 888 deletions
|
|
@ -103,9 +103,9 @@ var supportedScopes = {
|
|||
"collab.user1": "collab.user1"
|
||||
};
|
||||
|
||||
function extractStyles(theme) {
|
||||
function extractStyles(theme) {
|
||||
var globalSettings = theme.settings[0].settings;
|
||||
|
||||
|
||||
var colors = {
|
||||
"printMargin": "#e8e8e8",
|
||||
"background": parseColor(globalSettings.background),
|
||||
|
|
@ -117,10 +117,10 @@ function extractStyles(theme) {
|
|||
"bracket": parseColor(globalSettings.invisibles),
|
||||
"active_line": parseColor(globalSettings.lineHighlight),
|
||||
"cursor": parseColor(globalSettings.caret),
|
||||
|
||||
|
||||
"invisible": "color: " + parseColor(globalSettings.invisibles) + ";"
|
||||
}
|
||||
|
||||
|
||||
for (var i=1; i<theme.settings.length; i++) {
|
||||
var element = theme.settings[i];
|
||||
if (!element.scope)
|
||||
|
|
@ -133,8 +133,29 @@ function extractStyles(theme) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!colors.foldOutline)
|
||||
colors.foldOutline = (colors.keyword.match(/\:([^;]+)/)||[])[1];
|
||||
|
||||
if (!colors.selected_word_highlight)
|
||||
colors.selected_word_highlight = "border: 1px solid " + colors.selection + ";";
|
||||
|
||||
colors.isDark = (luma(colors.background) < 0.5) + ""
|
||||
|
||||
return colors;
|
||||
};
|
||||
|
||||
function luma(color) {
|
||||
if (color[0]=="#")
|
||||
var rgb = color.match(/^#(..)(..)(..)/).slice(1).map(function(c) {
|
||||
return parseInt(c, 16);
|
||||
});
|
||||
else
|
||||
var rgb = color.match(/\(([^,]+),([^,]+),([^,]+)/).slice(1).map(function(c) {
|
||||
return parseInt(c, 10);
|
||||
});
|
||||
|
||||
return (0.21 * rgb[0] + 0.72 * rgb[1] + 0.07 * rgb[2]) / 255
|
||||
}
|
||||
|
||||
function parseColor(color) {
|
||||
|
|
@ -158,32 +179,35 @@ function parseStyles(styles) {
|
|||
if (fontStyle.indexOf("italic") !== -1) {
|
||||
css.push("font-style:italic;");
|
||||
}
|
||||
|
||||
|
||||
if (styles.foreground) {
|
||||
css.push("color:" + parseColor(styles.foreground) + ";");
|
||||
}
|
||||
if (styles.background) {
|
||||
css.push("background-color:" + parseColor(styles.background) + ";");
|
||||
}
|
||||
|
||||
|
||||
return css.join("\n");
|
||||
}
|
||||
|
||||
function fillTemplate(template, replacements) {
|
||||
return template.replace(/%(.+?)%/g, function(str, m) {
|
||||
return replacements[m] || "";
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function createTheme(name, styles, cssTemplate, jsTemplate) {
|
||||
styles.cssClass = "ace-" + hyphenate(name);
|
||||
var css = fillTemplate(cssTemplate, styles);
|
||||
|
||||
css = css.replace(/[^\{\}]+{\s*}/g, "");
|
||||
return fillTemplate(jsTemplate, {
|
||||
name: name,
|
||||
css: '"' + css.replace(/\\/, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\\n") + '"',
|
||||
cssClass: "ace-" + hyphenate(name)
|
||||
});
|
||||
}
|
||||
cssClass: "ace-" + hyphenate(name),
|
||||
isDark: styles.isDark
|
||||
})
|
||||
};
|
||||
|
||||
function hyphenate(str) {
|
||||
return str.replace(/([A-Z])/g, "-$1").replace(/_/g, "-").toLowerCase();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue