1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-04-24 23:41:24 +02:00

More pointification and general code cleanup. Also massive, crazy, conflict-ridden merge.

This commit is contained in:
Kris Maglione
2013-09-21 14:13:07 -07:00
parent 2d90804d5f
commit 25aae2cc99
44 changed files with 350 additions and 230 deletions
+7 -4
View File
@@ -1,6 +1,6 @@
// Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2010 by anekos <anekos@snca.net> // Copyright (c) 2010 by anekos <anekos@snca.net>
// Copyright (c) 2010-2012 Kris Maglione <maglione.k at Gmail> // Copyright (c) 2010-2013 Kris Maglione <maglione.k at Gmail>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -80,7 +80,8 @@ var Abbreviation = Class("Abbreviation", {
* @param {Mode} mode The mode to remove. * @param {Mode} mode The mode to remove.
*/ */
removeMode: function (mode) { removeMode: function (mode) {
this.modes = this.modes.filter(m => m != mode).sort(); this.modes = this.modes.filter(m => m != mode)
.sort();
}, },
/** /**
@@ -248,7 +249,8 @@ var Abbreviations = Module("abbreviations", {
match: function (mode, text) { match: function (mode, text) {
let match = this._match.exec(text); let match = this._match.exec(text);
if (match) if (match)
return this.hives.map(h => h.get(mode, match[2] || match[4] || match[6])).nth(util.identity, 0); return this.hives.map(h => h.get(mode, match[2] || match[4] || match[6]))
.nth(util.identity, 0);
return null; return null;
}, },
@@ -302,7 +304,8 @@ var Abbreviations = Module("abbreviations", {
completion: function initCompletion() { completion: function initCompletion() {
completion.abbreviation = function abbreviation(context, modes, group) { completion.abbreviation = function abbreviation(context, modes, group) {
group = group || abbreviations.user; group = group || abbreviations.user;
let fn = modes ? ab => ab.inModes(modes) : util.identity; let fn = modes ? abbr => abbr.inModes(modes)
: abbr => abbr;
context.keys = { text: "lhs" , description: "rhs" }; context.keys = { text: "lhs" , description: "rhs" };
context.completions = group.merged.filter(fn); context.completions = group.merged.filter(fn);
}; };
+1 -1
View File
@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
+8 -3
View File
@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -408,7 +408,10 @@ var Bookmarks = Module("bookmarks", {
names: ["-tags", "-T"], names: ["-tags", "-T"],
description: "A comma-separated list of tags", description: "A comma-separated list of tags",
completer: function tags(context, args) { completer: function tags(context, args) {
context.generate = () => array(b.tags for (b in bookmarkcache) if (b.tags)).flatten().uniq().array; context.generate = function () array(b.tags
for (b in bookmarkcache)
if (b.tags))
.flatten().uniq().array;
context.keys = { text: util.identity, description: util.identity }; context.keys = { text: util.identity, description: util.identity };
}, },
type: CommandOption.LIST type: CommandOption.LIST
@@ -547,7 +550,9 @@ var Bookmarks = Module("bookmarks", {
let context = CompletionContext(args.join(" ")); let context = CompletionContext(args.join(" "));
context.fork("bookmark", 0, completion, "bookmark", context.fork("bookmark", 0, completion, "bookmark",
args["-tags"], { keyword: args["-keyword"], title: args["-title"] }); args["-tags"], { keyword: args["-keyword"], title: args["-title"] });
deletedCount = bookmarks.remove(context.allItems.items.map(item => item.item.id));
deletedCount = bookmarks.remove(context.allItems.items
.map(item => item.item.id));
} }
dactyl.echomsg({ message: _("bookmark.deleted", deletedCount) }); dactyl.echomsg({ message: _("bookmark.deleted", deletedCount) });
+3 -3
View File
@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k at Gmail> // Copyright (c) 2008-2013 Kris Maglione <maglione.k at Gmail>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -193,8 +193,8 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
function (args) { dactyl.open(args[0] || "about:blank"); }, function (args) { dactyl.open(args[0] || "about:blank"); },
{ {
completer: function (context) completion.url(context), completer: function (context) completion.url(context),
domains: function (args) array.compact(dactyl.parseURLs(args[0] || "").map( domains: function (args) array.compact(dactyl.parseURLs(args[0] || "")
url => util.getHost(url))), .map(url => util.getHost(url))),
literal: 0, literal: 0,
privateData: true privateData: true
}); });
+18 -10
View File
@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -217,7 +217,8 @@ var CommandWidgets = Class("CommandWidgets", {
let elem = nodeSet[obj.name]; let elem = nodeSet[obj.name];
if (elem) if (elem)
highlight.highlightNode(elem, obj.defaultGroup.split(/\s/) highlight.highlightNode(elem, obj.defaultGroup.split(/\s/)
.map(g => g + " " + nodeSet.group + g).join(" ")); .map(g => g + " " + nodeSet.group + g)
.join(" "));
}); });
} }
}, },
@@ -254,7 +255,9 @@ var CommandWidgets = Class("CommandWidgets", {
function check(node) { function check(node) {
if (DOM(node).style.display === "-moz-stack") { if (DOM(node).style.display === "-moz-stack") {
let nodes = Array.filter(node.children, n => !n.collapsed && n.boxObject.height); let nodes = Array.filter(node.children, n => !n.collapsed && n.boxObject.height);
nodes.forEach(function (node, i) { node.style.opacity = (i == nodes.length - 1) ? "" : "0" }); nodes.forEach((node, i) => {
node.style.opacity = (i == nodes.length - 1) ? "" : "0";
});
} }
Array.forEach(node.children, check); Array.forEach(node.children, check);
} }
@@ -309,7 +312,8 @@ var CommandWidgets = Class("CommandWidgets", {
return document.getElementById("dactyl-contextmenu"); return document.getElementById("dactyl-contextmenu");
}), }),
multilineOutput: Class.Memoize(function () this._whenReady("dactyl-multiline-output", function (elem) { multilineOutput: Class.Memoize(function () this._whenReady("dactyl-multiline-output",
elem => {
highlight.highlightNode(elem.contentDocument.body, "MOW"); highlight.highlightNode(elem.contentDocument.body, "MOW");
}), true), }), true),
@@ -1708,7 +1712,7 @@ var CommandLine = Module("commandline", {
commands.add(["sil[ent]"], commands.add(["sil[ent]"],
"Run a command silently", "Run a command silently",
function (args) { function (args) {
commandline.runSilently(() => commands.execute(args[0] || "", null, true)); commandline.runSilently(() => { commands.execute(args[0] || "", null, true); });
}, { }, {
completer: function (context) completion.ex(context), completer: function (context) completion.ex(context),
literal: 0, literal: 0,
@@ -1908,16 +1912,20 @@ var CommandLine = Module("commandline", {
!(timespan.contains(item.timestamp) && (host ? commands.hasDomain(item.value, host) !(timespan.contains(item.timestamp) && (host ? commands.hasDomain(item.value, host)
: item.privateData)))); : item.privateData))));
commandline._messageHistory.filter(item => !timespan.contains(item.timestamp * 1000) || commandline._messageHistory.filter(item =>
!item.domains && !item.privateData || ( !timespan.contains(item.timestamp * 1000)
host && (!item.domains || !item.domains.some(d => util.isSubdomain(d, host)))); || !item.domains && !item.privateData
|| host && ( !item.domains
|| !item.domains.some(d => util.isSubdomain(d, host)))));
} }
}); });
sanitizer.addItem("messages", { sanitizer.addItem("messages", {
description: "Saved :messages", description: "Saved :messages",
action: function (timespan, host) { action: function (timespan, host) {
commandline._messageHistory.filter(item => !timespan.contains(item.timestamp * 1000) || commandline._messageHistory.filter(item =>
host && (!item.domains || !item.domains.some(d => util.isSubdomain(d, host)))); ( !timespan.contains(item.timestamp * 1000)
|| host && ( !item.domains
|| !item.domains.some(d => util.isSubdomain(d, host)))));
} }
}); });
} }
+19 -13
View File
@@ -677,7 +677,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
]; ];
} }
else if (obj instanceof Map) { else if (obj instanceof Map) {
spec = map => obj.count ? [["oa", {}, "count"], map] : DOM.DOMString(map); spec = map => (obj.count ? [["oa", {}, "count"], map]
: DOM.DOMString(map));
tag = map => [ tag = map => [
let (c = obj.modes[0].char) c ? c + "_" : "", let (c = obj.modes[0].char) c ? c + "_" : "",
map map
@@ -720,7 +721,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
let (name = (obj.specs || obj.names)[0]) let (name = (obj.specs || obj.names)[0])
spec(template.highlightRegexp(tag(name), spec(template.highlightRegexp(tag(name),
/\[(.*?)\]/g, /\[(.*?)\]/g,
function (m, n0) ["oa", {}, n0]), (m, n0) => ["oa", {}, n0]),
name)], name)],
!obj.type ? "" : [ !obj.type ? "" : [
["type", {}, obj.type], ["type", {}, obj.type],
@@ -745,7 +746,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
[o.description, [o.description,
o.names.length == 1 ? "" : o.names.length == 1 ? "" :
["", " (short name: ", ["", " (short name: ",
template.map(o.names.slice(1), n => ["em", {}, n], ", "), template.map(o.names.slice(1),
n => ["em", {}, n],
", "),
")"]] ")"]]
])); ]));
@@ -1191,7 +1194,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
return function wrappedCallback() { return function wrappedCallback() {
let args = arguments; let args = arguments;
return dactyl.withSavedValues(save, function () { return dactyl.withSavedValues(save, function () {
saved.forEach((p, i) => dactyl[save[i]] = p); saved.forEach((p, i) => { dactyl[save[i]] = p; });
try { try {
return callback.apply(self, args); return callback.apply(self, args);
} }
@@ -1225,8 +1228,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
let lang = config.bestLocale(l[1].lang for each (l in langs)); let lang = config.bestLocale(l[1].lang for each (l in langs));
info = info.slice(0, 2).concat( info = info.slice(0, 2).concat(
info.slice(2).filter(e => !isArray(e) || !isObject(e[1]) info.slice(2).filter(e => !isArray(e)
|| e[1].lang == lang)); || !isObject(e[1])
|| e[1].lang == lang));
for each (let elem in info.slice(2).filter(e => isArray(e) && e[0] == "info" && isObject(e[1]))) for each (let elem in info.slice(2).filter(e => isArray(e) && e[0] == "info" && isObject(e[1])))
for (let attr in values(["name", "summary", "href"])) for (let attr in values(["name", "summary", "href"]))
@@ -1342,8 +1346,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
setter: function (opts) { setter: function (opts) {
let dir = ["horizontal", "vertical"].filter( let dir = ["horizontal", "vertical"].filter(
dir => !Array.some(opts, dir => !Array.some(opts,
o => this.opts[o] && this.opts[o][1] == dir) o => this.opts[o] && this.opts[o][1] == dir));
);
let class_ = dir.map(dir => "html|html > xul|scrollbar[orient=" + dir + "]"); let class_ = dir.map(dir => "html|html > xul|scrollbar[orient=" + dir + "]");
styles.system.add("scrollbar", "*", styles.system.add("scrollbar", "*",
@@ -1391,7 +1394,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
"rb" + [k for ([k, v] in iter(groups[1].opts)) "rb" + [k for ([k, v] in iter(groups[1].opts))
if (!Dactyl.toolbarHidden(document.getElementById(v[1][0])))].join(""), if (!Dactyl.toolbarHidden(document.getElementById(v[1][0])))].join(""),
values: array(groups).map(g => [[k, v[0]] for ([k, v] in Iterator(g.opts))]).flatten(), values: array(groups).map(g => [[k, v[0]] for ([k, v] in Iterator(g.opts))])
.flatten(),
setter: function (value) { setter: function (value) {
for (let group in values(groups)) for (let group in values(groups))
@@ -1399,8 +1403,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
events.checkFocus(); events.checkFocus();
return value; return value;
}, },
validator: function (val) Option.validateCompleter.call(this, val) && validator: function (val) Option.validateCompleter.call(this, val)
groups.every(g => !g.validator || g.validator(val)) && groups.every(g => !g.validator || g.validator(val))
}); });
options.add(["loadplugins", "lpl"], options.add(["loadplugins", "lpl"],
@@ -1449,7 +1453,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
options.add(["verbose", "vbs"], options.add(["verbose", "vbs"],
"Define which info messages are displayed", "Define which info messages are displayed",
"number", 1, "number", 1,
{ validator: function (value) Option.validIf(value >= 0 && value <= 15, "Value must be between 0 and 15") }); { validator: function (value) Option.validIf(value >= 0 && value <= 15,
"Value must be between 0 and 15") });
options.add(["visualbell", "vb"], options.add(["visualbell", "vb"],
"Use visual bell instead of beeping on errors", "Use visual bell instead of beeping on errors",
@@ -1860,7 +1865,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
completion.window = function window(context) { completion.window = function window(context) {
context.title = ["Window", "Title"]; context.title = ["Window", "Title"];
context.keys = { text: function (win) dactyl.windows.indexOf(win) + 1, description: function (win) win.document.title }; context.keys = { text: win => dactyl.windows.indexOf(win) + 1,
description: win => win.document.title };
context.completions = dactyl.windows; context.completions = dactyl.windows;
}; };
}, },
+15 -7
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2008-2011 Kris Maglione <maglione.k at Gmail> // Copyright (c) 2008-2013 Kris Maglione <maglione.k at Gmail>
// Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
@@ -304,7 +304,9 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
// Skip to any requested offset. // Skip to any requested offset.
count = Math.abs(offset); count = Math.abs(offset);
Editor.extendRange(range, offset > 0, { test: function (c) !!count-- }, true); Editor.extendRange(range, offset > 0,
{ test: c => !!count-- },
true);
range.collapse(offset < 0); range.collapse(offset < 0);
return range; return range;
@@ -400,7 +402,9 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
var editor_ = window.GetCurrentEditor ? GetCurrentEditor() var editor_ = window.GetCurrentEditor ? GetCurrentEditor()
: Editor.getEditor(document.commandDispatcher.focusedWindow); : Editor.getEditor(document.commandDispatcher.focusedWindow);
dactyl.assert(editor_); dactyl.assert(editor_);
text = Array.map(editor_.rootElement.childNodes, e => DOM.stringify(e, true)).join(""); text = Array.map(editor_.rootElement.childNodes,
e => DOM.stringify(e, true))
.join("");
if (!editor_.selection.rangeCount) if (!editor_.selection.rangeCount)
var sel = ""; var sel = "";
@@ -1316,7 +1320,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
var range = editor.selectedRange; var range = editor.selectedRange;
if (range.collapsed) { if (range.collapsed) {
count = count || 1; count = count || 1;
Editor.extendRange(range, true, { test: function (c) !!count-- }, true); Editor.extendRange(range, true, { test: c => !!count-- }, true);
} }
editor.mungeRange(range, munger, count != null); editor.mungeRange(range, munger, count != null);
@@ -1349,9 +1353,12 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
"The external text editor", "The external text editor",
"string", 'gvim -f +<line> +"sil! call cursor(0, <column>)" <file>', { "string", 'gvim -f +<line> +"sil! call cursor(0, <column>)" <file>', {
format: function (obj, value) { format: function (obj, value) {
let args = commands.parseArgs(value || this.value, { argCount: "*", allowUnknownOptions: true }) let args = commands.parseArgs(value || this.value,
.map(util.compileMacro).filter(fmt => fmt.valid(obj)) { argCount: "*", allowUnknownOptions: true })
.map(util.compileMacro)
.filter(fmt => fmt.valid(obj))
.map(fmt => fmt(obj)); .map(fmt => fmt(obj));
if (obj["file"] && !this.has("file")) if (obj["file"] && !this.has("file"))
args.push(obj["file"]); args.push(obj["file"]);
return args; return args;
@@ -1359,7 +1366,8 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
has: function (key) Set.has(util.compileMacro(this.value).seen, key), has: function (key) Set.has(util.compileMacro(this.value).seen, key),
validator: function (value) { validator: function (value) {
this.format({}, value); this.format({}, value);
return Object.keys(util.compileMacro(value).seen).every(k => ["column", "file", "line"].indexOf(k) >= 0); return Object.keys(util.compileMacro(value).seen)
.every(k => ["column", "file", "line"].indexOf(k) >= 0);
} }
}); });
+9 -6
View File
@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k at Gmail> // Copyright (c) 2008-2013 Kris Maglione <maglione.k at Gmail>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -465,7 +465,8 @@ var Events = Module("events", {
let accel = config.OS.isMacOSX ? "metaKey" : "ctrlKey"; let accel = config.OS.isMacOSX ? "metaKey" : "ctrlKey";
let access = iter({ 1: "shiftKey", 2: "ctrlKey", 4: "altKey", 8: "metaKey" }) let access = iter({ 1: "shiftKey", 2: "ctrlKey", 4: "altKey", 8: "metaKey" })
.filter(function ([k, v]) this & k, prefs.get("ui.key.chromeAccess")) .filter(function ([k, v]) this & k,
prefs.get("ui.key.chromeAccess"))
.map(([k, v]) => [v, true]) .map(([k, v]) => [v, true])
.toObject(); .toObject();
@@ -492,7 +493,7 @@ var Events = Module("events", {
break; break;
} }
if (iter(needed).every(([k, v]) => v == keys[k])) if (iter(needed).every(([k, v]) => (v == keys[k])))
return key; return key;
} }
@@ -542,7 +543,8 @@ var Events = Module("events", {
dactyl.echo(_("macro.loadWaiting"), commandline.FORCE_SINGLELINE); dactyl.echo(_("macro.loadWaiting"), commandline.FORCE_SINGLELINE);
const maxWaitTime = (time || 25); const maxWaitTime = (time || 25);
util.waitFor(function () buffer.loaded, this, maxWaitTime * 1000, true); util.waitFor(() => buffer.loaded, this,
maxWaitTime * 1000, true);
dactyl.echo("", commandline.FORCE_SINGLELINE); dactyl.echo("", commandline.FORCE_SINGLELINE);
if (!buffer.loaded) if (!buffer.loaded)
@@ -797,8 +799,9 @@ var Events = Module("events", {
&& let (key = DOM.Event.stringify(event)) && let (key = DOM.Event.stringify(event))
!(modes.main.count && /^\d$/.test(key) || !(modes.main.count && /^\d$/.test(key) ||
modes.main.allBases.some( modes.main.allBases.some(
mode => mappings.hives.some( mode => mappings.hives
hive => hive.get(mode, key) || hive.getCandidates(mode, key)))); .some(hive => hive.get(mode, key)
|| hive.getCandidates(mode, key))));
events.dbg("ON " + event.type.toUpperCase() + " " + DOM.Event.stringify(event) + events.dbg("ON " + event.type.toUpperCase() + " " + DOM.Event.stringify(event) +
" passing: " + this.passing + " " + " passing: " + this.passing + " " +
+9 -4
View File
@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -300,7 +300,9 @@ var HintSession = Class("HintSession", CommandMode, {
return false; return false;
if (!rect.width || !rect.height) if (!rect.width || !rect.height)
if (!Array.some(elem.childNodes, elem => elem instanceof Element && DOM(elem).style.float != "none" && isVisible(elem))) if (!Array.some(elem.childNodes, elem => elem instanceof Element
&& DOM(elem).style.float != "none"
&& isVisible(elem)))
if (elem.textContent || !elem.name) if (elem.textContent || !elem.name)
return false; return false;
@@ -1111,7 +1113,9 @@ var Hints = Module("hints", {
isVisible: function isVisible(elem, offScreen) { isVisible: function isVisible(elem, offScreen) {
let rect = elem.getBoundingClientRect(); let rect = elem.getBoundingClientRect();
if (!rect.width || !rect.height) if (!rect.width || !rect.height)
if (!Array.some(elem.childNodes, elem => elem instanceof Element && DOM(elem).style.float != "none" && isVisible(elem))) if (!Array.some(elem.childNodes, elem => elem instanceof Element
&& DOM(elem).style.float != "none"
&& isVisible(elem)))
return false; return false;
let win = elem.ownerDocument.defaultView; let win = elem.ownerDocument.defaultView;
@@ -1368,7 +1372,8 @@ var Hints = Module("hints", {
"transliterated": UTF8("When true, special latin characters are translated to their ASCII equivalents (e.g., é ⇒ e)") "transliterated": UTF8("When true, special latin characters are translated to their ASCII equivalents (e.g., é ⇒ e)")
}, },
validator: function (values) Option.validateCompleter.call(this, values) && validator: function (values) Option.validateCompleter.call(this, values) &&
1 === values.reduce((acc, v) => acc + (["contains", "custom", "firstletters", "wordstartswith"].indexOf(v) >= 0), 0) 1 === values.reduce((acc, v) => acc + (["contains", "custom", "firstletters", "wordstartswith"].indexOf(v) >= 0),
0)
}); });
options.add(["wordseparators", "wsp"], options.add(["wordseparators", "wsp"],
+8 -4
View File
@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -209,7 +209,9 @@ var History = Module("history", {
context.compare = CompletionContext.Sort.unsorted; context.compare = CompletionContext.Sort.unsorted;
context.filters = [CompletionContext.Filter.textDescription]; context.filters = [CompletionContext.Filter.textDescription];
context.completions = sh.slice(0, sh.index).reverse(); context.completions = sh.slice(0, sh.index).reverse();
context.keys = { text: function (item) (sh.index - item.index) + ": " + item.URI.spec, description: "title", icon: "icon" }; context.keys = { text: function (item) (sh.index - item.index) + ": " + item.URI.spec,
description: "title",
icon: "icon" };
}, },
count: true, count: true,
literal: 0, literal: 0,
@@ -249,7 +251,9 @@ var History = Module("history", {
context.compare = CompletionContext.Sort.unsorted; context.compare = CompletionContext.Sort.unsorted;
context.filters = [CompletionContext.Filter.textDescription]; context.filters = [CompletionContext.Filter.textDescription];
context.completions = sh.slice(sh.index + 1); context.completions = sh.slice(sh.index + 1);
context.keys = { text: function (item) (item.index - sh.index) + ": " + item.URI.spec, description: "title", icon: "icon" }; context.keys = { text: function (item) (item.index - sh.index) + ": " + item.URI.spec,
description: "title",
icon: "icon" };
}, },
count: true, count: true,
literal: 0, literal: 0,
@@ -305,7 +309,7 @@ var History = Module("history", {
jumps = [sh[sh.index]]; jumps = [sh[sh.index]];
else { else {
index += jumps.index; index += jumps.index;
jumps = jumps.locations.map(function (l) ({ jumps = jumps.locations.map(l => ({
__proto__: l, __proto__: l,
title: buffer.title, title: buffer.title,
get URI() util.newURI(this.location) get URI() util.newURI(this.location)
+2 -2
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2008-2012 Kris Maglione <maglione.k at Gmail> // Copyright (c) 2008-2013 Kris Maglione <maglione.k at Gmail>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -77,7 +77,7 @@ var ProcessorStack = Class("ProcessorStack", {
if (this.ownsBuffer) if (this.ownsBuffer)
statusline.inputBuffer = this.processors.length ? this.buffer : ""; statusline.inputBuffer = this.processors.length ? this.buffer : "";
if (!this.processors.some(function (p) !p.extended) && this.actions.length) { if (!this.processors.some(p => !p.extended) && this.actions.length) {
// We have matching actions and no processors other than // We have matching actions and no processors other than
// those waiting on further arguments. Execute actions as // those waiting on further arguments. Execute actions as
// long as they continue to return PASS. // long as they continue to return PASS.
+16 -10
View File
@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k at Gmail> // Copyright (c) 2008-2013 Kris Maglione <maglione.k at Gmail>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -48,9 +48,10 @@ var Map = Class("Map", {
name: Class.Memoize(function () this.names[0]), name: Class.Memoize(function () this.names[0]),
/** @property {[string]} All of this mapping's names (key sequences). */ /** @property {[string]} All of this mapping's names (key sequences). */
names: Class.Memoize(function () this._keys.map(function (k) DOM.Event.canonicalKeys(k))), names: Class.Memoize(function () this._keys.map(k => DOM.Event.canonicalKeys(k))),
get toStringParams() [this.modes.map(m => m.name), this.names.map(String.quote)], get toStringParams() [this.modes.map(m => m.name),
this.names.map(String.quote)],
get identifier() [this.modes[0].name, this.hive.prefix + this.names[0]].join("."), get identifier() [this.modes[0].name, this.hive.prefix + this.names[0]].join("."),
@@ -116,7 +117,7 @@ var Map = Class("Map", {
execute: function (args) { execute: function (args) {
if (!isObject(args)) // Backwards compatibility :( if (!isObject(args)) // Backwards compatibility :(
args = iter(["motion", "count", "arg", "command"]) args = iter(["motion", "count", "arg", "command"])
.map(function ([i, prop]) [prop, this[i]], arguments) .map(([i, prop]) => [prop, this[i]], arguments)
.toObject(); .toObject();
args = this.hive.makeArgs(this.hive.group.lastDocument, args = this.hive.makeArgs(this.hive.group.lastDocument,
@@ -172,7 +173,7 @@ var MapHive = Class("MapHive", Contexts.Hive, {
iterate: function (modes) { iterate: function (modes) {
let stacks = Array.concat(modes).map(this.closure.getStack); let stacks = Array.concat(modes).map(this.closure.getStack);
return values(stacks.shift().sort((m1, m2) => String.localeCompare(m1.name, m2.name)) return values(stacks.shift().sort((m1, m2) => String.localeCompare(m1.name, m2.name))
.filter(map => map.rhs && .filter((map) => map.rhs &&
stacks.every(stack => stack.some(m => m.rhs && m.rhs === map.rhs && m.name === map.name)))); stacks.every(stack => stack.some(m => m.rhs && m.rhs === map.rhs && m.name === map.name))));
}, },
@@ -360,7 +361,9 @@ var Mappings = Module("mappings", {
let list = Array.map("CASM", s => s + "-"); let list = Array.map("CASM", s => s + "-");
return iter(util.range(0, 1 << list.length)).map(mask => return iter(util.range(0, 1 << list.length)).map(mask =>
list.filter((p, i) => mask & (1 << i)).join("")).toArray().concat("*-"); list.filter((p, i) => mask & (1 << i)).join(""))
.toArray()
.concat("*-");
}), }),
expand: function expand(keys) { expand: function expand(keys) {
@@ -442,7 +445,8 @@ var Mappings = Module("mappings", {
* @param {string} cmd The map name to match. * @param {string} cmd The map name to match.
* @returns {Map} * @returns {Map}
*/ */
get: function get(mode, cmd) this.hives.map(h => h.get(mode, cmd)).compact()[0] || null, get: function get(mode, cmd) this.hives.map(h => h.get(mode, cmd))
.compact()[0] || null,
/** /**
* Returns a count of maps with names starting with but not equal to * Returns a count of maps with names starting with but not equal to
@@ -454,7 +458,7 @@ var Mappings = Module("mappings", {
*/ */
getCandidates: function (mode, prefix) getCandidates: function (mode, prefix)
this.hives.map(h => h.getCandidates(mode, prefix)) this.hives.map(h => h.getCandidates(mode, prefix))
.reduce((a, b) => a + b, 0), .reduce((a, b) => (a + b), 0),
/** /**
* Lists all user-defined mappings matching *filter* for the specified * Lists all user-defined mappings matching *filter* for the specified
@@ -813,7 +817,8 @@ var Mappings = Module("mappings", {
completion.userMapping = function userMapping(context, modes_, hive) { completion.userMapping = function userMapping(context, modes_, hive) {
hive = hive || mappings.user; hive = hive || mappings.user;
modes_ = modes_ || [modes.NORMAL]; modes_ = modes_ || [modes.NORMAL];
context.keys = { text: function (m) m.names[0], description: function (m) m.description + ": " + m.action }; context.keys = { text: function (m) m.names[0],
description: function (m) m.description + ": " + m.action };
context.completions = hive.iterate(modes_); context.completions = hive.iterate(modes_);
}; };
}, },
@@ -821,7 +826,8 @@ var Mappings = Module("mappings", {
JavaScript.setCompleter([Mappings.prototype.get, MapHive.prototype.get], JavaScript.setCompleter([Mappings.prototype.get, MapHive.prototype.get],
[ [
null, null,
function (context, obj, args) [[m.names, m.description] for (m in this.iterate(args[0]))] function (context, obj, args) [[m.names, m.description]
for (m in this.iterate(args[0]))]
]); ]);
}, },
mappings: function initMappings(dactyl, modules, window) { mappings: function initMappings(dactyl, modules, window) {
+2 -2
View File
@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -260,7 +260,7 @@ var Marks = Module("marks", {
if (filter.length > 0) { if (filter.length > 0) {
let pattern = util.charListToRegexp(filter, "a-zA-Z"); let pattern = util.charListToRegexp(filter, "a-zA-Z");
marks = marks.filter(([k, ]) => pattern.test(k)); marks = marks.filter(([k]) => (pattern.test(k)));
dactyl.assert(marks.length > 0, _("mark.noMatching", filter.quote())); dactyl.assert(marks.length > 0, _("mark.noMatching", filter.quote()));
} }
+18 -12
View File
@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -277,7 +277,7 @@ var Modes = Module("modes", {
for (let m; m = array.nth(this.modeStack, m => m.main == mode, 0);) for (let m; m = array.nth(this.modeStack, m => m.main == mode, 0);)
this._modeStack.splice(this._modeStack.indexOf(m)); this._modeStack.splice(this._modeStack.indexOf(m));
} }
else if (this.stack.some(function (m) m.main == mode)) { else if (this.stack.some(m => m.main == mode)) {
this.pop(mode); this.pop(mode);
this.pop(); this.pop();
} }
@@ -361,7 +361,9 @@ var Modes = Module("modes", {
push ? { push: push } : stack || {}, push ? { push: push } : stack || {},
prev); prev);
delayed.forEach(([fn, self]) => dactyl.trapErrors(fn, self)); delayed.forEach(([fn, self]) => {
dactyl.trapErrors(fn, self);
});
dactyl.triggerObserver("modes.change", [oldMain, oldExtended], [this._main, this._extended], stack); dactyl.triggerObserver("modes.change", [oldMain, oldExtended], [this._main, this._extended], stack);
this.show(); this.show();
@@ -425,8 +427,8 @@ var Modes = Module("modes", {
Mode: Class("Mode", { Mode: Class("Mode", {
init: function init(name, options, params) { init: function init(name, options, params) {
if (options.bases) if (options.bases)
util.assert(options.bases.every(function (m) m instanceof this, this.constructor), util.assert(options.bases.every(m => m instanceof this.constructor),
_("mode.invalidBases"), false); _("mode.invalidBases"), false);
this.update({ this.update({
id: 1 << Modes.Mode._id++, id: 1 << Modes.Mode._id++,
@@ -492,7 +494,8 @@ var Modes = Module("modes", {
get toStringParams() !loaded.modes ? this.main.name : [ get toStringParams() !loaded.modes ? this.main.name : [
this.main.name, this.main.name,
["(", modes.all.filter(m => this.extended & m) ["(", modes.all.filter(m => this.extended & m)
.map(m => m.name).join("|"), .map(m => m.name)
.join("|"),
")"].join("") ")"].join("")
] ]
}); });
@@ -608,16 +611,19 @@ var Modes = Module("modes", {
setter: function (vals) { setter: function (vals) {
modes.all.forEach(function (m) { delete m.passUnknown; }); modes.all.forEach(function (m) { delete m.passUnknown; });
vals = vals.map(function (v) update(new String(v.toLowerCase()), { vals = vals.map(v => update(new String(v.toLowerCase()),
mode: v.replace(/^!/, "").toUpperCase(), {
result: v[0] !== "!" mode: v.replace(/^!/, "").toUpperCase(),
})); result: v[0] !== "!"
}));
this.valueMap = values(vals).map(v => [v.mode, v.result]).toObject(); this.valueMap = values(vals).map(v => [v.mode, v.result])
.toObject();
return vals; return vals;
}, },
validator: function validator(vals) vals.map(v => v.replace(/^!/, "")).every(Set.has(this.values)), validator: function validator(vals) vals.map(v => v.replace(/^!/, ""))
.every(Set.has(this.values)),
get values() array.toObject([[m.name.toLowerCase(), m.description] for (m in values(modes._modes)) if (!m.hidden)]) get values() array.toObject([[m.name.toLowerCase(), m.description] for (m in values(modes._modes)) if (!m.hidden)])
}; };
+1 -1
View File
@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
+1 -1
View File
@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
+2 -2
View File
@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -330,7 +330,7 @@ var StatusLine = Module("statusline", {
updateTabCount: function updateTabCount(delayed) { updateTabCount: function updateTabCount(delayed) {
if (dactyl.has("tabs")) { if (dactyl.has("tabs")) {
if (delayed) { if (delayed) {
this.timeout(function () this.updateTabCount(false), 0); this.timeout(() => { this.updateTabCount(false); }, 0);
return; return;
} }
+12 -6
View File
@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k at Gmail> // Copyright (c) 2008-2013 Kris Maglione <maglione.k at Gmail>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -244,7 +244,7 @@ var Tabs = Module("tabs", {
this._groups = iframe ? iframe.contentWindow : null; this._groups = iframe ? iframe.contentWindow : null;
if (this._groups && !func) if (this._groups && !func)
util.waitFor(function () this._groups.TabItems, this); util.waitFor(() => this._groups.TabItems);
return this._groups; return this._groups;
}, },
@@ -426,9 +426,13 @@ var Tabs = Module("tabs", {
} }
if (focusLeftTab) if (focusLeftTab)
tabs.slice(Math.max(0, index + 1 - count), index + 1).forEach(config.closure.removeTab); tabs.slice(Math.max(0, index + 1 - count),
index + 1)
.forEach(config.closure.removeTab);
else else
tabs.slice(index, index + count).forEach(config.closure.removeTab); tabs.slice(index,
index + count)
.forEach(config.closure.removeTab);
return res; return res;
}, },
@@ -548,7 +552,7 @@ var Tabs = Module("tabs", {
if (matches) if (matches)
return tabs.select(this.allTabs[parseInt(matches[1], 10) - 1], false); return tabs.select(this.allTabs[parseInt(matches[1], 10) - 1], false);
matches = array.nth(tabs.allTabs, function (t) (t.linkedBrowser.lastURI || {}).spec === buffer, 0); matches = array.nth(tabs.allTabs, t => (t.linkedBrowser.lastURI || {}).spec === buffer, 0);
if (matches) if (matches)
return tabs.select(matches, false); return tabs.select(matches, false);
@@ -992,7 +996,9 @@ var Tabs = Module("tabs", {
context.anchored = false; context.anchored = false;
context.compare = CompletionContext.Sort.unsorted; context.compare = CompletionContext.Sort.unsorted;
context.filters = [CompletionContext.Filter.textDescription]; context.filters = [CompletionContext.Filter.textDescription];
context.keys = { text: function ([i, { state: s }]) (i + 1) + ": " + s.entries[s.index - 1].url, description: "[1].title", icon: "[1].image" }; context.keys = { text: function ([i, { state: s }]) (i + 1) + ": " + s.entries[s.index - 1].url,
description: "[1].title",
icon: "[1].image" };
context.completions = Iterator(tabs.closedTabs); context.completions = Iterator(tabs.closedTabs);
}, },
count: true, count: true,
+9 -7
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2009-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2009-2013 Kris Maglione <maglione.k@gmail.com>
// Copyright (c) 2009-2010 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2009-2010 by Doug Kearns <dougkearns@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
@@ -64,7 +64,7 @@ var updateAddons = Class("UpgradeListener", AddonListener, {
install.install(); install.install();
}, },
onUpdateFinished: function (addon, error) { onUpdateFinished: function (addon, error) {
this.remaining = this.remaining.filter(a => a.type != addon.type || a.id != addon.id); this.remaining = this.remaining.filter(a => (a.type != addon.type || a.id != addon.id));
if (!this.remaining.length) if (!this.remaining.length)
this.dactyl.echomsg( this.dactyl.echomsg(
this.upgrade.length this.upgrade.length
@@ -118,8 +118,10 @@ var actions = {
}); });
}, },
get filter() { get filter() {
return addon => !addon.userDisabled && return addon => (
!(addon.operationsRequiringRestart & (AddonManager.OP_NEEDS_RESTART_ENABLE | AddonManager.OP_NEEDS_RESTART_DISABLE)); !addon.userDisabled &&
!(addon.operationsRequiringRestart & (AddonManager.OP_NEEDS_RESTART_ENABLE
| AddonManager.OP_NEEDS_RESTART_DISABLE)));
}, },
perm: "disable" perm: "disable"
}, },
@@ -420,7 +422,7 @@ var Addons = Module("addons", {
AddonManager.getAddonsByTypes(args["-types"], dactyl.wrapCallback(function (list) { AddonManager.getAddonsByTypes(args["-types"], dactyl.wrapCallback(function (list) {
if (!args.bang || command.bang) { if (!args.bang || command.bang) {
list = list.filter(addon => addon.id == name || addon.name == name); list = list.filter(addon => (addon.id == name || addon.name == name));
dactyl.assert(list.length, _("error.invalidArgument", name)); dactyl.assert(list.length, _("error.invalidArgument", name));
dactyl.assert(list.some(ok), _("error.invalidOperation")); dactyl.assert(list.some(ok), _("error.invalidOperation"));
list = list.filter(ok); list = list.filter(ok);
@@ -429,7 +431,7 @@ var Addons = Module("addons", {
if (command.actions) if (command.actions)
command.actions(list, this.modules); command.actions(list, this.modules);
else else
list.forEach(addon => command.action.call(this.modules, addon, args.bang)); list.forEach(addon => { command.action.call(this.modules, addon, args.bang) });
})); }));
}, { }, {
argCount: "?", // FIXME: should be "1" argCount: "?", // FIXME: should be "1"
@@ -475,7 +477,7 @@ var Addons = Module("addons", {
context.title = ["Add-on"]; context.title = ["Add-on"];
context.anchored = false; context.anchored = false;
context.keys = { context.keys = {
text: function (addon) [addon.name, addon.id], text: addon => [addon.name, addon.id],
description: "description", description: "description",
icon: "iconURL" icon: "iconURL"
}; };
+4 -4
View File
@@ -929,14 +929,14 @@ Class.prototype = {
return callback.call(self || this); return callback.call(self || this);
} }
finally { finally {
names.forEach((name, i) => this[name] = vals[i]); names.forEach((name, i) => { this[name] = vals[i]; });
} }
}, },
toString: function C_toString() { toString: function C_toString() {
if (this.toStringParams) if (this.toStringParams)
var params = "(" + this.toStringParams.map(m => isArray(m) ? "[" + m + "]" : var params = "(" + this.toStringParams.map(m => (isArray(m) ? "[" + m + "]" :
isString(m) ? m.quote() : String(m)) isString(m) ? m.quote() : String(m)))
.join(", ") + ")"; .join(", ") + ")";
return "[instance " + this.constructor.className + (params || "") + "]"; return "[instance " + this.constructor.className + (params || "") + "]";
}, },
@@ -1172,7 +1172,7 @@ Module.INIT = {
module.isLocalModule = true; module.isLocalModule = true;
modules.jsmodules[this.constructor.className] = module; modules.jsmodules[this.constructor.className] = module;
locals.reverse().forEach((fn, i) => update(objs[i], fn.apply(module, args))); locals.reverse().forEach((fn, i) => { update(objs[i], fn.apply(module, args)); });
memoize(module, "closure", Class.makeClosure); memoize(module, "closure", Class.makeClosure);
module.instance = module; module.instance = module;
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright ©2008-2010 Kris Maglione <maglione.k at Gmail> // Copyright ©2008-2013 Kris Maglione <maglione.k at Gmail>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
+11 -5
View File
@@ -435,7 +435,9 @@ var Buffer = Module("Buffer", {
yield elem; yield elem;
function a(regexp, elem) regexp.test(elem.textContent) === regexp.result || function a(regexp, elem) regexp.test(elem.textContent) === regexp.result ||
Array.some(elem.childNodes, child => regexp.test(child.alt) === regexp.result); Array.some(elem.childNodes,
child => (regexp.test(child.alt) === regexp.result));
function b(regexp, elem) regexp.test(elem.title) === regexp.result; function b(regexp, elem) regexp.test(elem.title) === regexp.result;
let res = Array.filter(frame.document.querySelectorAll(selector), Hints.isVisible); let res = Array.filter(frame.document.querySelectorAll(selector), Hints.isVisible);
@@ -904,8 +906,11 @@ var Buffer = Module("Buffer", {
let path = options["jumptags"][arg]; let path = options["jumptags"][arg];
util.assert(path, _("error.invalidArgument", arg)); util.assert(path, _("error.invalidArgument", arg));
let distance = reverse ? rect => -rect.top : rect => rect.top; let distance = reverse ? rect => -rect.top
let elems = [[e, distance(e.getBoundingClientRect())] for (e in path.matcher(this.focusedFrame.document))] : rect => rect.top;
let elems = [[e, distance(e.getBoundingClientRect())]
for (e in path.matcher(this.focusedFrame.document))]
.filter(e => e[1] > FUDGE) .filter(e => e[1] > FUDGE)
.sort((a, b) => a[1] - b[1]); .sort((a, b) => a[1] - b[1]);
@@ -1003,7 +1008,7 @@ var Buffer = Module("Buffer", {
let info = template.map( let info = template.map(
(sections || options["pageinfo"]) (sections || options["pageinfo"])
.map((opt) => Buffer.pageInfo[opt].action.call(this)), .map((opt) => Buffer.pageInfo[opt].action.call(this)),
res => res && iter(res).join(", ") || undefined, res => (res && iter(res).join(", ") || undefined),
", ").join(""); ", ").join("");
if (bookmarkcache.isBookmarked(this.URL)) if (bookmarkcache.isBookmarked(this.URL))
@@ -2413,7 +2418,8 @@ var Buffer = Module("Buffer", {
var res = dactyl.userEval("(" + Option.dequote(filter.result.substr(5)) + ")")(doc, line); var res = dactyl.userEval("(" + Option.dequote(filter.result.substr(5)) + ")")(doc, line);
else else
res = iter.nth(filter.matcher(doc), res = iter.nth(filter.matcher(doc),
elem => (elem.nodeValue || elem.textContent).trim() == line && DOM(elem).display != "none", elem => ((elem.nodeValue || elem.textContent).trim() == line &&
DOM(elem).display != "none"),
0) 0)
|| iter.nth(filter.matcher(doc), util.identity, line - 1); || iter.nth(filter.matcher(doc), util.identity, line - 1);
if (res) if (res)
+2 -2
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2011-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2011-2013 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -167,7 +167,7 @@ var Cache = Module("Cache", XPCOM(Ci.nsIRequestObserver), {
}, },
force: function force(name, localOnly) { force: function force(name, localOnly) {
util.waitFor(function () !this.inQueue, this); util.waitFor(() => !this.inQueue);
if (this.cacheReader && this.cacheReader.hasEntry(name)) { if (this.cacheReader && this.cacheReader.hasEntry(name)) {
return this.parse(File.readStream( return this.parse(File.readStream(
+10 -6
View File
@@ -766,7 +766,8 @@ var Commands = Module("commands", {
// TODO: allow matching of aliases? // TODO: allow matching of aliases?
function cmds(hive) hive._list.filter(cmd => cmd.name.indexOf(filter || "") == 0) function cmds(hive) hive._list.filter(cmd => cmd.name.indexOf(filter || "") == 0)
let hives = (hives || this.userHives).map(h => [h, cmds(h)]).filter(([h, c]) => c.length); let hives = (hives || this.userHives).map(h => [h, cmds(h)])
.filter(([h, c]) => c.length);
let list = ["table", {}, let list = ["table", {},
["tr", { highlight: "Title" }, ["tr", { highlight: "Title" },
@@ -815,7 +816,8 @@ var Commands = Module("commands", {
/** @property {Iterator(Command)} @private */ /** @property {Iterator(Command)} @private */
iterator: function iterator() iter.apply(null, this.hives.array) iterator: function iterator() iter.apply(null, this.hives.array)
.sort((a, b) => a.serialGroup - b.serialGroup || a.name > b.name) .sort((a, b) => (a.serialGroup - b.serialGroup ||
a.name > b.name))
.iterValues(), .iterValues(),
/** @property {string} The last executed Ex command line. */ /** @property {string} The last executed Ex command line. */
@@ -1016,7 +1018,7 @@ var Commands = Module("commands", {
let matchOpts = function matchOpts(arg) { let matchOpts = function matchOpts(arg) {
// Push possible option matches into completions // Push possible option matches into completions
if (complete && !onlyArgumentsRemaining) if (complete && !onlyArgumentsRemaining)
completeOpts = options.filter(opt => opt.multiple || !Set.has(args, opt.names[0])); completeOpts = options.filter(opt => (opt.multiple || !Set.has(args, opt.names[0])));
}; };
let resetCompletions = function resetCompletions() { let resetCompletions = function resetCompletions() {
completeOpts = null; completeOpts = null;
@@ -1394,7 +1396,8 @@ var Commands = Module("commands", {
let quote = null; let quote = null;
let len = str.length; let len = str.length;
function fixEscapes(str) str.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4}|(.))/g, (m, n1) => n1 || m); function fixEscapes(str) str.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4}|(.))/g,
(m, n1) => n1 || m);
// Fix me. // Fix me.
if (isString(sep)) if (isString(sep))
@@ -1725,7 +1728,7 @@ var Commands = Module("commands", {
] ]
})), })),
iterateIndex: function (args) let (tags = help.tags) iterateIndex: function (args) let (tags = help.tags)
this.iterate(args).filter(cmd => cmd.hive === commands.builtin || Set.has(tags, cmd.helpTag)), this.iterate(args).filter(cmd => (cmd.hive === commands.builtin || Set.has(tags, cmd.helpTag))),
format: { format: {
headings: ["Command", "Group", "Description"], headings: ["Command", "Group", "Description"],
description: function (cmd) template.linkifyHelp(cmd.description + (cmd.replacementText ? ": " + cmd.action : "")), description: function (cmd) template.linkifyHelp(cmd.description + (cmd.replacementText ? ": " + cmd.action : "")),
@@ -1779,7 +1782,8 @@ var Commands = Module("commands", {
let quote = function quote(q, list, map) { let quote = function quote(q, list, map) {
map = map || Commands.quoteMap; map = map || Commands.quoteMap;
let re = RegExp("[" + list + "]", "g"); let re = RegExp("[" + list + "]", "g");
function quote(str) q + String.replace(str, re, $0 => $0 in map ? map[$0] : ("\\" + $0)) + q; function quote(str) (q + String.replace(str, re, $0 => ($0 in map ? map[$0] : ("\\" + $0)))
+ q);
quote.list = list; quote.list = list;
return quote; return quote;
}; };
+1 -1
View File
@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
+5 -3
View File
@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -152,8 +152,10 @@ var ConfigBase = Class("ConfigBase", {
loadStyles: function loadStyles(force) { loadStyles: function loadStyles(force) {
highlight.styleableChrome = this.styleableChrome; highlight.styleableChrome = this.styleableChrome;
highlight.loadCSS(this.CSS.replace(/__MSG_(.*?)__/g, (m0, m1) => _(m1))); highlight.loadCSS(this.CSS.replace(/__MSG_(.*?)__/g,
highlight.loadCSS(this.helpCSS.replace(/__MSG_(.*?)__/g, (m0, m1) => _(m1))); (m0, m1) => _(m1)));
highlight.loadCSS(this.helpCSS.replace(/__MSG_(.*?)__/g,
(m0, m1) => _(m1)));
if (!this.haveGecko("2b")) if (!this.haveGecko("2b"))
highlight.loadCSS(literal(/* highlight.loadCSS(literal(/*
+8 -7
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2010-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2010-2013 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -78,8 +78,9 @@ var Group = Class("Group", {
toJSONXML: function (modules) let (uri = modules && modules.buffer.uri) toJSONXML: function (modules) let (uri = modules && modules.buffer.uri)
template.map(this.filters, template.map(this.filters,
function (f) ["span", { highlight: uri && f(uri) ? "Filter" : "" }, f => ["span", { highlight: uri && f(uri) ? "Filter" : "" },
"toJSONXML" in f ? f.toJSONXML() : String(f)], ("toJSONXML" in f ? f.toJSONXML()
: String(f))],
","), ","),
filters: Option.parse.sitelist(patterns) filters: Option.parse.sitelist(patterns)
@@ -201,9 +202,9 @@ var Contexts = Module("contexts", {
Context: function Context(file, group, args) { Context: function Context(file, group, args) {
const { contexts, io, newContext, plugins, userContext } = this.modules; const { contexts, io, newContext, plugins, userContext } = this.modules;
let isPlugin = array.nth(io.getRuntimeDirectories("plugins"), let isPlugin = array.nth(io.getRuntimeDirectories("plugins"),
dir => dir.contains(file, true), dir => dir.contains(file, true),
0); 0);
let isRuntime = array.nth(io.getRuntimeDirectories(""), let isRuntime = array.nth(io.getRuntimeDirectories(""),
dir => dir.contains(file, true), dir => dir.contains(file, true),
0); 0);
@@ -795,7 +796,7 @@ var Contexts = Module("contexts", {
context.title = ["Group"]; context.title = ["Group"];
let uri = modules.buffer.uri; let uri = modules.buffer.uri;
context.keys = { context.keys = {
active: function (group) group.filter(uri), active: group => group.filter(uri),
text: "name", text: "name",
description: function (g) ["", g.filter.toJSONXML ? g.filter.toJSONXML(modules).concat("\u00a0") : "", g.description || ""] description: function (g) ["", g.filter.toJSONXML ? g.filter.toJSONXML(modules).concat("\u00a0") : "", g.description || ""]
}; };
+11 -9
View File
@@ -1,5 +1,5 @@
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -108,7 +108,7 @@ var DOM = Class("DOM", {
}] }]
]), ]),
matcher: function matcher(sel) elem => elem.mozMatchesSelector && elem.mozMatchesSelector(sel), matcher: function matcher(sel) elem => (elem.mozMatchesSelector && elem.mozMatchesSelector(sel)),
each: function each(fn, self) { each: function each(fn, self) {
let obj = self || this.Empty(); let obj = self || this.Empty();
@@ -794,19 +794,19 @@ var DOM = Class("DOM", {
html: function html(txt, self) { html: function html(txt, self) {
return this.getSet(arguments, return this.getSet(arguments,
elem => elem.innerHTML, elem => elem.innerHTML,
util.wrapCallback(function (elem, val) { elem.innerHTML = val; })); util.wrapCallback((elem, val) => { elem.innerHTML = val; }));
}, },
text: function text(txt, self) { text: function text(txt, self) {
return this.getSet(arguments, return this.getSet(arguments,
elem => elem.textContent, elem => elem.textContent,
function (elem, val) { elem.textContent = val; }); (elem, val) => { elem.textContent = val; });
}, },
val: function val(txt) { val: function val(txt) {
return this.getSet(arguments, return this.getSet(arguments,
elem => elem.value, elem => elem.value,
function (elem, val) { elem.value = val == null ? "" : val; }); (elem, val) => { elem.value = val == null ? "" : val; });
}, },
listen: function listen(event, listener, capture) { listen: function listen(event, listener, capture) {
@@ -1664,13 +1664,13 @@ var DOM = Class("DOM", {
function isFragment(args) !isString(args[0]) || args.length == 0 || args[0] === ""; function isFragment(args) !isString(args[0]) || args.length == 0 || args[0] === "";
function hasString(args) { function hasString(args) {
return args.some(a => isString(a) || isFragment(a) && hasString(a)); return args.some(a => (isString(a) || isFragment(a) && hasString(a)));
} }
function isStrings(args) { function isStrings(args) {
if (!isArray(args)) if (!isArray(args))
return util.dump("ARGS: " + {}.toString.call(args) + " " + args), false; return util.dump("ARGS: " + {}.toString.call(args) + " " + args), false;
return args.every(a => isinstance(a, ["String", DOM.DOMString]) || isFragment(a) && isStrings(a)); return args.every(a => (isinstance(a, ["String", DOM.DOMString]) || isFragment(a) && isStrings(a)));
} }
function tag(args, namespaces, indent) { function tag(args, namespaces, indent) {
@@ -1878,7 +1878,9 @@ var DOM = Class("DOM", {
*/ */
makeXPath: function makeXPath(nodes) { makeXPath: function makeXPath(nodes) {
return array(nodes).map(util.debrace).flatten() return array(nodes).map(util.debrace).flatten()
.map(node => /^[a-z]+:/.test(node) ? node : [node, "xhtml:" + node]).flatten() .map(node => /^[a-z]+:/.test(node) ? node
: [node, "xhtml:" + node])
.flatten()
.map(node => "//" + node).join(" | "); .map(node => "//" + node).join(" | ");
}, },
@@ -1891,7 +1893,7 @@ var DOM = Class("DOM", {
}, },
namespaceNames: Class.Memoize(function () namespaceNames: Class.Memoize(function ()
iter(this.namespaces).map(([k, v]) => [v, k]).toObject()), iter(this.namespaces).map(([k, v]) => ([v, k])).toObject()),
}); });
Object.keys(DOM.Event.types).forEach(function (event) { Object.keys(DOM.Event.types).forEach(function (event) {
+12 -12
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2011-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2011-2013 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -131,14 +131,14 @@ var Download = Class("Download", {
}, },
_compare: { _compare: {
active: function (a, b) a.alive - b.alive, active: (a, b) => a.alive - b.alive,
complete: function (a, b) a.percentComplete - b.percentComplete, complete: (a, b) => a.percentComplete - b.percentComplete,
date: function (a, b) a.startTime - b.startTime, date: (a, b) => a.startTime - b.startTime,
filename: function (a, b) String.localeCompare(a.targetFile.leafName, b.targetFile.leafName), filename: (a, b) => String.localeCompare(a.targetFile.leafName, b.targetFile.leafName),
size: function (a, b) a.size - b.size, size: (a, b) => a.size - b.size,
speed: function (a, b) a.speed - b.speed, speed: (a, b) => a.speed - b.speed,
time: function (a, b) a.timeRemaining - b.timeRemaining, time: (a, b) => a.timeRemaining - b.timeRemaining,
url: function (a, b) String.localeCompare(a.source.spec, b.source.spec) url: (a, b) => String.localeCompare(a.source.spec, b.source.spec)
}, },
compare: function compare(other) values(this.list.sortOrder).map(function (order) { compare: function compare(other) values(this.list.sortOrder).map(function (order) {
@@ -497,13 +497,13 @@ var Downloads = Module("downloads", XPCOM(Ci.nsIDownloadProgressListener), {
.flatten().array; .flatten().array;
}, },
has: function () Array.some(arguments, function (val) this.value.some(v => v.substr(1) == val)), has: function () Array.some(arguments, val => this.value.some(v => v.substr(1) == val)),
validator: function (value) { validator: function (value) {
let seen = {}; let seen = {};
return value.every(val => /^[+-]/.test(val) && Set.has(this.values, val.substr(1)) return value.every(val => /^[+-]/.test(val) && Set.has(this.values, val.substr(1))
&& !Set.add(seen, val.substr(1)) && !Set.add(seen, val.substr(1)))
) && value.length; && value.length;
} }
}); });
} }
+4 -4
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -104,7 +104,7 @@ var RangeFinder = Module("rangefinder", {
return ""; return "";
} }
this.options["findflags"].forEach(function (f) { replacer(f, f); }); this.options["findflags"].forEach(f => replacer(f, f));
let pattern = str.replace(/\\(.|$)/g, replacer); let pattern = str.replace(/\\(.|$)/g, replacer);
@@ -542,7 +542,7 @@ var RangeFind = Class("RangeFind", {
} }
} }
finally { finally {
saved.forEach(function ([k, v]) { this[k] = v; }, this); saved.forEach(([k, v]) => { this[k] = v; });
} }
}, },
@@ -611,7 +611,7 @@ var RangeFind = Class("RangeFind", {
this.range = this.findRange(this.startRange) || this.ranges[0]; this.range = this.findRange(this.startRange) || this.ranges[0];
util.assert(this.range, "Null range", false); util.assert(this.range, "Null range", false);
this.ranges.first = this.range; this.ranges.first = this.range;
this.ranges.forEach(function (range) { range.save(); }); this.ranges.forEach(range => { range.save(); });
this.forward = null; this.forward = null;
this.found = false; this.found = false;
}, },
+3 -3
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -367,8 +367,8 @@ var Help = Module("Help", {
for (let [file, ] in Iterator(help.files)) { for (let [file, ] in Iterator(help.files)) {
let url = "dactyl://help/" + file; let url = "dactyl://help/" + file;
dactyl.open(url); dactyl.open(url);
util.waitFor(() => content.location.href == url && buffer.loaded util.waitFor(() => (content.location.href == url && buffer.loaded &&
&& content.document.documentElement instanceof Ci.nsIDOMHTMLHtmlElement, content.document.documentElement instanceof Ci.nsIDOMHTMLHtmlElement),
15000); 15000);
events.waitForPageLoad(); events.waitForPageLoad();
var data = [ var data = [
+8 -7
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2008-2012 Kris Maglione <maglione.k at Gmail> // Copyright (c) 2008-2013 Kris Maglione <maglione.k at Gmail>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -282,8 +282,8 @@ var Highlights = Module("Highlight", {
*/ */
loadCSS: function loadCSS(css, eager) { loadCSS: function loadCSS(css, eager) {
String.replace(css, /\\\n/g, "") String.replace(css, /\\\n/g, "")
.replace(this.groupRegexp, (m, m1, m2) => m1 + " " + m2.replace(/\n\s*/g, " ")) .replace(this.groupRegexp, (m, m1, m2) => (m1 + " " + m2.replace(/\n\s*/g, " ")))
.split("\n").filter(s => /\S/.test(s) && !/^\s*\/\//.test(s)) .split("\n").filter(s => (/\S/.test(s) && !/^\s*\/\//.test(s)))
.forEach(function (highlight) { .forEach(function (highlight) {
let bang = eager || /^\s*!/.test(highlight); let bang = eager || /^\s*!/.test(highlight);
@@ -354,7 +354,7 @@ var Highlights = Module("Highlight", {
["span", { style: "text-align: center; line-height: 1em;" + h.value + style }, "XXX"], ["span", { style: "text-align: center; line-height: 1em;" + h.value + style }, "XXX"],
template.map(h.extends, s => template.highlight(s), ","), template.map(h.extends, s => template.highlight(s), ","),
template.highlightRegexp(h.value, /\b[-\w]+(?=:)|\/\*.*?\*\//g, template.highlightRegexp(h.value, /\b[-\w]+(?=:)|\/\*.*?\*\//g,
function (match) ["span", { highlight: match[0] == "/" ? "Comment" : "Key" }, match]) match => ["span", { highlight: match[0] == "/" ? "Comment" : "Key" }, match])
] ]
for (h in highlight) for (h in highlight)
if (!key || h.class.indexOf(key) > -1)))); if (!key || h.class.indexOf(key) > -1))));
@@ -424,12 +424,13 @@ var Highlights = Module("Highlight", {
let extRe = RegExp("\\." + config.fileExtension + "$"); let extRe = RegExp("\\." + config.fileExtension + "$");
context.title = ["Color Scheme", "Runtime Path"]; context.title = ["Color Scheme", "Runtime Path"];
context.keys = { text: function (f) f.leafName.replace(extRe, ""), description: ".parent.path" }; context.keys = { text: f => f.leafName.replace(extRe, ""),
description: ".parent.path" };
context.completions = context.completions =
array.flatten( array.flatten(
io.getRuntimeDirectories("colors").map( io.getRuntimeDirectories("colors").map(
dir => dir.readDirectory().filter( dir => dir.readDirectory()
file => extRe.test(file.leafName)))) .filter(file => extRe.test(file.leafName))))
.concat([ .concat([
{ leafName: "default", parent: { path: /*L*/"Revert to builtin colorscheme" } } { leafName: "default", parent: { path: /*L*/"Revert to builtin colorscheme" } }
]); ]);
+11 -7
View File
@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2012 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2012 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
// Some code based on Venkman // Some code based on Venkman
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
@@ -75,7 +75,7 @@ var IO = Module("io", {
getRuntimeDirectories: function getRuntimeDirectories(name) { getRuntimeDirectories: function getRuntimeDirectories(name) {
return modules.options.get("runtimepath").files return modules.options.get("runtimepath").files
.map(dir => dir.child(name)) .map(dir => dir.child(name))
.filter(dir => dir.exists() && dir.isDirectory() && dir.isReadable()); .filter(dir => (dir.exists() && dir.isDirectory() && dir.isReadable()));
}, },
// FIXME: multiple paths? // FIXME: multiple paths?
@@ -502,7 +502,9 @@ var IO = Module("io", {
function async(status) { function async(status) {
let output = stdout.read(); let output = stdout.read();
[stdin, stdout, cmd].forEach(f => f.exists() && f.remove(false)); for (let f of [stdin, stdout, cmd])
if (f.exists())
f.remove(false);
callback(result(status, output)); callback(result(status, output));
} }
@@ -550,7 +552,7 @@ var IO = Module("io", {
} }
finally { finally {
if (!checked || res !== true) if (!checked || res !== true)
args.forEach(f => f.remove(false)); args.forEach(f => { f.remove(false); });
} }
return res; return res;
} }
@@ -806,7 +808,9 @@ unlet s:cpo_save
lines.last.push(item, sep); lines.last.push(item, sep);
} }
lines.last.pop(); lines.last.pop();
return lines.map(l => l.join("")).join("\n").replace(/\s+\n/gm, "\n"); return lines.map(l => l.join(""))
.join("\n")
.replace(/\s+\n/gm, "\n");
}//}}} }//}}}
let params = { //{{{ let params = { //{{{
@@ -904,8 +908,8 @@ unlet s:cpo_save
_("command.run.noPrevious")); _("command.run.noPrevious"));
arg = arg.replace(/(\\)*!/g, arg = arg.replace(/(\\)*!/g,
m => /^\\(\\\\)*!$/.test(m) ? m.replace("\\!", "!") : m.replace("!", io._lastRunCommand) m => (/^\\(\\\\)*!$/.test(m) ? m.replace("\\!", "!")
); : m.replace("!", io._lastRunCommand)));
} }
io._lastRunCommand = arg; io._lastRunCommand = arg;
+5 -4
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2008-2012 Kris Maglione <maglione.k at Gmail> // Copyright (c) 2008-2013 Kris Maglione <maglione.k at Gmail>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -273,7 +273,7 @@ var JavaScript = Module("javascript", {
// Don't eval any function calls unless the user presses tab. // Don't eval any function calls unless the user presses tab.
_checkFunction: function (start, end, key) { _checkFunction: function (start, end, key) {
let res = this._functions.some(idx => idx >= start && idx < end); let res = this._function(idx => (idx >= start && idx < end));
if (!res || this.context.tabPressed || key in this.cache.evalled) if (!res || this.context.tabPressed || key in this.cache.evalled)
return false; return false;
this.context.waitingForTab = true; this.context.waitingForTab = true;
@@ -371,7 +371,8 @@ var JavaScript = Module("javascript", {
}; };
base.keys = { base.keys = {
text: prefix ? text => text.substr(prefix.length) : util.identity, text: prefix ? text => text.substr(prefix.length)
: text => text,
description: function (item) self.getKey(this.obj, item), description: function (item) self.getKey(this.obj, item),
key: function (item) { key: function (item) {
if (!isNaN(key)) if (!isNaN(key))
@@ -491,7 +492,7 @@ var JavaScript = Module("javascript", {
let [, prefix, args] = /^(function .*?)\((.*?)\)/.exec(Function.prototype.toString.call(func)); let [, prefix, args] = /^(function .*?)\((.*?)\)/.exec(Function.prototype.toString.call(func));
let n = this._get(i).comma.length; let n = this._get(i).comma.length;
args = template.map(Iterator(args.split(", ")), args = template.map(Iterator(args.split(", ")),
function ([i, arg]) ["span", { highlight: i == n ? "Filter" : "" }, arg], ([i, arg]) => ["span", { highlight: i == n ? "Filter" : "" }, arg],
",\u00a0"); ",\u00a0");
this.context.message = ["", prefix + "(", args, ")"]; this.context.message = ["", prefix + "(", args, ")"];
} }
+4 -3
View File
@@ -151,7 +151,7 @@ var Modules = function Modules(window) {
Object.getOwnPropertyNames(this) Object.getOwnPropertyNames(this)
.map(name => Object.getOwnPropertyDescriptor(this, name).value)), .map(name => Object.getOwnPropertyDescriptor(this, name).value)),
get moduleList() this.ownPropertyValues.filter(mod => mod instanceof this.ModuleBase || mod.isLocalModule) get moduleList() this.ownPropertyValues.filter(mod => (mod instanceof this.ModuleBase || mod.isLocalModule))
}); });
modules.plugins = create(modules); modules.plugins = create(modules);
@@ -161,7 +161,8 @@ var Modules = function Modules(window) {
config.loadStyles(); config.loadStyles();
overlay.overlayWindow(Object.keys(config.overlays), function _overlay(window) ({ overlay.overlayWindow(Object.keys(config.overlays),
function _overlay(window) ({
ready: function onInit(document) { ready: function onInit(document) {
const modules = Modules(window); const modules = Modules(window);
modules.moduleManager = this; modules.moduleManager = this;
@@ -179,7 +180,7 @@ overlay.overlayWindow(Object.keys(config.overlays), function _overlay(window) ({
}); });
config.modules.window config.modules.window
.forEach(name => defineModule.time("load", name, modules.load, modules, name)); .forEach(name => { defineModule.time("load", name, modules.load, modules, name); });
}, this); }, this);
}, },
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2011-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2011-2013 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
+20 -10
View File
@@ -75,7 +75,7 @@ var Option = Class("Option", {
get helpTag() "'" + this.name + "'", get helpTag() "'" + this.name + "'",
initValue: function initValue() { initValue: function initValue() {
util.trapErrors(() => this.value = this.value, this); util.trapErrors(() => { this.value = this.value; });
}, },
get isDefault() this.stringValue === this.stringDefaultValue, get isDefault() this.stringValue === this.stringDefaultValue,
@@ -464,7 +464,8 @@ var Option = Class("Option", {
let [, bang, filter] = /^(!?)(.*)/.exec(pattern); let [, bang, filter] = /^(!?)(.*)/.exec(pattern);
filter = Option.dequote(filter).trim(); filter = Option.dequote(filter).trim();
let quote = this.keepQuotes ? util.identity : function (v) Option.quote(v, /:/); let quote = this.keepQuotes ? v => v
: v => Option.quote(v, /:/);
return update(Styles.matchFilter(filter), { return update(Styles.matchFilter(filter), {
bang: bang, bang: bang,
@@ -731,7 +732,7 @@ var Option = Class("Option", {
acceptable = completions.call(this); acceptable = completions.call(this);
if (isArray(acceptable)) if (isArray(acceptable))
acceptable = Set(acceptable.map(([k]) => k)); acceptable = Set(acceptable.map(([k]) => (k)));
if (this.type === "regexpmap" || this.type === "sitemap") if (this.type === "regexpmap" || this.type === "sitemap")
return Array.concat(vals).every(re => Set.has(acceptable, re.result)); return Array.concat(vals).every(re => Set.has(acceptable, re.result));
@@ -927,7 +928,9 @@ var Options = Module("options", {
let closure = () => this._optionMap[name]; let closure = () => this._optionMap[name];
memoize(this._optionMap, name, () => Option.types[type](modules, names, description, defaultValue, extraInfo)); memoize(this._optionMap, name,
function () Option.types[type](modules, names, description, defaultValue, extraInfo));
for (let alias in values(names.slice(1))) for (let alias in values(names.slice(1)))
memoize(this._optionMap, alias, closure); memoize(this._optionMap, alias, closure);
@@ -1098,9 +1101,11 @@ var Options = Module("options", {
let names = Set(list.map(opt => opt.option ? opt.option.name : "")); let names = Set(list.map(opt => opt.option ? opt.option.name : ""));
if (list.length) if (list.length)
if (list.some(opt => opt.all)) if (list.some(opt => opt.all))
options.list(opt => !(list[0].onlyNonDefault && opt.isDefault), list[0].scope); options.list(opt => !(list[0].onlyNonDefault && opt.isDefault),
list[0].scope);
else else
options.list(opt => Set.has(names, opt.name), list[0].scope); options.list(opt => Set.has(names, opt.name),
list[0].scope);
list = []; list = [];
} }
@@ -1229,8 +1234,12 @@ var Options = Module("options", {
context.highlight(); context.highlight();
if (context.filter.indexOf("=") == -1) { if (context.filter.indexOf("=") == -1) {
if (false && prefix) if (false && prefix)
context.filters.push(({ item }) => item.type == "boolean" || prefix == "inv" && isArray(item.values)); context.filters.push(({ item }) => (item.type == "boolean" ||
return completion.option(context, opt.scope, opt.name == "inv" ? opt.name : prefix); prefix == "inv" && isArray(item.values)));
return completion.option(context, opt.scope,
opt.name == "inv" ? opt.name
: prefix);
} }
function error(length, message) { function error(length, message) {
@@ -1484,7 +1493,8 @@ var Options = Module("options", {
function val(obj) { function val(obj) {
if (isArray(opt.defaultValue)) { if (isArray(opt.defaultValue)) {
let val = array.nth(obj, re => re.key == extra.key, 0); let val = array.nth(obj, re => (re.key == extra.key),
0);
return val && val.result; return val && val.result;
} }
if (Set.has(opt.defaultValue, extra.key)) if (Set.has(opt.defaultValue, extra.key))
@@ -1496,7 +1506,7 @@ var Options = Module("options", {
context.completions = [ context.completions = [
[val(opt.value), _("option.currentValue")], [val(opt.value), _("option.currentValue")],
[val(opt.defaultValue), _("option.defaultValue")] [val(opt.defaultValue), _("option.defaultValue")]
].filter(f => f[0] !== "" && f[0] != null); ].filter(f => (f[0] !== "" && f[0] != null));
}); });
context = context.fork("stuff", 0); context = context.fork("stuff", 0);
} }
+3 -3
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2009-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2009-2013 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -148,7 +148,7 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
"content-document-global-created": function (window, uri) { this.observe(window, "toplevel-window-ready", null); }, "content-document-global-created": function (window, uri) { this.observe(window, "toplevel-window-ready", null); },
"xul-window-visible": function () { "xul-window-visible": function () {
if (this.onWindowVisible) if (this.onWindowVisible)
this.onWindowVisible.forEach(function (f) { f.call(this); }, this); this.onWindowVisible.forEach(f => { f.call(this); });
this.onWindowVisible = null; this.onWindowVisible = null;
} }
}, },
@@ -189,7 +189,7 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
return data[key] = val; return data[key] = val;
}, },
overlayWindow: function (url, fn) { overlayWindow: function overlayWindow(url, fn) {
if (url instanceof Ci.nsIDOMWindow) if (url instanceof Ci.nsIDOMWindow)
overlay._loadOverlay(url, fn); overlay._loadOverlay(url, fn);
else { else {
+5 -3
View File
@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -375,7 +375,8 @@ var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
if (!this._observers[pref]) if (!this._observers[pref])
this._observers[pref] = []; this._observers[pref] = [];
this._observers[pref].push(!strong ? util.weakReference(callback) : { get: function () callback }); this._observers[pref].push(!strong ? util.weakReference(callback)
: { get: function () callback });
}, },
/** /**
@@ -422,7 +423,8 @@ var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
modules.completion.preference = function preference(context) { modules.completion.preference = function preference(context) {
context.anchored = false; context.anchored = false;
context.title = [config.host + " Preference", "Value"]; context.title = [config.host + " Preference", "Value"];
context.keys = { text: function (item) item, description: function (item) prefs.get(item) }; context.keys = { text: function (item) item,
description: function (item) prefs.get(item) };
context.completions = prefs.getNames(); context.completions = prefs.getNames();
}; };
}, },
+5 -4
View File
@@ -1,5 +1,5 @@
// Copyright (c) 2009 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2009 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2009-2012 Kris Maglione <maglione.k at Gmail> // Copyright (c) 2009-2013 Kris Maglione <maglione.k at Gmail>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -186,7 +186,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
let (branch = Item.PREFIX + Item.SHUTDOWN_BRANCH) { let (branch = Item.PREFIX + Item.SHUTDOWN_BRANCH) {
overlay.overlayWindow("chrome://browser/content/preferences/sanitize.xul", overlay.overlayWindow("chrome://browser/content/preferences/sanitize.xul",
function (win) prefOverlay(branch, true, { function (win) prefOverlay(branch, true, {
append: { append: {
SanitizeDialogPane: SanitizeDialogPane:
["groupbox", { orient: "horizontal", xmlns: "xul" }, ["groupbox", { orient: "horizontal", xmlns: "xul" },
@@ -612,11 +612,12 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
}, },
has: function has(val) has: function has(val)
let (res = array.nth(this.value, v => v == "all" || v.replace(/^!/, "") == val, 0)) let (res = array.nth(this.value, v => (v == "all" || v.replace(/^!/, "") == val),
0))
res && !/^!/.test(res), res && !/^!/.test(res),
validator: function (values) values.length && validator: function (values) values.length &&
values.every(val => val === "all" || Set.has(sanitizer.itemMap, val.replace(/^!/, ""))) values.every(val => (val === "all" || Set.has(sanitizer.itemMap, val.replace(/^!/, ""))))
}); });
options.add(["sanitizeshutdown", "ss"], options.add(["sanitizeshutdown", "ss"],
+2 -1
View File
@@ -126,7 +126,8 @@ var Services = Module("Services", {
if (!service.interfaces.length) if (!service.interfaces.length)
return res.wrappedJSObject || res; return res.wrappedJSObject || res;
service.interfaces.forEach(iface => res instanceof Ci[iface]); service.interfaces.forEach(iface => { res instanceof Ci[iface]; });
if (service.init && args.length) { if (service.init && args.length) {
if (service.callable) if (service.callable)
res[service.init].apply(res, args); res[service.init].apply(res, args);
+8 -7
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2008-2012 Kris Maglione <maglione.k at Gmail> // Copyright (c) 2008-2013 Kris Maglione <maglione.k at Gmail>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -293,7 +293,8 @@ var Storage = Module("Storage", {
this.observers[key] = []; this.observers[key] = [];
if (!this.observers[key].some(o => o.callback.get() == callback)) if (!this.observers[key].some(o => o.callback.get() == callback))
this.observers[key].push({ ref: ref && Cu.getWeakReference(ref), callback: callbackRef }); this.observers[key].push({ ref: ref && Cu.getWeakReference(ref),
callback: callbackRef });
}, },
removeObserver: function (key, callback) { removeObserver: function (key, callback) {
@@ -495,7 +496,8 @@ var File = Class("File", {
let array = [e for (e in this.iterDirectory())]; let array = [e for (e in this.iterDirectory())];
if (sort) if (sort)
array.sort((a, b) => b.isDirectory() - a.isDirectory() || String.localeCompare(a.path, b.path)); array.sort((a, b) => (b.isDirectory() - a.isDirectory() ||
String.localeCompare(a.path, b.path)));
return array; return array;
}, },
@@ -693,10 +695,9 @@ var File = Class("File", {
// Kris reckons we shouldn't replicate this 'bug'. --djk // Kris reckons we shouldn't replicate this 'bug'. --djk
// TODO: should we be doing this for all paths? // TODO: should we be doing this for all paths?
function expand(path) path.replace( function expand(path) path.replace(
!win32 ? /\$(\w+)\b|\${(\w+)}/g win32 ? /\$(\w+)\b|\${(\w+)}|%(\w+)%/g
: /\$(\w+)\b|\${(\w+)}|%(\w+)%/g, : /\$(\w+)\b|\${(\w+)}/g,
(m, n1, n2, n3) => getenv(n1 || n2 || n3) || m (m, n1, n2, n3) => (getenv(n1 || n2 || n3) || m));
);
path = expand(path); path = expand(path);
// expand ~ // expand ~
+21 -13
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2008-2012 Kris Maglione <maglione.k at Gmail> // Copyright (c) 2008-2013 Kris Maglione <maglione.k at Gmail>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -36,7 +36,7 @@ Sheet.liveProperty("sites");
update(Sheet.prototype, { update(Sheet.prototype, {
formatSites: function (uris) formatSites: function (uris)
template.map(this.sites, template.map(this.sites,
function (filter) ["span", { highlight: uris.some(Styles.matchFilter(filter)) ? "Filter" : "" }, filter], filter => ["span", { highlight: uris.some(Styles.matchFilter(filter)) ? "Filter" : "" }, filter],
","), ","),
remove: function () { this.hive.remove(this); }, remove: function () { this.hive.remove(this); },
@@ -102,7 +102,8 @@ var Hive = Class("Hive", {
this.dropRef(null); this.dropRef(null);
}, },
dropRef: function (obj) { dropRef: function (obj) {
this.refs = this.refs.filter(ref => ref.get() && ref.get() !== obj); this.refs = this.refs.filter(ref => (ref.get() && ref.get() !== obj));
if (!this.refs.length) { if (!this.refs.length) {
this.cleanup(); this.cleanup();
styles.hives = styles.hives.filter(h => h !== this); styles.hives = styles.hives.filter(h => h !== this);
@@ -116,7 +117,9 @@ var Hive = Class("Hive", {
__iterator__: function () Iterator(this.sheets), __iterator__: function () Iterator(this.sheets),
get sites() array(this.sheets).map(s => s.sites).flatten().uniq().array, get sites() array(this.sheets).map(s => s.sites)
.flatten()
.uniq().array,
/** /**
* Add a new style sheet. * Add a new style sheet.
@@ -189,6 +192,7 @@ var Hive = Class("Hive", {
matches = matches.filter(i => this.sheets[i].css == css); matches = matches.filter(i => this.sheets[i].css == css);
if (filter) if (filter)
matches = matches.filter(i => this.sheets[i].sites.indexOf(filter) >= 0); matches = matches.filter(i => this.sheets[i].sites.indexOf(filter) >= 0);
return matches.map(i => this.sheets[i]); return matches.map(i => this.sheets[i]);
}, },
@@ -273,7 +277,8 @@ var Styles = Module("Styles", {
}, },
addHive: function addHive(name, ref, persist) { addHive: function addHive(name, ref, persist) {
let hive = array.nth(this.hives, h => h.name === name, 0); let hive = array.nth(this.hives, h => h.name === name,
0);
if (!hive) { if (!hive) {
hive = Hive(name, persist); hive = Hive(name, persist);
this.hives.push(hive); this.hives.push(hive);
@@ -304,14 +309,14 @@ var Styles = Module("Styles", {
list: function list(content, sites, name, hives) { list: function list(content, sites, name, hives) {
const { commandline, dactyl } = this.modules; const { commandline, dactyl } = this.modules;
hives = hives || styles.hives.filter(h => h.modifiable && h.sheets.length); hives = hives || styles.hives.filter(h => (h.modifiable && h.sheets.length));
function sheets(group) function sheets(group)
group.sheets.slice() group.sheets.slice()
.filter(sheet => (!name || sheet.name === name) && .filter(sheet => ((!name || sheet.name === name) &&
(!sites || sites.every(s => sheet.sites.indexOf(s) >= 0))) (!sites || sites.every(s => sheet.sites.indexOf(s) >= 0))))
.sort((a, b) => a.name && b.name ? String.localeCompare(a.name, b.name) .sort((a, b) => (a.name && b.name ? String.localeCompare(a.name, b.name)
: !!b.name - !!a.name || a.id - b.id); : !!b.name - !!a.name || a.id - b.id));
let uris = util.visibleURIs(content); let uris = util.visibleURIs(content);
@@ -622,7 +627,8 @@ var Styles = Module("Styles", {
.filter(hive => hive.persist) .filter(hive => hive.persist)
.map(hive => .map(hive =>
hive.sheets.filter(style => style.persist) hive.sheets.filter(style => style.persist)
.sort((a, b) => String.localeCompare(a.name || "", b.name || "")) .sort((a, b) => String.localeCompare(a.name || "",
b.name || ""))
.map(style => ({ .map(style => ({
command: "style", command: "style",
arguments: [style.sites.join(",")], arguments: [style.sites.join(",")],
@@ -716,7 +722,8 @@ var Styles = Module("Styles", {
const names = Array.slice(DOM(["div"], window.document).style); const names = Array.slice(DOM(["div"], window.document).style);
modules.completion.css = function (context) { modules.completion.css = function (context) {
context.title = ["CSS Property"]; context.title = ["CSS Property"];
context.keys = { text: function (p) p + ":", description: function () "" }; context.keys = { text: function (p) p + ":",
description: function () "" };
for (let match in Styles.propertyIter(context.filter, true)) for (let match in Styles.propertyIter(context.filter, true))
var lastMatch = match; var lastMatch = match;
@@ -749,7 +756,8 @@ var Styles = Module("Styles", {
if (match.function) if (match.function)
return ["", template.filter(match.word), return ["", template.filter(match.word),
template.highlightRegexp(match.function, patterns.string, template.highlightRegexp(match.function, patterns.string,
function (match) ["span", { highlight: "String" }, match.string]) match => ["span", { highlight: "String" },
match.string])
]; ];
if (match.important == "!important") if (match.important == "!important")
return ["span", { highlight: "String" }, match.important]; return ["span", { highlight: "String" }, match.important];
+25 -12
View File
@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com> // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -185,7 +185,8 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
* @param {string} name The name to mangle. * @param {string} name The name to mangle.
* @returns {string} The mangled name. * @returns {string} The mangled name.
*/ */
camelCase: function camelCase(name) String.replace(name, /-(.)/g, (m, m1) => m1.toUpperCase()), camelCase: function camelCase(name) String.replace(name, /-(.)/g,
(m, m1) => m1.toUpperCase()),
/** /**
* Capitalizes the first character of the given string. * Capitalizes the first character of the given string.
@@ -261,8 +262,10 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
function frame() update( function frame() update(
function _frame(obj) function _frame(obj)
_frame === stack.top || _frame.valid(obj) ? _frame === stack.top || _frame.valid(obj)
_frame.elements.map(e => callable(e) ? e(obj) : e).join("") : "", ? _frame.elements.map(e => callable(e) ? e(obj) : e)
.join("")
: "",
{ {
elements: [], elements: [],
seen: {}, seen: {},
@@ -295,7 +298,8 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
char = char.toLowerCase(); char = char.toLowerCase();
stack.top.elements.push(update( stack.top.elements.push(update(
obj => obj[char] != null ? quote(obj, char) : "", function (obj) obj[char] != null ? quote(obj, char)
: "",
{ test: function test(obj) obj[char] != null })); { test: function test(obj) obj[char] != null }));
for (let elem in array.iterValues(stack)) for (let elem in array.iterValues(stack))
@@ -344,12 +348,14 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
function frame() update( function frame() update(
function _frame(obj) function _frame(obj)
_frame === stack.top || _frame.valid(obj) ? _frame === stack.top || _frame.valid(obj)
_frame.elements.map(e => callable(e) ? e(obj) : e).join("") : "", ? _frame.elements.map(e => callable(e) ? e(obj) : e)
.join("")
: "",
{ {
elements: [], elements: [],
seen: {}, seen: {},
valid: function valid(obj) this.elements.every(e => !e.test || e.test(obj)) valid: function valid(obj) this.elements.every(e => (!e.test || e.test(obj)))
}); });
let defaults = { lt: "<", gt: ">" }; let defaults = { lt: "<", gt: ">" };
@@ -999,7 +1005,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
if (color) { if (color) {
obj = template.highlightFilter(util.clip(obj, 150), "\n", obj = template.highlightFilter(util.clip(obj, 150), "\n",
function () ["span", { highlight: "NonText" }, "^J"]); () => ["span", { highlight: "NonText" },
"^J"]);
var head = ["span", { highlight: "Title Object" }, obj, "::\n"]; var head = ["span", { highlight: "Title Object" }, obj, "::\n"];
} }
else else
@@ -1066,7 +1074,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
return String.localeCompare(a[0], b[0]); return String.localeCompare(a[0], b[0]);
} }
let vals = template.map(keys.sort(compare), f => f[1], "\n"); let vals = template.map(keys.sort(compare), f => f[1],
"\n");
if (color) { if (color) {
return ["div", { style: "white-space: pre-wrap" }, head, vals]; return ["div", { style: "white-space: pre-wrap" }, head, vals];
} }
@@ -1252,7 +1262,8 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
// Strip comments and white space. // Strip comments and white space.
if (/x/.test(flags)) if (/x/.test(flags))
expr = String.replace(expr, /(\\.)|\/\/[^\n]*|\/\*[^]*?\*\/|\s+/gm, (m, m1) => m1 || ""); expr = String.replace(expr, /(\\.)|\/\/[^\n]*|\/\*[^]*?\*\/|\s+/gm,
(m, m1) => m1 || "");
// Replace (?P<named> parameters) // Replace (?P<named> parameters)
if (/\(\?P</.test(expr)) { if (/\(\?P</.test(expr)) {
@@ -1296,7 +1307,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
* @param {RegExp} re The regexp showable source of which is to be returned. * @param {RegExp} re The regexp showable source of which is to be returned.
* @returns {string} * @returns {string}
*/ */
getSource: function regexp_getSource(re) re.source.replace(/\\(.)/g, (m0, m1) => m1 === "/" ? "/" : m0), getSource: function regexp_getSource(re) re.source.replace(/\\(.)/g,
(m0, m1) => m1 === "/" ? m1
: m0),
/** /**
* Iterates over all matches of the given regexp in the given * Iterates over all matches of the given regexp in the given