h.style.css = h.css;
this.style[prop || name] = this[prop || name];
+ if (this.onChange)
+ this.onChange();
});
}
Highlight.liveProperty("agent");
__iterator__: function () values(this.highlight).sort(function (a, b) String.localeCompare(a.class, b.class))
.iterValues(),
- _create: function (agent, args) {
+ _create: function _create(agent, args) {
let obj = Highlight.apply(Highlight, args);
if (!isArray(obj.sites))
return obj;
},
- get: function (k) this.highlight[k],
+ get: function get(k) this.highlight[k],
- set: function (key, newStyle, force, append, extend) {
+ set: function set(key, newStyle, force, append, extend) {
let [, class_, selectors] = key.match(/^([a-zA-Z_-]+)(.*)/);
let highlight = this.highlight[key] || this._create(false, [key]);
* Clears all highlighting rules. Rules with default values are
* reset.
*/
- clear: function () {
+ clear: function clear() {
for (let [k, v] in Iterator(this.highlight))
this.set(k, null, true);
},
* @param {Node} node
* @param {string} group
*/
- highlightNode: function (node, group, applyBindings) {
+ highlightNode: function highlightNode(node, group, applyBindings) {
node.setAttributeNS(NS.uri, "highlight", group);
let groups = group.split(" ");
*
* @param {string} class
*/
- selector: function (class_)
+ selector: function selector(class_)
let (self = this)
class_.replace(/(^|[>\s])([A-Z][\w-]+)\b/g,
function (m, n1, hl) n1 +
* @param {string} css The rules to load. See {@link Highlights#css}.
* @param {boolean} eager When true, load all provided rules immediately.
*/
- loadCSS: function (css, eager) {
- String.replace(css, this.groupRegexp, function (m, m1, m2) m1 + " " + m2.replace(/\n\s*/g, " "))
+ loadCSS: function loadCSS(css, eager) {
+ String.replace(css, /\\\n/g, "")
+ .replace(this.groupRegexp, function (m, m1, m2) m1 + " " + m2.replace(/\n\s*/g, " "))
.split("\n").filter(function (s) /\S/.test(s) && !/^\s*\/\//.test(s))
.forEach(function (highlight) {
}
}, {
}, {
- commands: function (dactyl, modules) {
+ commands: function initCommands(dactyl, modules) {
const { autocommands, commands, completion, CommandOption, config, io } = modules;
let lastScheme;
if (!modify && /&$/.test(key))
[clear, modify, key] = [true, true, key.replace(/&$/, "")];
- dactyl.assert(!(clear && css), _("error.trailing"));
+ dactyl.assert(!(clear && css), _("error.trailingCharacters"));
if (!modify)
modules.commandline.commandOutput(
([h.class,
<span style={"text-align: center; line-height: 1em;" + h.value + style}>XXX</span>,
template.map(h.extends, template.highlight),
- template.highlightRegexp(h.value, /\b[-\w]+(?=:)/g)]
- for (h in highlight)
- if (!key || h.class.indexOf(key) > -1))));
+ template.highlightRegexp(h.value, /\b[-\w]+(?=:)|\/\*.*?\*\//g,
+ function (match) <span highlight={match[0] == "/" ? "Comment" : "Key"}>{match}</span>)
+ ]
+ for (h in highlight)
+ if (!key || h.class.indexOf(key) > -1))));
else if (!key && clear)
highlight.clear();
else if (key)
else if (args.completeArg == 1) {
let hl = highlight.get(args[0]);
if (hl)
- context.completions = [[hl.value, "Current Value"], [hl.defaultValue || "", "Default Value"]];
+ context.completions = [
+ [hl.value, _("option.currentValue")],
+ [hl.defaultValue || "", _("option.defaultValue")]
+ ];
context.fork("css", 0, completion, "css");
}
},
let group = args[0] && highlight.get(args[0]);
if (group)
context.fork("extra", 0, this, function (context) [
- [String(group.extends), "Current Value"],
- [String(group.defaultExtends) || "", "Default Value"]
+ [String(group.extends), _("option.currentValue")],
+ [String(group.defaultExtends) || "", _("option.defaultValue")]
]);
context.fork("groups", 0, completion, "highlightGroup");
}
]
});
},
- completion: function (dactyl, modules) {
+ completion: function initCompletion(dactyl, modules) {
const { completion, config, io } = modules;
+
completion.colorScheme = function colorScheme(context) {
let extRe = RegExp("\\." + config.fileExtension + "$");
context.title = ["Color Scheme", "Runtime Path"];
context.keys = { text: function (f) f.leafName.replace(extRe, ""), description: ".parent.path" };
- context.completions = array.flatten(
- io.getRuntimeDirectories("colors").map(
- function (dir) dir.readDirectory().filter(
- function (file) extRe.test(file.leafName))));
+ context.completions =
+ array.flatten(
+ io.getRuntimeDirectories("colors").map(
+ function (dir) dir.readDirectory().filter(
+ function (file) extRe.test(file.leafName))))
+ .concat([
+ { leafName: "default", parent: { path: /*L*/"Revert to builtin colorscheme" } }
+ ]);
};
context.completions = [[v.class, v.value] for (v in highlight)];
};
},
- javascript: function (dactyl, modules, window) {
+ javascript: function initJavascript(dactyl, modules, window) {
modules.JavaScript.setCompleter(["get", "set"].map(function (m) highlight[m]),
[ function (context, obj, args) Iterator(highlight.highlight) ]);
modules.JavaScript.setCompleter(["highlightNode"].map(function (m) highlight[m]),