1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-18 15:35:49 +01: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

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org>
// 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
// 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.
*/
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) {
let match = this._match.exec(text);
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;
},
@@ -302,7 +304,8 @@ var Abbreviations = Module("abbreviations", {
completion: function initCompletion() {
completion.abbreviation = function abbreviation(context, modes, group) {
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.completions = group.merged.filter(fn);
};

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// 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
// given in the LICENSE.txt file included with this file.

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// 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
// given in the LICENSE.txt file included with this file.
@@ -408,7 +408,10 @@ var Bookmarks = Module("bookmarks", {
names: ["-tags", "-T"],
description: "A comma-separated list of tags",
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 };
},
type: CommandOption.LIST
@@ -547,7 +550,9 @@ var Bookmarks = Module("bookmarks", {
let context = CompletionContext(args.join(" "));
context.fork("bookmark", 0, completion, "bookmark",
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) });

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// 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
// 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"); },
{
completer: function (context) completion.url(context),
domains: function (args) array.compact(dactyl.parseURLs(args[0] || "").map(
url => util.getHost(url))),
domains: function (args) array.compact(dactyl.parseURLs(args[0] || "")
.map(url => util.getHost(url))),
literal: 0,
privateData: true
});

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// 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
// given in the LICENSE.txt file included with this file.
@@ -217,7 +217,8 @@ var CommandWidgets = Class("CommandWidgets", {
let elem = nodeSet[obj.name];
if (elem)
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) {
if (DOM(node).style.display === "-moz-stack") {
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);
}
@@ -309,7 +312,8 @@ var CommandWidgets = Class("CommandWidgets", {
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");
}), true),
@@ -1708,7 +1712,7 @@ var CommandLine = Module("commandline", {
commands.add(["sil[ent]"],
"Run a command silently",
function (args) {
commandline.runSilently(() => commands.execute(args[0] || "", null, true));
commandline.runSilently(() => { commands.execute(args[0] || "", null, true); });
}, {
completer: function (context) completion.ex(context),
literal: 0,
@@ -1908,16 +1912,20 @@ var CommandLine = Module("commandline", {
!(timespan.contains(item.timestamp) && (host ? commands.hasDomain(item.value, host)
: item.privateData))));
commandline._messageHistory.filter(item => !timespan.contains(item.timestamp * 1000) ||
!item.domains && !item.privateData ||
host && (!item.domains || !item.domains.some(d => util.isSubdomain(d, host))));
commandline._messageHistory.filter(item =>
( !timespan.contains(item.timestamp * 1000)
|| !item.domains && !item.privateData
|| host && ( !item.domains
|| !item.domains.some(d => util.isSubdomain(d, host)))));
}
});
sanitizer.addItem("messages", {
description: "Saved :messages",
action: function (timespan, host) {
commandline._messageHistory.filter(item => !timespan.contains(item.timestamp * 1000) ||
host && (!item.domains || !item.domains.some(d => util.isSubdomain(d, host))));
commandline._messageHistory.filter(item =>
( !timespan.contains(item.timestamp * 1000)
|| host && ( !item.domains
|| !item.domains.some(d => util.isSubdomain(d, host)))));
}
});
}

View File

@@ -677,7 +677,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
];
}
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 => [
let (c = obj.modes[0].char) c ? c + "_" : "",
map
@@ -720,7 +721,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
let (name = (obj.specs || obj.names)[0])
spec(template.highlightRegexp(tag(name),
/\[(.*?)\]/g,
function (m, n0) ["oa", {}, n0]),
(m, n0) => ["oa", {}, n0]),
name)],
!obj.type ? "" : [
["type", {}, obj.type],
@@ -745,7 +746,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
[o.description,
o.names.length == 1 ? "" :
["", " (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() {
let args = arguments;
return dactyl.withSavedValues(save, function () {
saved.forEach((p, i) => dactyl[save[i]] = p);
saved.forEach((p, i) => { dactyl[save[i]] = p; });
try {
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));
info = info.slice(0, 2).concat(
info.slice(2).filter(e => !isArray(e) || !isObject(e[1])
|| e[1].lang == lang));
info.slice(2).filter(e => !isArray(e)
|| !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 (let attr in values(["name", "summary", "href"]))
@@ -1342,8 +1346,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
setter: function (opts) {
let dir = ["horizontal", "vertical"].filter(
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 + "]");
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))
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) {
for (let group in values(groups))
@@ -1399,8 +1403,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
events.checkFocus();
return value;
},
validator: function (val) Option.validateCompleter.call(this, val) &&
groups.every(g => !g.validator || g.validator(val))
validator: function (val) Option.validateCompleter.call(this, val)
&& groups.every(g => !g.validator || g.validator(val))
});
options.add(["loadplugins", "lpl"],
@@ -1449,7 +1453,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
options.add(["verbose", "vbs"],
"Define which info messages are displayed",
"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"],
"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) {
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;
};
},

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>
//
// 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.
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);
return range;
@@ -400,7 +402,9 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
var editor_ = window.GetCurrentEditor ? GetCurrentEditor()
: Editor.getEditor(document.commandDispatcher.focusedWindow);
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)
var sel = "";
@@ -1316,7 +1320,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
var range = editor.selectedRange;
if (range.collapsed) {
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);
@@ -1349,9 +1353,12 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
"The external text editor",
"string", 'gvim -f +<line> +"sil! call cursor(0, <column>)" <file>', {
format: function (obj, value) {
let args = commands.parseArgs(value || this.value, { argCount: "*", allowUnknownOptions: true })
.map(util.compileMacro).filter(fmt => fmt.valid(obj))
let args = commands.parseArgs(value || this.value,
{ argCount: "*", allowUnknownOptions: true })
.map(util.compileMacro)
.filter(fmt => fmt.valid(obj))
.map(fmt => fmt(obj));
if (obj["file"] && !this.has("file"))
args.push(obj["file"]);
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),
validator: function (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);
}
});

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// 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
// 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 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])
.toObject();
@@ -492,7 +493,7 @@ var Events = Module("events", {
break;
}
if (iter(needed).every(([k, v]) => v == keys[k]))
if (iter(needed).every(([k, v]) => (v == keys[k])))
return key;
}
@@ -542,7 +543,8 @@ var Events = Module("events", {
dactyl.echo(_("macro.loadWaiting"), commandline.FORCE_SINGLELINE);
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);
if (!buffer.loaded)
@@ -797,8 +799,9 @@ var Events = Module("events", {
&& let (key = DOM.Event.stringify(event))
!(modes.main.count && /^\d$/.test(key) ||
modes.main.allBases.some(
mode => mappings.hives.some(
hive => hive.get(mode, key) || hive.getCandidates(mode, key))));
mode => mappings.hives
.some(hive => hive.get(mode, key)
|| hive.getCandidates(mode, key))));
events.dbg("ON " + event.type.toUpperCase() + " " + DOM.Event.stringify(event) +
" passing: " + this.passing + " " +

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// 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
// given in the LICENSE.txt file included with this file.
@@ -300,7 +300,9 @@ var HintSession = Class("HintSession", CommandMode, {
return false;
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)
return false;
@@ -1111,7 +1113,9 @@ var Hints = Module("hints", {
isVisible: function isVisible(elem, offScreen) {
let rect = elem.getBoundingClientRect();
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;
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)")
},
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"],

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// 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
// given in the LICENSE.txt file included with this file.
@@ -209,7 +209,9 @@ var History = Module("history", {
context.compare = CompletionContext.Sort.unsorted;
context.filters = [CompletionContext.Filter.textDescription];
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,
literal: 0,
@@ -249,7 +251,9 @@ var History = Module("history", {
context.compare = CompletionContext.Sort.unsorted;
context.filters = [CompletionContext.Filter.textDescription];
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,
literal: 0,
@@ -305,7 +309,7 @@ var History = Module("history", {
jumps = [sh[sh.index]];
else {
index += jumps.index;
jumps = jumps.locations.map(function (l) ({
jumps = jumps.locations.map(l => ({
__proto__: l,
title: buffer.title,
get URI() util.newURI(this.location)

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
// given in the LICENSE.txt file included with this file.
@@ -77,7 +77,7 @@ var ProcessorStack = Class("ProcessorStack", {
if (this.ownsBuffer)
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
// those waiting on further arguments. Execute actions as
// long as they continue to return PASS.

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// 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
// 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]),
/** @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("."),
@@ -116,7 +117,7 @@ var Map = Class("Map", {
execute: function (args) {
if (!isObject(args)) // Backwards compatibility :(
args = iter(["motion", "count", "arg", "command"])
.map(function ([i, prop]) [prop, this[i]], arguments)
.map(([i, prop]) => [prop, this[i]], arguments)
.toObject();
args = this.hive.makeArgs(this.hive.group.lastDocument,
@@ -172,7 +173,7 @@ var MapHive = Class("MapHive", Contexts.Hive, {
iterate: function (modes) {
let stacks = Array.concat(modes).map(this.closure.getStack);
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))));
},
@@ -360,7 +361,9 @@ var Mappings = Module("mappings", {
let list = Array.map("CASM", s => s + "-");
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) {
@@ -442,7 +445,8 @@ var Mappings = Module("mappings", {
* @param {string} cmd The map name to match.
* @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
@@ -454,7 +458,7 @@ var Mappings = Module("mappings", {
*/
getCandidates: function (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
@@ -813,7 +817,8 @@ var Mappings = Module("mappings", {
completion.userMapping = function userMapping(context, modes_, hive) {
hive = hive || mappings.user;
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_);
};
},
@@ -821,7 +826,8 @@ var Mappings = Module("mappings", {
JavaScript.setCompleter([Mappings.prototype.get, MapHive.prototype.get],
[
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) {

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// 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
// given in the LICENSE.txt file included with this file.
@@ -260,7 +260,7 @@ var Marks = Module("marks", {
if (filter.length > 0) {
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()));
}

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// 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
// 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);)
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();
}
@@ -361,7 +361,9 @@ var Modes = Module("modes", {
push ? { push: push } : stack || {},
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);
this.show();
@@ -425,8 +427,8 @@ var Modes = Module("modes", {
Mode: Class("Mode", {
init: function init(name, options, params) {
if (options.bases)
util.assert(options.bases.every(function (m) m instanceof this, this.constructor),
_("mode.invalidBases"), false);
util.assert(options.bases.every(m => m instanceof this.constructor),
_("mode.invalidBases"), false);
this.update({
id: 1 << Modes.Mode._id++,
@@ -492,7 +494,8 @@ var Modes = Module("modes", {
get toStringParams() !loaded.modes ? this.main.name : [
this.main.name,
["(", modes.all.filter(m => this.extended & m)
.map(m => m.name).join("|"),
.map(m => m.name)
.join("|"),
")"].join("")
]
});
@@ -608,16 +611,19 @@ var Modes = Module("modes", {
setter: function (vals) {
modes.all.forEach(function (m) { delete m.passUnknown; });
vals = vals.map(function (v) update(new String(v.toLowerCase()), {
mode: v.replace(/^!/, "").toUpperCase(),
result: v[0] !== "!"
}));
vals = vals.map(v => update(new String(v.toLowerCase()),
{
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;
},
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)])
};

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// 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
// given in the LICENSE.txt file included with this file.

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// 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
// given in the LICENSE.txt file included with this file.

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// 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
// given in the LICENSE.txt file included with this file.
@@ -330,7 +330,7 @@ var StatusLine = Module("statusline", {
updateTabCount: function updateTabCount(delayed) {
if (dactyl.has("tabs")) {
if (delayed) {
this.timeout(function () this.updateTabCount(false), 0);
this.timeout(() => { this.updateTabCount(false); }, 0);
return;
}

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// 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
// given in the LICENSE.txt file included with this file.
@@ -244,7 +244,7 @@ var Tabs = Module("tabs", {
this._groups = iframe ? iframe.contentWindow : null;
if (this._groups && !func)
util.waitFor(function () this._groups.TabItems, this);
util.waitFor(() => this._groups.TabItems);
return this._groups;
},
@@ -426,9 +426,13 @@ var Tabs = Module("tabs", {
}
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
tabs.slice(index, index + count).forEach(config.closure.removeTab);
tabs.slice(index,
index + count)
.forEach(config.closure.removeTab);
return res;
},
@@ -548,7 +552,7 @@ var Tabs = Module("tabs", {
if (matches)
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)
return tabs.select(matches, false);
@@ -992,7 +996,9 @@ var Tabs = Module("tabs", {
context.anchored = false;
context.compare = CompletionContext.Sort.unsorted;
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);
},
count: true,