mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-22 17:35:47 +01:00
Fix all the things. And break most of the other things, in all likelihood.
This commit is contained in:
@@ -116,7 +116,7 @@ var AbbrevHive = Class("AbbrevHive", Contexts.Hive, {
|
||||
if (!(abbr instanceof Abbreviation))
|
||||
abbr = Abbreviation.apply(null, arguments);
|
||||
|
||||
for (let [, mode] in Iterator(abbr.modes)) {
|
||||
for (let mode of abbr.modes) {
|
||||
if (!this._store[mode])
|
||||
this._store[mode] = {};
|
||||
this._store[mode][abbr.lhs] = abbr;
|
||||
@@ -156,7 +156,7 @@ var AbbrevHive = Class("AbbrevHive", Contexts.Hive, {
|
||||
*/
|
||||
remove: function (modes, lhs) {
|
||||
let result = false;
|
||||
for (let [, mode] in Iterator(modes)) {
|
||||
for (let mode of modes) {
|
||||
if ((mode in this._store) && (lhs in this._store[mode])) {
|
||||
result = true;
|
||||
this._store[mode][lhs].removeMode(mode);
|
||||
@@ -172,8 +172,8 @@ var AbbrevHive = Class("AbbrevHive", Contexts.Hive, {
|
||||
* @param {Array} modes List of modes.
|
||||
*/
|
||||
clear: function (modes) {
|
||||
for (let mode in values(modes)) {
|
||||
for (let abbr in values(this._store[mode]))
|
||||
for (let mode of values(modes)) {
|
||||
for (let abbr of values(this._store[mode]))
|
||||
abbr.removeMode(mode);
|
||||
delete this._store[mode];
|
||||
}
|
||||
@@ -276,15 +276,18 @@ var Abbreviations = Module("abbreviations", {
|
||||
["td", { style: "padding-right: 1em;" }, _("title.Abbrev")],
|
||||
["td", { style: "padding-right: 1em;" }, _("title.Replacement")]],
|
||||
["col", { style: "min-width: 6em; padding-right: 1em;" }],
|
||||
hives.map(hive => let (i = 0) [
|
||||
["tr", { style: "height: .5ex;" }],
|
||||
abbrevs(hive).map(abbrev =>
|
||||
["tr", {},
|
||||
["td", { highlight: "Title" }, !i++ ? String(hive.name) : ""],
|
||||
["td", {}, abbrev.modeChar],
|
||||
["td", {}, abbrev.lhs],
|
||||
["td", {}, abbrev.rhs]]),
|
||||
["tr", { style: "height: .5ex;" }]])];
|
||||
hives.map(hive => {
|
||||
let i = 0;
|
||||
return [
|
||||
["tr", { style: "height: .5ex;" }],
|
||||
abbrevs(hive).map(abbrev =>
|
||||
["tr", {},
|
||||
["td", { highlight: "Title" }, !i++ ? String(hive.name) : ""],
|
||||
["td", {}, abbrev.modeChar],
|
||||
["td", {}, abbrev.lhs],
|
||||
["td", {}, abbrev.rhs]]),
|
||||
["tr", { style: "height: .5ex;" }]];
|
||||
})];
|
||||
|
||||
// FIXME?
|
||||
// // TODO: Move this to an ItemList to show this automatically
|
||||
@@ -361,7 +364,7 @@ var Abbreviations = Module("abbreviations", {
|
||||
"-javascript": callable(abbr.rhs) ? null : undefined
|
||||
}
|
||||
}
|
||||
for ([, abbr] in Iterator(hive.merged))
|
||||
for (abbr of hive.merged)
|
||||
if (abbr.modesEqual(modes))
|
||||
]).
|
||||
flatten().array
|
||||
|
||||
@@ -23,7 +23,7 @@ var AutoCmdHive = Class("AutoCmdHive", Contexts.Hive, {
|
||||
this._store = [];
|
||||
},
|
||||
|
||||
__iterator__: function () array.iterValues(this._store),
|
||||
"@@iterator": function () array.iterValues(this._store),
|
||||
|
||||
/**
|
||||
* Adds a new autocommand. *cmd* will be executed when one of the specified
|
||||
@@ -38,7 +38,7 @@ var AutoCmdHive = Class("AutoCmdHive", Contexts.Hive, {
|
||||
if (!callable(pattern))
|
||||
pattern = Group.compileFilter(pattern);
|
||||
|
||||
for (let event in values(events))
|
||||
for (let event of values(events))
|
||||
this._store.push(AutoCommand(event, pattern, cmd));
|
||||
},
|
||||
|
||||
@@ -134,7 +134,7 @@ var AutoCommands = Module("autocommands", {
|
||||
if (options.get("eventignore").has(event))
|
||||
return;
|
||||
|
||||
dactyl.echomsg(_("autocmd.executing", event, "*".quote()), 8);
|
||||
dactyl.echomsg(_("autocmd.executing", event, '"*"'), 8);
|
||||
|
||||
let lastPattern = null;
|
||||
var { url, doc } = args;
|
||||
@@ -144,10 +144,10 @@ var AutoCommands = Module("autocommands", {
|
||||
var { uri, doc } = buffer;
|
||||
|
||||
event = event.toLowerCase();
|
||||
for (let hive in values(this.matchingHives(uri, doc))) {
|
||||
for (let hive of values(this.matchingHives(uri, doc))) {
|
||||
let args = hive.makeArgs(doc, null, arguments[1]);
|
||||
|
||||
for (let autoCmd in values(hive._store))
|
||||
for (let autoCmd of values(hive._store))
|
||||
if (autoCmd.eventName === event && autoCmd.filter(uri, doc)) {
|
||||
if (!lastPattern || lastPattern !== String(autoCmd.filter))
|
||||
dactyl.echomsg(_("autocmd.executing", event, autoCmd.filter), 8);
|
||||
|
||||
@@ -76,7 +76,7 @@ var Bookmarks = Module("bookmarks", {
|
||||
if (keyword && hasOwnProperty(bookmarkcache.keywords, keyword))
|
||||
bmark = bookmarkcache.keywords[keyword];
|
||||
else if (bookmarkcache.isBookmarked(uri))
|
||||
for (bmark in bookmarkcache)
|
||||
for (bmark of bookmarkcache)
|
||||
if (bmark.url == uri.spec)
|
||||
break;
|
||||
}
|
||||
@@ -421,11 +421,11 @@ var Bookmarks = Module("bookmarks", {
|
||||
return dactyl.open(items.map(i => i.url), dactyl.NEW_TAB);
|
||||
|
||||
if (filter.length > 0 && tags.length > 0)
|
||||
dactyl.echoerr(_("bookmark.noMatching", tags.map(String.quote), filter.quote()));
|
||||
dactyl.echoerr(_("bookmark.noMatching", tags.map(JSON.stringify), JSON.stringify(filter)));
|
||||
else if (filter.length > 0)
|
||||
dactyl.echoerr(_("bookmark.noMatchingString", filter.quote()));
|
||||
dactyl.echoerr(_("bookmark.noMatchingString", JSON.stringify(filter)));
|
||||
else if (tags.length > 0)
|
||||
dactyl.echoerr(_("bookmark.noMatchingTags", tags.map(String.quote)));
|
||||
dactyl.echoerr(_("bookmark.noMatchingTags", tags.map(JSON.stringify)));
|
||||
else
|
||||
dactyl.echoerr(_("bookmark.none"));
|
||||
return null;
|
||||
@@ -455,7 +455,7 @@ var Bookmarks = Module("bookmarks", {
|
||||
if (!args.bang)
|
||||
return [
|
||||
[win.document.title, frames.length == 1 ? /*L*/"Current Location" : /*L*/"Frame: " + win.location.href]
|
||||
for ([, win] in Iterator(frames))];
|
||||
for (win of frames)];
|
||||
context.keys.text = "title";
|
||||
context.keys.description = "url";
|
||||
return bookmarks.get(args.join(" "), args["-tags"], null, { keyword: args["-keyword"], title: context.filter });
|
||||
@@ -519,7 +519,7 @@ var Bookmarks = Module("bookmarks", {
|
||||
let frames = buffer.allFrames();
|
||||
context.completions = [
|
||||
[win.document.documentURI, frames.length == 1 ? /*L*/"Current Location" : /*L*/"Frame: " + win.document.title]
|
||||
for ([, win] in Iterator(frames))];
|
||||
for (win of frames)];
|
||||
return;
|
||||
}
|
||||
completion.bookmark(context, args["-tags"], { keyword: args["-keyword"], title: args["-title"] });
|
||||
@@ -695,7 +695,7 @@ var Bookmarks = Module("bookmarks", {
|
||||
context.generate = function () {
|
||||
let [begin, end] = item.url.split("%s");
|
||||
|
||||
let seen = RealSet();
|
||||
let seen = new RealSet;
|
||||
return history.get({ uri: util.newURI(begin), uriIsPrefix: true }).map(function (item) {
|
||||
let rest = item.url.length - end.length;
|
||||
let query = item.url.substring(begin.length, rest);
|
||||
|
||||
@@ -160,7 +160,7 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
|
||||
let oldURI = overlay.getData(win.document)["uri"];
|
||||
if (overlay.getData(win.document)["load-idx"] === webProgress.loadedTransIndex
|
||||
|| !oldURI || uri.spec.replace(/#.*/, "") !== oldURI.replace(/#.*/, ""))
|
||||
for (let frame in values(buffer.allFrames(win)))
|
||||
for (let frame of values(buffer.allFrames(win)))
|
||||
overlay.setData(frame.document, "focus-allowed", false);
|
||||
|
||||
overlay.setData(win.document, "uri", uri.spec);
|
||||
|
||||
@@ -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-2014 Kris Maglione <maglione.k@gmail.com>
|
||||
// Copyright (c) 2008-2015 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.
|
||||
@@ -231,13 +231,13 @@ var CommandWidgets = Class("CommandWidgets", {
|
||||
|
||||
updateVisibility: function updateVisibility() {
|
||||
let changed = 0;
|
||||
for (let elem in values(this.elements))
|
||||
for (let elem of values(this.elements))
|
||||
if (elem.getGroup) {
|
||||
let value = elem.getValue ? elem.getValue.call(this)
|
||||
: elem.noValue || this[elem.name];
|
||||
|
||||
let activeGroup = this.getGroup(elem.name, value);
|
||||
for (let group in values([this.commandbar, this.statusbar])) {
|
||||
for (let group of [this.commandbar, this.statusbar]) {
|
||||
let meth, node = group[elem.name];
|
||||
let visible = (value && group === activeGroup);
|
||||
if (node && !node.collapsed == !visible) {
|
||||
@@ -277,7 +277,7 @@ var CommandWidgets = Class("CommandWidgets", {
|
||||
["viewable", "complete"].indexOf(elem.contentDocument.readyState) >= 0;
|
||||
},
|
||||
|
||||
_whenReady: function _whenReady(id, init) {
|
||||
_whenReady: function* _whenReady(id, init) {
|
||||
let elem = document.getElementById(id);
|
||||
while (!this._ready(elem))
|
||||
yield 10;
|
||||
@@ -502,11 +502,11 @@ var CommandLine = Module("commandline", {
|
||||
|
||||
memoize(this, "_store", function () storage.newMap("command-history", { store: true, privateData: true }));
|
||||
|
||||
for (let name in values(["command", "search"]))
|
||||
for (let name of ["command", "search"])
|
||||
if (storage.exists("history-" + name)) {
|
||||
let ary = storage.newArray("history-" + name, { store: true, privateData: true });
|
||||
|
||||
this._store.set(name, [v for ([k, v] in ary)]);
|
||||
this._store.set(name, [v for ([k, v] of ary)]);
|
||||
ary.delete();
|
||||
this._store.changed();
|
||||
}
|
||||
@@ -632,7 +632,7 @@ var CommandLine = Module("commandline", {
|
||||
},
|
||||
|
||||
hideCompletions: function hideCompletions() {
|
||||
for (let nodeSet in values([this.widgets.statusbar, this.widgets.commandbar]))
|
||||
for (let nodeSet of values([this.widgets.statusbar, this.widgets.commandbar]))
|
||||
if (nodeSet.commandline.completionList)
|
||||
nodeSet.commandline.completionList.visible = false;
|
||||
},
|
||||
@@ -1882,7 +1882,7 @@ var CommandLine = Module("commandline", {
|
||||
persistent: true,
|
||||
action: function (timespan, host) {
|
||||
let store = commandline._store;
|
||||
for (let [k, v] in store) {
|
||||
for (let [k, v] of store) {
|
||||
if (k == "command")
|
||||
store.set(k, v.filter(item =>
|
||||
!(timespan.contains(item.timestamp) && (!host || commands.hasDomain(item.value, host)))));
|
||||
@@ -1974,8 +1974,11 @@ var ItemList = Class("ItemList", {
|
||||
.filter(c => c.items.length || c.message || c.incomplete)
|
||||
.map(this.getGroup, this),
|
||||
|
||||
get selected() let (g = this.selectedGroup) g && g.selectedIdx != null
|
||||
? [g.context, g.selectedIdx] : null,
|
||||
get selected() {
|
||||
let g = this.selectedGroup;
|
||||
return g && g.selectedIdx != null ? [g.context, g.selectedIdx]
|
||||
: null;
|
||||
},
|
||||
|
||||
getRelativeItem: function getRelativeItem(offset, tuple, noWrap) {
|
||||
let groups = this.activeGroups;
|
||||
@@ -2021,7 +2024,11 @@ var ItemList = Class("ItemList", {
|
||||
if (start < 0 || start >= this.itemCount)
|
||||
return null;
|
||||
|
||||
group = groups.find(g => let (i = start - g.offsets.start) i >= 0 && i < g.itemCount);
|
||||
group = groups.find(g => {
|
||||
let i = start - g.offsets.start;
|
||||
return i >= 0 && i < g.itemCount;
|
||||
});
|
||||
|
||||
return [group.context, start - group.offsets.start];
|
||||
},
|
||||
|
||||
@@ -2075,7 +2082,7 @@ var ItemList = Class("ItemList", {
|
||||
updateOffsets: function updateOffsets() {
|
||||
let total = this.itemCount;
|
||||
let count = 0;
|
||||
for (let group in values(this.activeGroups)) {
|
||||
for (let group of values(this.activeGroups)) {
|
||||
group.offsets = { start: count, end: total - count - group.itemCount };
|
||||
count += group.itemCount;
|
||||
}
|
||||
@@ -2090,7 +2097,7 @@ var ItemList = Class("ItemList", {
|
||||
|
||||
let container = DOM(this.nodes.completions);
|
||||
let groups = this.activeGroups;
|
||||
for (let group in values(groups)) {
|
||||
for (let group of values(groups)) {
|
||||
group.reset();
|
||||
container.append(group.nodes.root);
|
||||
}
|
||||
@@ -2133,7 +2140,7 @@ var ItemList = Class("ItemList", {
|
||||
* @private
|
||||
*/
|
||||
draw: function draw() {
|
||||
for (let group in values(this.activeGroups))
|
||||
for (let group of values(this.activeGroups))
|
||||
group.draw();
|
||||
|
||||
// We need to collect all of the rescrolling functions in
|
||||
@@ -2244,7 +2251,7 @@ var ItemList = Class("ItemList", {
|
||||
}
|
||||
|
||||
let count = this.maxItems;
|
||||
for (let group in values(groups)) {
|
||||
for (let group of groups) {
|
||||
let off = Math.max(0, start - group.offsets.start);
|
||||
|
||||
group.count = Math.constrain(group.itemCount - off, 0, count);
|
||||
@@ -2379,7 +2386,7 @@ var ItemList = Class("ItemList", {
|
||||
|
||||
if (!this.generatedRange.contains(this.range)) {
|
||||
if (this.generatedRange.end == 0)
|
||||
var [start, end] = this.range;
|
||||
var [start, end] = Array.slice(this.range);
|
||||
else {
|
||||
start = this.range.start - (this.range.start <= this.generatedRange.start
|
||||
? this.maxItems / 2 : 0);
|
||||
@@ -2391,19 +2398,20 @@ var ItemList = Class("ItemList", {
|
||||
Math.min(this.itemCount, end));
|
||||
|
||||
let first;
|
||||
for (let [i, row] in this.context.getRows(this.generatedRange.start,
|
||||
for (let [i, row] of this.context.getRows(this.generatedRange.start,
|
||||
this.generatedRange.end,
|
||||
this.doc))
|
||||
this.doc)) {
|
||||
if (!range.contains(i))
|
||||
DOM(row).remove();
|
||||
else if (!first)
|
||||
first = row;
|
||||
}
|
||||
|
||||
let container = DOM(this.nodes.items);
|
||||
let before = first ? DOM(first).bound.before
|
||||
: DOM(this.nodes.items).bound.append;
|
||||
|
||||
for (let [i, row] in this.context.getRows(range.start, range.end,
|
||||
for (let [i, row] of this.context.getRows(range.start, range.end,
|
||||
this.doc)) {
|
||||
if (i < this.generatedRange.start)
|
||||
before(row);
|
||||
|
||||
@@ -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-2014 Kris Maglione <maglione.k@gmail.com>
|
||||
// Copyright (c) 2008-2015 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.
|
||||
@@ -47,7 +47,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
},
|
||||
|
||||
cleanup: function () {
|
||||
for (let cleanup in values(this.cleanups))
|
||||
for (let cleanup of values(this.cleanups))
|
||||
cleanup.call(this);
|
||||
|
||||
delete window.dactyl;
|
||||
@@ -73,7 +73,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
// has :set go= or something similar in his config
|
||||
hideGUI: function () {
|
||||
let guioptions = config.guioptions;
|
||||
for (let option in guioptions) {
|
||||
for (let option of guioptions) {
|
||||
guioptions[option].forEach(function (elem) {
|
||||
try {
|
||||
document.getElementById(elem).collapsed = true;
|
||||
@@ -87,7 +87,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
"dactyl-cleanup": function dactyl_cleanup(subject, reason) {
|
||||
let modules = dactyl.modules;
|
||||
|
||||
for (let mod in values(modules.moduleList.reverse())) {
|
||||
for (let mod of values(modules.moduleList.reverse())) {
|
||||
mod.stale = true;
|
||||
if ("cleanup" in mod)
|
||||
this.trapErrors("cleanup", mod, reason);
|
||||
@@ -97,7 +97,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
|
||||
modules.moduleManager.initDependencies("cleanup");
|
||||
|
||||
for (let name in values(Object.getOwnPropertyNames(modules).reverse()))
|
||||
for (let name of values(Object.getOwnPropertyNames(modules).reverse()))
|
||||
try {
|
||||
delete modules[name];
|
||||
}
|
||||
@@ -131,7 +131,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
if (~["menu", "menupopup"].indexOf(node.localName) && node.children.length)
|
||||
DOM(node).popupshowing({ bubbles: false });
|
||||
|
||||
for (let [, item] in Iterator(node.childNodes)) {
|
||||
for (let item of node.childNodes) {
|
||||
if (item.childNodes.length == 0 && item.localName == "menuitem"
|
||||
&& !item.hidden
|
||||
&& !/rdf:http:/.test(item.getAttribute("label"))) { // FIXME
|
||||
@@ -169,7 +169,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
get forceOpen() ({ background: this.forceBackground,
|
||||
target: this.forceTarget }),
|
||||
set forceOpen(val) {
|
||||
for (let [k, v] in Iterator({ background: "forceBackground", target: "forceTarget" }))
|
||||
for (let [k, v] of iter({ background: "forceBackground", target: "forceTarget" }))
|
||||
if (k in val)
|
||||
this[v] = val[k];
|
||||
},
|
||||
@@ -205,7 +205,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
},
|
||||
|
||||
registerObservers: function registerObservers(obj, prop) {
|
||||
for (let [signal, func] in Iterator(obj[prop || "signals"]))
|
||||
for (let [signal, func] of iter(obj[prop || "signals"]))
|
||||
this.registerObserver(signal, func.bind(obj), false);
|
||||
},
|
||||
|
||||
@@ -238,8 +238,11 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
let results = array(params.iterate(args))
|
||||
.sort((a, b) => String.localeCompare(a.name, b.name));
|
||||
|
||||
let filters = args.map(arg => let (re = util.regexp.escape(arg))
|
||||
util.regexp("\\b" + re + "\\b|(?:^|[()\\s])" + re + "(?:$|[()\\s])", "i"));
|
||||
let filters = args.map(arg => {
|
||||
let re = util.regexp.escape(arg);
|
||||
return util.regexp("\\b" + re + "\\b|(?:^|[()\\s])" + re + "(?:$|[()\\s])", "i");
|
||||
});
|
||||
|
||||
if (filters.length)
|
||||
results = results.filter(item => filters.every(re => keys(item).some(re.bound.test)));
|
||||
|
||||
@@ -254,7 +257,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
context.ignoreCase = true;
|
||||
let seen = {};
|
||||
context.completions = array(keys(item).join(" ").toLowerCase().split(/[()\s]+/)
|
||||
for (item in params.iterate(args)))
|
||||
for (item of params.iterate(args)))
|
||||
.flatten()
|
||||
.map(function (k) {
|
||||
seen[k] = (seen[k] || 0) + 1;
|
||||
@@ -265,11 +268,11 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
});
|
||||
|
||||
if (params.index)
|
||||
this.indices[params.index] = function () {
|
||||
this.indices[params.index] = function* () {
|
||||
let results = array((params.iterateIndex || params.iterate).call(params, commands.get(name).newArgs()))
|
||||
.array.sort((a, b) => String.localeCompare(a.name, b.name));
|
||||
|
||||
for (let obj in values(results)) {
|
||||
for (let obj of values(results)) {
|
||||
let res = dactyl.generateHelp(obj, null, null, true);
|
||||
if (!hasOwnProperty(help.tags, obj.helpTag))
|
||||
res[0][1].tag = obj.helpTag;
|
||||
@@ -536,7 +539,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
if (!silent)
|
||||
commands.lastCommand = str.replace(/^\s*:\s*/, "");
|
||||
let res = true;
|
||||
for (let [command, args] in commands.parseCommands(str.replace(/^'(.*)'$/, "$1"))) {
|
||||
for (let [command, args] of commands.parseCommands(str.replace(/^'(.*)'$/, "$1"))) {
|
||||
if (command === null)
|
||||
throw FailedAssertion(_("dactyl.notCommand", config.appName, args.commandString));
|
||||
|
||||
@@ -667,10 +670,12 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
else if (obj instanceof Map) {
|
||||
spec = map => (obj.count ? [["oa", {}, "count"], map]
|
||||
: DOM.DOMString(map));
|
||||
tag = map => [
|
||||
let (c = obj.modes[0].char) c ? c + "_" : "",
|
||||
map
|
||||
];
|
||||
tag = map => {
|
||||
let c = obj.modes[0].char;
|
||||
return [c ? c + "_" : "",
|
||||
map];
|
||||
};
|
||||
|
||||
link = map => {
|
||||
let [, mode, name, extra] = /^(?:(.)_)?(?:<([^>]+)>)?(.*)$/.exec(map);
|
||||
let k = ["k", {}, extra];
|
||||
@@ -700,17 +705,16 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
extraHelp ? extraHelp : "",
|
||||
!(extraHelp || obj.description) ? ["p", {}, /*L*/ "Sorry, no help available."] : ""];
|
||||
|
||||
let name = (obj.specs || obj.names)[0];
|
||||
res.push(
|
||||
["item", {},
|
||||
["tags", {}, template.map(obj.names.slice().reverse(),
|
||||
tag,
|
||||
" ").join("")],
|
||||
["spec", {},
|
||||
let (name = (obj.specs || obj.names)[0])
|
||||
spec(template.highlightRegexp(tag(name),
|
||||
/\[(.*?)\]/g,
|
||||
(m, n0) => ["oa", {}, n0]),
|
||||
name)],
|
||||
["spec", {}, spec(template.highlightRegexp(tag(name),
|
||||
/\[(.*?)\]/g,
|
||||
(m, n0) => ["oa", {}, n0]),
|
||||
name)],
|
||||
!obj.type ? "" : [
|
||||
["type", {}, obj.type],
|
||||
["default", {}, obj.stringDefaultValue]],
|
||||
@@ -790,13 +794,14 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
|
||||
dactyl.echomsg(
|
||||
_("plugin.searchingForIn",
|
||||
("plugins/**/*.{js," + config.fileExtension + "}").quote(),
|
||||
[dir.path.replace(/.plugins$/, "") for ([, dir] in Iterator(dirs))]
|
||||
.join(",").quote()),
|
||||
JSON.stringify("plugins/**/*.{js," + config.fileExtension + "}"),
|
||||
JSON.stringify([dir.path.replace(/.plugins$/, "")
|
||||
for (dir of dirs)]
|
||||
.join(","))),
|
||||
2);
|
||||
|
||||
dirs.forEach(function (dir) {
|
||||
dactyl.echomsg(_("plugin.searchingFor", (dir.path + "/**/*.{js," + config.fileExtension + "}").quote()), 3);
|
||||
dactyl.echomsg(_("plugin.searchingFor", JSON.stringify(dir.path + "/**/*.{js," + config.fileExtension + "}")), 3);
|
||||
sourceDirectory(dir);
|
||||
});
|
||||
},
|
||||
@@ -909,7 +914,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
params = { where: params };
|
||||
|
||||
let flags = 0;
|
||||
for (let [opt, flag] in Iterator({ replace: "REPLACE_HISTORY", hide: "BYPASS_HISTORY" }))
|
||||
for (let [opt, flag] of iter({ replace: "REPLACE_HISTORY", hide: "BYPASS_HISTORY" }))
|
||||
flags |= params[opt] && Ci.nsIWebNavigation["LOAD_FLAGS_" + flag];
|
||||
|
||||
let where = params.where || dactyl.CURRENT_TAB;
|
||||
@@ -1220,7 +1225,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
// Process plugin help entries.
|
||||
|
||||
let body = [];
|
||||
for (let [, context] in Iterator(plugins.contexts))
|
||||
for (let context of values(plugins.contexts))
|
||||
try {
|
||||
let info = contexts.getDocs(context);
|
||||
if (DOM.isJSONXML(info)) {
|
||||
@@ -1371,7 +1376,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
N: ["Tab number over icon", highlight.selector("TabIconNumber")]
|
||||
},
|
||||
setter: function (opts) {
|
||||
let classes = [v[1] for ([k, v] in Iterator(this.opts)) if (opts.indexOf(k) < 0)];
|
||||
let classes = [v[1] for ([k, v] of iter(this.opts)) if (opts.indexOf(k) < 0)];
|
||||
|
||||
styles.system.add("taboptions", "chrome://*",
|
||||
classes.length ? classes.join(",") + "{ display: none; }" : "");
|
||||
@@ -1392,14 +1397,14 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
|
||||
// FIXME: cleanup
|
||||
cleanupValue: config.cleanups.guioptions ||
|
||||
"rb" + [k for ([k, v] in iter(groups[1].opts))
|
||||
"rb" + [k for ([k, v] of 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))])
|
||||
values: array(groups).map(g => [[k, v[0]] for ([k, v] of iter(g.opts))])
|
||||
.flatten(),
|
||||
|
||||
setter: function (value) {
|
||||
for (let group in values(groups))
|
||||
for (let group of values(groups))
|
||||
group.setter(value);
|
||||
events.checkFocus();
|
||||
return value;
|
||||
@@ -1494,7 +1499,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
config.dialogs[dialog][1]();
|
||||
}
|
||||
catch (e) {
|
||||
dactyl.echoerr(_("error.cantOpen", dialog.quote(), e.message || e));
|
||||
dactyl.echoerr(_("error.cantOpen", JSON.stringify(dialog), e.message || e));
|
||||
}
|
||||
}, {
|
||||
argCount: "1",
|
||||
@@ -1513,7 +1518,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
dactyl.assert(items.some(i => i.dactylPath == arg),
|
||||
_("emenu.notFound", arg));
|
||||
|
||||
for (let [, item] in Iterator(items)) {
|
||||
for (let item of items) {
|
||||
if (item.dactylPath == arg) {
|
||||
dactyl.assert(!item.disabled, _("error.disabled", item.dactylPath));
|
||||
item.doCommand();
|
||||
@@ -1716,7 +1721,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
let each, eachUnits, totalUnits;
|
||||
let total = 0;
|
||||
|
||||
for (let i in util.interruptibleRange(0, count, 500)) {
|
||||
for (let i of util.interruptibleRange(0, count, 500)) {
|
||||
let now = Date.now();
|
||||
func();
|
||||
total += Date.now() - now;
|
||||
@@ -1843,7 +1848,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
completion.dialog = function dialog(context) {
|
||||
context.title = ["Dialog"];
|
||||
context.filters.push(({ item }) => !item[2] || item[2]());
|
||||
context.completions = [[k, v[0], v[2]] for ([k, v] in Iterator(config.dialogs))];
|
||||
context.completions = [[k, v[0], v[2]] for ([k, v] of iter(config.dialogs))];
|
||||
};
|
||||
|
||||
completion.menuItem = function menuItem(context) {
|
||||
@@ -1988,7 +1993,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
// after sourcing the initialization files, this function will set
|
||||
// all gui options to their default values, if they have not been
|
||||
// set before by any RC file
|
||||
for (let option in values(options.needInit))
|
||||
for (let option of values(options.needInit))
|
||||
option.initValue();
|
||||
|
||||
if (dactyl.commandLineOptions.postCommands)
|
||||
|
||||
@@ -245,7 +245,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
||||
range[container]);
|
||||
|
||||
let delta = 0;
|
||||
for (let node in Editor.TextsIterator(range)) {
|
||||
for (let node of Editor.TextsIterator(range)) {
|
||||
let text = node.textContent;
|
||||
let start = 0, end = text.length;
|
||||
if (node == range.startContainer)
|
||||
@@ -427,7 +427,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
||||
column = 1 + pre.replace(/[^]*\n/, "").length;
|
||||
|
||||
let origGroup = DOM(textBox).highlight.toString();
|
||||
let cleanup = promises.task(function cleanup(error) {
|
||||
let cleanup = promises.task(function* cleanup(error) {
|
||||
if (timer)
|
||||
timer.cancel();
|
||||
|
||||
@@ -447,7 +447,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
||||
if (!keepFocus)
|
||||
dactyl.focus(textBox);
|
||||
|
||||
for (let group in values(blink.concat(blink, ""))) {
|
||||
for (let group of values(blink.concat(blink, ""))) {
|
||||
highlight.highlightNode(textBox, origGroup + " " + group);
|
||||
|
||||
yield promises.sleep(100);
|
||||
@@ -548,7 +548,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
||||
this.range = range;
|
||||
},
|
||||
|
||||
__iterator__: function __iterator__() {
|
||||
"@@iterator": function* __iterator__() {
|
||||
while (this.nextNode())
|
||||
yield this.context;
|
||||
},
|
||||
@@ -1122,14 +1122,15 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
||||
bind(["<C-t>"], "Edit text field in Text Edit mode",
|
||||
function () {
|
||||
dactyl.assert(!editor.isTextEdit && editor.editor);
|
||||
dactyl.assert(dactyl.focusedElement ||
|
||||
// Sites like Google like to use a
|
||||
// hidden, editable window for keyboard
|
||||
// focus and use their own WYSIWYG editor
|
||||
// implementations for the visible area,
|
||||
// which we can't handle.
|
||||
let (f = document.commandDispatcher.focusedWindow.frameElement)
|
||||
f && Hints.isVisible(f, true));
|
||||
if (!dactyl.focusedElement) {
|
||||
// Sites like Google like to use a
|
||||
// hidden, editable window for keyboard
|
||||
// focus and use their own WYSIWYG editor
|
||||
// implementations for the visible area,
|
||||
// which we can't handle.
|
||||
let f = document.commandDispatcher.focusedWindow.frameElement;
|
||||
dactyl.assert(f && Hints.isVisible(f, true));
|
||||
}
|
||||
|
||||
modes.push(modes.TEXT_EDIT);
|
||||
});
|
||||
@@ -1371,7 +1372,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
||||
has: function (key) util.compileMacro(this.value).seen.has(key),
|
||||
validator: function (value) {
|
||||
this.format({}, value);
|
||||
let allowed = RealSet(["column", "file", "line"]);
|
||||
let allowed = new RealSet(["column", "file", "line"]);
|
||||
return [k for (k of util.compileMacro(value).seen)]
|
||||
.every(k => allowed.has(k));
|
||||
}
|
||||
@@ -1409,7 +1410,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
||||
persistent: true,
|
||||
action: function (timespan, host) {
|
||||
if (!host) {
|
||||
for (let [k, v] in editor.registers)
|
||||
for (let [k, v] of editor.registers)
|
||||
if (timespan.contains(v.timestamp))
|
||||
editor.registers.remove(k);
|
||||
editor.registerRing.truncate(0);
|
||||
|
||||
@@ -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-2014 Kris Maglione <maglione.k at Gmail>
|
||||
// Copyright (c) 2008-2015 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.
|
||||
@@ -49,7 +49,7 @@ var EventHive = Class("EventHive", Contexts.Hive, {
|
||||
listen: function (target, event, callback, capture, allowUntrusted) {
|
||||
var [self, events] = this._events(event, callback);
|
||||
|
||||
for (let [event, callback] in Iterator(events)) {
|
||||
for (let [event, callback] of iter(events)) {
|
||||
let args = [util.weakReference(target),
|
||||
util.weakReference(self),
|
||||
event,
|
||||
@@ -119,7 +119,7 @@ var Events = Module("events", {
|
||||
|
||||
this._macros = storage.newMap("registers", { privateData: true, store: true });
|
||||
if (storage.exists("macros")) {
|
||||
for (let [k, m] in storage.newMap("macros", { store: true }))
|
||||
for (let [k, m] of storage.newMap("macros", { store: true }))
|
||||
this._macros.set(k, { text: m.keys, timestamp: m.timeRecorded * 1000 });
|
||||
storage.remove("macros");
|
||||
}
|
||||
@@ -308,7 +308,7 @@ var Events = Module("events", {
|
||||
*/
|
||||
getMacros: function (filter) {
|
||||
let re = RegExp(filter || "");
|
||||
return ([k, m.text] for ([k, m] in editor.registers) if (re.test(k)));
|
||||
return ([k, m.text] for ([k, m] of editor.registers) if (re.test(k)));
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -319,7 +319,7 @@ var Events = Module("events", {
|
||||
*/
|
||||
deleteMacros: function (filter) {
|
||||
let re = RegExp(filter || "");
|
||||
for (let [item, ] in editor.registers) {
|
||||
for (let [item, ] of editor.registers) {
|
||||
if (!filter || re.test(item))
|
||||
editor.registers.remove(item);
|
||||
}
|
||||
@@ -373,10 +373,10 @@ var Events = Module("events", {
|
||||
if (quiet)
|
||||
commandline.quiet = quiet;
|
||||
|
||||
for (let [, evt_obj] in Iterator(DOM.Event.parse(keys))) {
|
||||
for (let evt_obj of DOM.Event.parse(keys)) {
|
||||
let now = Date.now();
|
||||
let key = DOM.Event.stringify(evt_obj);
|
||||
for (let type in values(["keydown", "keypress", "keyup"])) {
|
||||
for (let type of values(["keydown", "keypress", "keyup"])) {
|
||||
let evt = update({}, evt_obj, { type: type });
|
||||
if (type !== "keypress" && !evt.keyCode)
|
||||
evt.keyCode = evt._keyCode || 0;
|
||||
@@ -475,13 +475,13 @@ var Events = Module("events", {
|
||||
.toObject();
|
||||
|
||||
outer:
|
||||
for (let [, key] in iter(elements))
|
||||
for (let [, key] of iter(elements))
|
||||
if (filters.some(([k, v]) => key.getAttribute(k) == v)) {
|
||||
let keys = { ctrlKey: false, altKey: false, shiftKey: false, metaKey: false };
|
||||
let needed = { ctrlKey: event.ctrlKey, altKey: event.altKey, shiftKey: event.shiftKey, metaKey: event.metaKey };
|
||||
|
||||
let modifiers = (key.getAttribute("modifiers") || "").trim().split(/[\s,]+/);
|
||||
for (let modifier in values(modifiers))
|
||||
for (let modifier of values(modifiers))
|
||||
switch (modifier) {
|
||||
case "access": update(keys, access); break;
|
||||
case "accel": keys[accel] = true; break;
|
||||
@@ -489,7 +489,7 @@ var Events = Module("events", {
|
||||
case "any":
|
||||
if (!iter.some(keys, ([k, v]) => v && needed[k]))
|
||||
continue outer;
|
||||
for (let [k, v] in iter(keys)) {
|
||||
for (let [k, v] of iter(keys)) {
|
||||
if (v)
|
||||
needed[k] = false;
|
||||
keys[k] = false;
|
||||
@@ -677,7 +677,7 @@ var Events = Module("events", {
|
||||
let ourEvent = DOM.Event.feedingEvent;
|
||||
DOM.Event.feedingEvent = null;
|
||||
if (ourEvent)
|
||||
for (let [k, v] in Iterator(ourEvent))
|
||||
for (let [k, v] of iter(ourEvent))
|
||||
if (!(k in event))
|
||||
event[k] = v;
|
||||
|
||||
@@ -781,7 +781,7 @@ var Events = Module("events", {
|
||||
if (this.feedingKeys)
|
||||
this.duringFeed = this.duringFeed.concat(duringFeed);
|
||||
else
|
||||
for (let event in values(duringFeed))
|
||||
for (let event of values(duringFeed))
|
||||
try {
|
||||
DOM.Event.dispatch(event.originalTarget, event, event);
|
||||
}
|
||||
@@ -797,6 +797,8 @@ var Events = Module("events", {
|
||||
else if (!this.processor)
|
||||
this.keyEvents = [];
|
||||
|
||||
let key = DOM.Event.stringify(event);
|
||||
|
||||
let pass = this.passing && !event.isMacro ||
|
||||
DOM.Event.feedingEvent && DOM.Event.feedingEvent.isReplay ||
|
||||
event.isReplay ||
|
||||
@@ -807,14 +809,13 @@ var Events = Module("events", {
|
||||
!modes.passThrough && this.shouldPass(event) ||
|
||||
!this.processor && event.type === "keydown"
|
||||
&& options.get("passunknown").getKey(modes.main.allBases)
|
||||
&& 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))));
|
||||
&& !(modes.main.count && /^\d$/.test(key) ||
|
||||
modes.main.allBases.some(
|
||||
mode => mappings.hives
|
||||
.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() + " " + key +
|
||||
" passing: " + this.passing + " " +
|
||||
" pass: " + pass +
|
||||
" replay: " + event.isReplay +
|
||||
@@ -924,12 +925,18 @@ var Events = Module("events", {
|
||||
if (elem == null && urlbar && urlbar.inputField == this._lastFocus.get())
|
||||
util.threadYield(true); // Why? --Kris
|
||||
|
||||
while (modes.main.ownsFocus
|
||||
&& let ({ ownsFocus } = modes.topOfStack.params)
|
||||
(!ownsFocus ||
|
||||
ownsFocus.get() != elem &&
|
||||
ownsFocus.get() != win)
|
||||
&& !modes.topOfStack.params.holdFocus)
|
||||
let ownsFocus = () => {
|
||||
if (!modes.main.ownsFocus)
|
||||
return false;
|
||||
|
||||
let { ownsFocus } = modes.topOfStack.params;
|
||||
if (ownsFocus && ~[elem, win].indexOf(ownsFocus.get()))
|
||||
return false;
|
||||
|
||||
return !modes.topOfStack.params.holdFocus;
|
||||
};
|
||||
|
||||
while (ownsFocus())
|
||||
modes.pop(null, { fromFocus: true });
|
||||
}
|
||||
finally {
|
||||
@@ -966,9 +973,10 @@ var Events = Module("events", {
|
||||
PASS_THROUGH: {},
|
||||
WAIT: null,
|
||||
|
||||
isEscape: function isEscape(event)
|
||||
let (key = isString(event) ? event : DOM.Event.stringify(event))
|
||||
key === "<Esc>" || key === "<C-[>",
|
||||
isEscape: function isEscape(event) {
|
||||
let key = isString(event) ? event : DOM.Event.stringify(event);
|
||||
return key === "<Esc>" || key === "<C-[>";
|
||||
},
|
||||
|
||||
isHidden: function isHidden(elem, aggressive) {
|
||||
if (DOM(elem).style.visibility !== "visible")
|
||||
@@ -1033,7 +1041,7 @@ var Events = Module("events", {
|
||||
completion: function initCompletion() {
|
||||
completion.macro = function macro(context) {
|
||||
context.title = ["Macro", "Keys"];
|
||||
context.completions = [item for (item in events.getMacros())];
|
||||
context.completions = [item for (item of events.getMacros())];
|
||||
};
|
||||
},
|
||||
mappings: function initMappings() {
|
||||
@@ -1140,7 +1148,7 @@ var Events = Module("events", {
|
||||
"sitemap", "", {
|
||||
flush: function flush() {
|
||||
memoize(this, "filters", function () this.value.filter(function (f) f(buffer.documentURI)));
|
||||
memoize(this, "pass", function () RealSet(array.flatten(this.filters.map(function (f) f.keys))));
|
||||
memoize(this, "pass", function () new RealSet(array.flatten(this.filters.map(function (f) f.keys))));
|
||||
memoize(this, "commandHive", function hive() Hive(this.filters, "command"));
|
||||
memoize(this, "inputHive", function hive() Hive(this.filters, "input"));
|
||||
},
|
||||
|
||||
@@ -179,7 +179,7 @@ var HintSession = Class("HintSession", CommandMode, {
|
||||
getHintNumber: function getHintNumber(str) {
|
||||
let base = this.hintKeys.length;
|
||||
let res = 0;
|
||||
for (let char in values(str))
|
||||
for (let char of values(str))
|
||||
res = res * base + this.hintKeys.indexOf(char);
|
||||
return res;
|
||||
},
|
||||
@@ -286,7 +286,7 @@ var HintSession = Class("HintSession", CommandMode, {
|
||||
|
||||
memoize(doc, "dactylLabels", () =>
|
||||
iter([l.getAttribute("for"), l]
|
||||
for (l in array.iterValues(doc.querySelectorAll("label[for]"))))
|
||||
for (l of array.iterValues(doc.querySelectorAll("label[for]"))))
|
||||
.toObject());
|
||||
|
||||
let [offsetX, offsetY] = this.getContainerOffsets(doc);
|
||||
@@ -330,7 +330,7 @@ var HintSession = Class("HintSession", CommandMode, {
|
||||
|
||||
let start = this.pageHints.length;
|
||||
let _hints = [];
|
||||
for (let elem in res)
|
||||
for (let elem of res)
|
||||
if (isVisible(elem) && (!mode.filter || mode.filter(elem)))
|
||||
_hints.push({
|
||||
elem: elem,
|
||||
@@ -545,14 +545,14 @@ var HintSession = Class("HintSession", CommandMode, {
|
||||
* hint disappears.
|
||||
*/
|
||||
removeHints: function _removeHints(timeout) {
|
||||
for (let { doc, start, end } in values(this.docs)) {
|
||||
for (let { doc, start, end } of values(this.docs)) {
|
||||
DOM(doc.documentElement).highlight.remove("Hinting");
|
||||
// Goddamn stupid fucking Gecko 1.x security manager bullshit.
|
||||
try { delete doc.dactylLabels; } catch (e) { doc.dactylLabels = undefined; }
|
||||
|
||||
for (let elem in DOM.XPath("//*[@dactyl:highlight='hints']", doc))
|
||||
for (let elem of DOM.XPath("//*[@dactyl:highlight='hints']", doc))
|
||||
elem.parentNode.removeChild(elem);
|
||||
for (let i in util.range(start, end + 1)) {
|
||||
for (let i of util.range(start, end + 1)) {
|
||||
this.pageHints[i].ambiguous = false;
|
||||
this.pageHints[i].valid = false;
|
||||
}
|
||||
@@ -590,12 +590,12 @@ var HintSession = Class("HintSession", CommandMode, {
|
||||
let activeHint = this.hintNumber || 1;
|
||||
this.validHints = [];
|
||||
|
||||
for (let { doc, start, end } in values(this.docs)) {
|
||||
for (let { doc, start, end } of values(this.docs)) {
|
||||
DOM(doc.documentElement).highlight.add("Hinting");
|
||||
let [offsetX, offsetY] = this.getContainerOffsets(doc);
|
||||
|
||||
inner:
|
||||
for (let i in (util.interruptibleRange(start, end + 1, 500))) {
|
||||
for (let i of util.interruptibleRange(start, end + 1, 500)) {
|
||||
if (this.showCount != count)
|
||||
return;
|
||||
|
||||
@@ -644,13 +644,13 @@ var HintSession = Class("HintSession", CommandMode, {
|
||||
}
|
||||
|
||||
let base = this.hintKeys.length;
|
||||
for (let [i, hint] in Iterator(this.validHints))
|
||||
for (let [i, hint] of iter(this.validHints))
|
||||
hint.ambiguous = (i + 1) * base <= this.validHints.length;
|
||||
|
||||
if (options["usermode"]) {
|
||||
let css = [];
|
||||
for (let hint in values(this.pageHints)) {
|
||||
let selector = highlight.selector("Hint") + "[number=" + hint.span.getAttribute("number").quote() + "]";
|
||||
for (let hint of values(this.pageHints)) {
|
||||
let selector = highlight.selector("Hint") + "[number=" + JSON.stringify(hint.span.getAttribute("number")) + "]";
|
||||
let imgSpan = "[dactyl|hl=HintImage]";
|
||||
css.push(selector + ":not(" + imgSpan + ") { " + hint.span.style.cssText + " }");
|
||||
if (hint.imgSpan)
|
||||
@@ -699,7 +699,7 @@ var HintSession = Class("HintSession", CommandMode, {
|
||||
|
||||
updateValidNumbers: function updateValidNumbers(always) {
|
||||
let string = this.getHintString(this.hintNumber);
|
||||
for (let hint in values(this.validHints))
|
||||
for (let hint of values(this.validHints))
|
||||
hint.valid = always || hint.span.getAttribute("number").startsWith(string);
|
||||
},
|
||||
|
||||
@@ -866,7 +866,7 @@ var Hints = Module("hints", {
|
||||
if (DOM(elem).isInput)
|
||||
return [elem.value, false];
|
||||
else {
|
||||
for (let [, option] in Iterator(options["hintinputs"])) {
|
||||
for (let option of options["hintinputs"]) {
|
||||
if (option == "value") {
|
||||
if (elem instanceof Ci.nsIDOMHTMLSelectElement) {
|
||||
if (elem.selectedIndex >= 0)
|
||||
@@ -1022,7 +1022,7 @@ var Hints = Module("hints", {
|
||||
*/
|
||||
function stringsAtBeginningOfWords(strings, words, allowWordOverleaping) {
|
||||
let strIdx = 0;
|
||||
for (let [, word] in Iterator(words)) {
|
||||
for (let word of words) {
|
||||
if (word.length == 0)
|
||||
continue;
|
||||
|
||||
@@ -1077,7 +1077,8 @@ var Hints = Module("hints", {
|
||||
autocomplete: false,
|
||||
completer: function (context) {
|
||||
context.compare = () => 0;
|
||||
context.completions = [[k, v.prompt] for ([k, v] in Iterator(hints.modes))];
|
||||
context.completions = [[k, v.prompt]
|
||||
for ([k, v] of iter(hints.modes))];
|
||||
},
|
||||
onCancel: mappings.bound.popCommand,
|
||||
onSubmit: function (arg) {
|
||||
@@ -1315,14 +1316,18 @@ var Hints = Module("hints", {
|
||||
{
|
||||
keepQuotes: true,
|
||||
|
||||
getKey: function (val, default_)
|
||||
let (res = this.value.find(re => let (match = re.exec(val)) match && match[0] == val))
|
||||
res ? res.matcher
|
||||
: default_,
|
||||
getKey: function (val, default_) {
|
||||
let res = this.value.find(re => {
|
||||
let match = re.exec(val);
|
||||
return match && match[0] == val;
|
||||
});
|
||||
return res ? res.matcher
|
||||
: default_;
|
||||
},
|
||||
|
||||
parse: function parse(val) {
|
||||
let vals = parse.supercall(this, val);
|
||||
for (let value in values(vals))
|
||||
for (let value of values(vals))
|
||||
value.matcher = DOM.compileMatcher(Option.splitList(value.result));
|
||||
return vals;
|
||||
},
|
||||
|
||||
@@ -21,7 +21,7 @@ var History = Module("history", {
|
||||
let query = services.history.getNewQuery();
|
||||
let options = services.history.getNewQueryOptions();
|
||||
|
||||
for (let [k, v] in Iterator(filter))
|
||||
for (let [k, v] of iter(filter))
|
||||
query[k] = v;
|
||||
|
||||
let res = /^([+-])(.+)/.exec(sort);
|
||||
@@ -65,9 +65,9 @@ var History = Module("history", {
|
||||
let obj = [];
|
||||
obj.__defineGetter__("index", () => sh.index);
|
||||
obj.__defineSetter__("index", function (val) { webNav.gotoIndex(val); });
|
||||
obj.__iterator__ = function () array.iterItems(this);
|
||||
obj[Symbol.iterator] = function () array.iterItems(this);
|
||||
|
||||
for (let item in iter(sh.SHistoryEnumerator, Ci.nsISHEntry))
|
||||
for (let item of iter(sh.SHistoryEnumerator, Ci.nsISHEntry))
|
||||
obj.push(update(Object.create(item), {
|
||||
index: obj.length,
|
||||
icon: Class.Memoize(function () services.favicon.getFaviconImageForPage(this.URI).spec)
|
||||
@@ -166,7 +166,7 @@ var History = Module("history", {
|
||||
return dactyl.open(items.map(i => i.url), dactyl.NEW_TAB);
|
||||
|
||||
if (filter.length > 0)
|
||||
dactyl.echoerr(_("history.noMatching", filter.quote()));
|
||||
dactyl.echoerr(_("history.noMatching", JSON.stringify(filter)));
|
||||
else
|
||||
dactyl.echoerr(_("history.none"));
|
||||
return null;
|
||||
@@ -187,7 +187,7 @@ var History = Module("history", {
|
||||
if (/^\d+(:|$)/.test(url) && sh.index - parseInt(url) in sh)
|
||||
return void window.getWebNavigation().gotoIndex(sh.index - parseInt(url));
|
||||
|
||||
for (let [i, ent] in Iterator(sh.slice(0, sh.index).reverse()))
|
||||
for (let [i, ent] of iter(sh.slice(0, sh.index).reverse()))
|
||||
if (ent.URI.spec == url)
|
||||
return void window.getWebNavigation().gotoIndex(i);
|
||||
dactyl.echoerr(_("history.noURL"));
|
||||
@@ -229,7 +229,7 @@ var History = Module("history", {
|
||||
if (/^\d+(:|$)/.test(url) && sh.index + parseInt(url) in sh)
|
||||
return void window.getWebNavigation().gotoIndex(sh.index + parseInt(url));
|
||||
|
||||
for (let [i, ent] in Iterator(sh.slice(sh.index + 1)))
|
||||
for (let [i, ent] of iter(sh.slice(sh.index + 1)))
|
||||
if (ent.URI.spec == url)
|
||||
return void window.getWebNavigation().gotoIndex(i);
|
||||
dactyl.echoerr(_("history.noURL"));
|
||||
@@ -333,7 +333,7 @@ var History = Module("history", {
|
||||
// FIXME: Schema-specific
|
||||
context.generate = () => [
|
||||
Array.slice(row.rev_host).reverse().join("").slice(1)
|
||||
for (row in iter(services.history.DBConnection
|
||||
for (row of iter(services.history.DBConnection
|
||||
.createStatement("SELECT DISTINCT rev_host FROM moz_places WHERE rev_host IS NOT NULL;")))
|
||||
].slice(2);
|
||||
};
|
||||
|
||||
@@ -26,7 +26,7 @@ var ProcessorStack = Class("ProcessorStack", {
|
||||
.flatten().array;
|
||||
this.ownsBuffer = !this.processors.some(p => p.main.ownsBuffer);
|
||||
|
||||
for (let [i, input] in Iterator(this.processors)) {
|
||||
for (let input of this.processors) {
|
||||
let params = input.main.params;
|
||||
|
||||
if (params.preExecute)
|
||||
@@ -82,7 +82,7 @@ var ProcessorStack = Class("ProcessorStack", {
|
||||
// those waiting on further arguments. Execute actions as
|
||||
// long as they continue to return PASS.
|
||||
|
||||
for (var action in values(this.actions)) {
|
||||
for (var action of values(this.actions)) {
|
||||
while (callable(action)) {
|
||||
length = action.eventLength;
|
||||
action = dactyl.trapErrors(action);
|
||||
@@ -171,7 +171,7 @@ var ProcessorStack = Class("ProcessorStack", {
|
||||
|
||||
events.dbg("PROCESS(" + key + ") skipmap: " + event.skipmap + " macro: " + event.isMacro + " replay: " + event.isReplay);
|
||||
|
||||
for (let [i, input] in Iterator(this.processors)) {
|
||||
for (let input of this.processors) {
|
||||
let res = input.process(event);
|
||||
if (res !== Events.ABORT)
|
||||
var result = res;
|
||||
@@ -197,14 +197,14 @@ var ProcessorStack = Class("ProcessorStack", {
|
||||
this._actions = actions;
|
||||
this.actions = actions.concat(this.actions);
|
||||
|
||||
for (let action in values(actions))
|
||||
for (let action of values(actions))
|
||||
if (!("eventLength" in action))
|
||||
action.eventLength = this.events.length;
|
||||
|
||||
if (result === Events.KILL)
|
||||
this.actions = [];
|
||||
else if (!this.actions.length && !processors.length)
|
||||
for (let input in values(this.processors))
|
||||
for (let input of values(this.processors))
|
||||
if (input.fallthrough) {
|
||||
if (result === Events.KILL)
|
||||
break;
|
||||
|
||||
@@ -197,11 +197,11 @@ var MapHive = Class("MapHive", Contexts.Hive, {
|
||||
map.hive = this;
|
||||
|
||||
if (this.name !== "builtin")
|
||||
for (let [, name] in Iterator(map.names))
|
||||
for (let [, mode] in Iterator(map.modes))
|
||||
for (let name of map.names)
|
||||
for (let mode of map.modes)
|
||||
this.remove(mode, name);
|
||||
|
||||
for (let mode in values(map.modes))
|
||||
for (let mode of values(map.modes))
|
||||
this.getStack(mode).add(map);
|
||||
return map;
|
||||
},
|
||||
@@ -255,13 +255,13 @@ var MapHive = Class("MapHive", Contexts.Hive, {
|
||||
*/
|
||||
remove: function (mode, cmd) {
|
||||
let stack = this.getStack(mode);
|
||||
for (let [i, map] in array.iterItems(stack)) {
|
||||
for (let map of stack) {
|
||||
let j = map.names.indexOf(cmd);
|
||||
if (j >= 0) {
|
||||
delete stack.states;
|
||||
map.names.splice(j, 1);
|
||||
if (map.names.length == 0) // FIX ME.
|
||||
for (let [mode, stack] in Iterator(this.stacks))
|
||||
for (let [mode, stack] of iter(this.stacks))
|
||||
this.stacks[mode] = MapHive.Stack(stack.filter(m => m != map));
|
||||
return;
|
||||
}
|
||||
@@ -284,7 +284,7 @@ var MapHive = Class("MapHive", Contexts.Hive, {
|
||||
return self;
|
||||
},
|
||||
|
||||
__iterator__: function () array.iterValues(this),
|
||||
"@@iterator": function () array.iterValues(this),
|
||||
|
||||
get candidates() this.states.candidates,
|
||||
get mappings() this.states.mappings,
|
||||
@@ -300,11 +300,11 @@ var MapHive = Class("MapHive", Contexts.Hive, {
|
||||
mappings: {}
|
||||
};
|
||||
|
||||
for (let map in this)
|
||||
for (let name in values(map.keys)) {
|
||||
for (let map of this)
|
||||
for (let name of values(map.keys)) {
|
||||
states.mappings[name] = map;
|
||||
let state = "";
|
||||
for (let key in DOM.Event.iterKeys(name)) {
|
||||
for (let key of DOM.Event.iterKeys(name)) {
|
||||
state += key;
|
||||
if (state !== name)
|
||||
states.candidates[state] = (states.candidates[state] || 0) + 1;
|
||||
@@ -379,17 +379,17 @@ var Mappings = Module("mappings", {
|
||||
return keys;
|
||||
},
|
||||
|
||||
iterate: function (mode) {
|
||||
let seen = RealSet();
|
||||
for (let hive in this.hives.iterValues())
|
||||
for (let map in array(hive.getStack(mode)).iterValues())
|
||||
iterate: function* (mode) {
|
||||
let seen = new RealSet;
|
||||
for (let hive of this.hives.iterValues())
|
||||
for (let map of array(hive.getStack(mode)).iterValues())
|
||||
if (!seen.add(map.name))
|
||||
yield map;
|
||||
},
|
||||
|
||||
// NOTE: just normal mode for now
|
||||
/** @property {Iterator(Map)} */
|
||||
__iterator__: function () this.iterate(modes.NORMAL),
|
||||
"@@iterator": function () this.iterate(modes.NORMAL),
|
||||
|
||||
getDefault: deprecated("mappings.builtin.get", function getDefault(mode, cmd) this.builtin.get(mode, cmd)),
|
||||
getUserIterator: deprecated("mappings.user.iterator", function getUserIterator(modes) this.user.iterator(modes)),
|
||||
@@ -488,16 +488,19 @@ var Mappings = Module("mappings", {
|
||||
["td", { style: "padding-right: 1em;" }, _("title.Command")],
|
||||
["td", { style: "padding-right: 1em;" }, _("title.Action")]],
|
||||
["col", { style: "min-width: 6em; padding-right: 1em;" }],
|
||||
hives.map(([hive, maps]) => let (i = 0) [
|
||||
["tr", { style: "height: .5ex;" }],
|
||||
maps.map(map =>
|
||||
map.names.map(name =>
|
||||
["tr", {},
|
||||
["td", { highlight: "Title" }, !i++ ? hive.name : ""],
|
||||
["td", {}, modeSign],
|
||||
["td", {}, name],
|
||||
["td", {}, map.rhs || map.action.toSource()]])),
|
||||
["tr", { style: "height: .5ex;" }]])];
|
||||
hives.map(([hive, maps]) => {
|
||||
let i = 0;
|
||||
return [
|
||||
["tr", { style: "height: .5ex;" }],
|
||||
maps.map(map =>
|
||||
map.names.map(name =>
|
||||
["tr", {},
|
||||
["td", { highlight: "Title" }, !i++ ? hive.name : ""],
|
||||
["td", {}, modeSign],
|
||||
["td", {}, name],
|
||||
["td", {}, map.rhs || map.action.toSource()]])),
|
||||
["tr", { style: "height: .5ex;" }]];
|
||||
})];
|
||||
|
||||
// E4X-FIXME
|
||||
// // TODO: Move this to an ItemList to show this automatically
|
||||
@@ -631,16 +634,16 @@ var Mappings = Module("mappings", {
|
||||
literalArg: map.rhs,
|
||||
ignoreDefaults: true
|
||||
}
|
||||
for (map in userMappings(hive))
|
||||
for (map of userMappings(hive))
|
||||
if (map.persist)
|
||||
])
|
||||
.flatten().array;
|
||||
}
|
||||
};
|
||||
function userMappings(hive) {
|
||||
let seen = RealSet();
|
||||
for (let stack in values(hive.stacks))
|
||||
for (let map in array.iterValues(stack))
|
||||
function* userMappings(hive) {
|
||||
let seen = new RealSet;
|
||||
for (let stack of values(hive.stacks))
|
||||
for (let map of array.iterValues(stack))
|
||||
if (!seen.add(map.id))
|
||||
yield map;
|
||||
}
|
||||
@@ -666,7 +669,7 @@ var Mappings = Module("mappings", {
|
||||
let mapmodes = array.uniq(args["-modes"].map(findMode));
|
||||
|
||||
let found = 0;
|
||||
for (let mode in values(mapmodes))
|
||||
for (let mode of values(mapmodes))
|
||||
if (args.bang)
|
||||
args["-group"].clear(mode);
|
||||
else if (args["-group"].has(mode, args[0])) {
|
||||
@@ -699,20 +702,20 @@ var Mappings = Module("mappings", {
|
||||
type: CommandOption.STRING,
|
||||
validator: function (value) Array.concat(value).every(findMode),
|
||||
completer: function () [[array.compact([mode.name.toLowerCase().replace(/_/g, "-"), mode.char]), mode.description]
|
||||
for (mode in values(modes.all))
|
||||
for (mode of values(modes.all))
|
||||
if (!mode.hidden)]
|
||||
};
|
||||
|
||||
function findMode(name) {
|
||||
if (name)
|
||||
for (let mode in values(modes.all))
|
||||
for (let mode of values(modes.all))
|
||||
if (name == mode || name == mode.char
|
||||
|| String.toLowerCase(name).replace(/-/g, "_") == mode.name.toLowerCase())
|
||||
return mode;
|
||||
return null;
|
||||
}
|
||||
function uniqueModes(modes) {
|
||||
let chars = [k for ([k, v] in Iterator(modules.modes.modeChars))
|
||||
let chars = [k for ([k, v] of iter(modules.modes.modeChars))
|
||||
if (v.every(mode => modes.indexOf(mode) >= 0))];
|
||||
|
||||
return array.uniq(modes.filter(m => chars.indexOf(m.char) < 0)
|
||||
@@ -736,25 +739,25 @@ var Mappings = Module("mappings", {
|
||||
|
||||
addMapCommands("", [modes.NORMAL, modes.VISUAL], "");
|
||||
|
||||
for (let mode in modes.mainModes)
|
||||
for (let mode of modes.mainModes)
|
||||
if (mode.char && !commands.get(mode.char + "map", true))
|
||||
addMapCommands(mode.char,
|
||||
[m.mask for (m in modes.mainModes) if (m.char == mode.char)],
|
||||
[m.mask for (m of modes.mainModes) if (m.char == mode.char)],
|
||||
mode.displayName);
|
||||
|
||||
let args = {
|
||||
getMode: function (args) findMode(args["-mode"]),
|
||||
iterate: function (args, mainOnly) {
|
||||
iterate: function* (args, mainOnly) {
|
||||
let modes = [this.getMode(args)];
|
||||
if (!mainOnly)
|
||||
modes = modes[0].allBases;
|
||||
|
||||
let seen = RealSet();
|
||||
let seen = new RealSet;
|
||||
// Bloody hell. --Kris
|
||||
for (let [i, mode] in Iterator(modes))
|
||||
for (let hive in mappings.hives.iterValues())
|
||||
for (let map in array.iterValues(hive.getStack(mode)))
|
||||
for (let name in values(map.names))
|
||||
for (let [i, mode] of iter(modes))
|
||||
for (let hive of mappings.hives.iterValues())
|
||||
for (let map of array.iterValues(hive.getStack(mode)))
|
||||
for (let name of values(map.names))
|
||||
if (!seen.add(name))
|
||||
yield {
|
||||
name: name,
|
||||
@@ -775,8 +778,10 @@ var Mappings = Module("mappings", {
|
||||
: [],
|
||||
template.linkifyHelp(map.description + (map.rhs ? ": " + map.rhs : ""))
|
||||
],
|
||||
help: function (map) let (char = array.compact(map.modes.map(m => m.char))[0])
|
||||
char === "n" ? map.name : char ? char + "_" + map.name : "",
|
||||
help: function (map) {
|
||||
let char = array.compact(map.modes.map(m => m.char))[0];
|
||||
return char === "n" ? map.name : char ? char + "_" + map.name : "";
|
||||
},
|
||||
headings: ["Command", "Mode", "Group", "Description"]
|
||||
}
|
||||
};
|
||||
@@ -798,12 +803,15 @@ var Mappings = Module("mappings", {
|
||||
dactyl.addUsageCommand({
|
||||
__proto__: args,
|
||||
name: [mode.char + "listk[eys]", mode.char + "lk"],
|
||||
iterateIndex: function (args)
|
||||
let (self = this, prefix = /^[bCmn]$/.test(mode.char) ? "" : mode.char + "_",
|
||||
haveTag = k => hasOwnProperty(help.tags, k))
|
||||
({ helpTag: prefix + map.name, __proto__: map }
|
||||
for (map in self.iterate(args, true))
|
||||
if (map.hive === mappings.builtin || haveTag(prefix + map.name))),
|
||||
iterateIndex: function (args) {
|
||||
let self = this;
|
||||
let prefix = /^[bCmn]$/.test(mode.char) ? "" : mode.char + "_";
|
||||
let haveTag = k => hasOwnProperty(help.tags, k);
|
||||
|
||||
return ({ helpTag: prefix + map.name, __proto__: map }
|
||||
for (map of self.iterate(args, true))
|
||||
if (map.hive === mappings.builtin || haveTag(prefix + map.name)));
|
||||
},
|
||||
description: "List all " + mode.displayName + " mode mappings along with their short descriptions",
|
||||
index: mode.char + "-map",
|
||||
getMode: function (args) mode,
|
||||
@@ -823,7 +831,7 @@ var Mappings = Module("mappings", {
|
||||
[
|
||||
null,
|
||||
function (context, obj, args) [[m.names, m.description]
|
||||
for (m in this.iterate(args[0]))]
|
||||
for (m of this.iterate(args[0]))]
|
||||
]);
|
||||
},
|
||||
mappings: function initMappings(dactyl, modules, window) {
|
||||
|
||||
@@ -181,7 +181,7 @@ var Marks = Module("marks", {
|
||||
|
||||
let tab = mark.tab && mark.tab.get();
|
||||
if (!tab || !tab.linkedBrowser || tabs.allTabs.indexOf(tab) == -1)
|
||||
for ([, tab] in iter(tabs.visibleTabs, tabs.allTabs)) {
|
||||
for ([, tab] of iter(tabs.visibleTabs, tabs.allTabs)) {
|
||||
if (tab.linkedBrowser.contentDocument.documentURI.replace(/#.*/, "") === mark.location)
|
||||
break;
|
||||
tab = null;
|
||||
@@ -205,7 +205,7 @@ var Marks = Module("marks", {
|
||||
a.length = b.length = Math.max(a.length, b.length);
|
||||
items = array(a).zip(b).flatten().compact();
|
||||
|
||||
for (let i in items.iterValues()) {
|
||||
for (let i of items.iterValues()) {
|
||||
let entry = sh.getEntryAtIndex(i, false);
|
||||
if (entry.URI.spec.replace(/#.*/, "") == mark.location)
|
||||
return void tab.linkedBrowser.webNavigation.gotoIndex(i);
|
||||
@@ -234,7 +234,7 @@ var Marks = Module("marks", {
|
||||
if (!mark.path)
|
||||
var node = buffer.findScrollable(0, (mark.offset || mark.position).x);
|
||||
else
|
||||
for (node in DOM.XPath(mark.path, buffer.focusedFrame.document))
|
||||
for (node of DOM.XPath(mark.path, buffer.focusedFrame.document))
|
||||
break;
|
||||
|
||||
util.assert(node);
|
||||
@@ -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)));
|
||||
dactyl.assert(marks.length > 0, _("mark.noMatching", filter.quote()));
|
||||
dactyl.assert(marks.length > 0, _("mark.noMatching", JSON.stringify(filter)));
|
||||
}
|
||||
|
||||
commandline.commandOutput(
|
||||
@@ -273,7 +273,7 @@ var Marks = Module("marks", {
|
||||
mark.offset ? Math.round(mark.offset.y)
|
||||
: Math.round(mark.position.y * 100) + "%",
|
||||
mark.location]
|
||||
for ([, [name, mark]] in Iterator(marks)))));
|
||||
for ([name, mark] of marks))));
|
||||
},
|
||||
|
||||
_onPageLoad: function _onPageLoad(event) {
|
||||
@@ -388,18 +388,20 @@ var Marks = Module("marks", {
|
||||
contains: ["history"],
|
||||
action: function (timespan, host) {
|
||||
function matchhost(url) !host || util.isDomainURL(url, host);
|
||||
function match(marks) (k for ([k, v] in Iterator(marks)) if (timespan.contains(v.timestamp) && matchhost(v.location)));
|
||||
function match(marks) (k
|
||||
for ([k, v] in iter(marks))
|
||||
if (timespan.contains(v.timestamp) && matchhost(v.location)));
|
||||
|
||||
for (let [url, local] in marks._localMarks)
|
||||
for (let [url, local] of marks._localMarks)
|
||||
if (matchhost(url)) {
|
||||
for (let key in match(local))
|
||||
for (let key of match(local))
|
||||
delete local[key];
|
||||
if (!Object.keys(local).length)
|
||||
marks._localMarks.remove(url);
|
||||
}
|
||||
marks._localMarks.changed();
|
||||
|
||||
for (let key in match(marks._urlMarks))
|
||||
for (let key of match(marks._urlMarks))
|
||||
marks._urlMarks.remove(key);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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-2014 Kris Maglione <maglione.k@gmail.com>
|
||||
// Copyright (c) 2008-2015 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.
|
||||
@@ -150,7 +150,7 @@ var Modes = Module("modes", {
|
||||
dactyl.focusContent(true);
|
||||
if (prev.main == modes.NORMAL) {
|
||||
dactyl.focusContent(true);
|
||||
for (let frame in values(buffer.allFrames())) {
|
||||
for (let frame of values(buffer.allFrames())) {
|
||||
// clear any selection made
|
||||
let selection = frame.getSelection();
|
||||
if (selection && !selection.isCollapsed)
|
||||
@@ -194,11 +194,13 @@ var Modes = Module("modes", {
|
||||
|
||||
NONE: 0,
|
||||
|
||||
__iterator__: function __iterator__() array.iterValues(this.all),
|
||||
"@@iterator": function __iterator__() array.iterValues(this.all),
|
||||
|
||||
get all() this._modes.slice(),
|
||||
|
||||
get mainModes() (mode for ([k, mode] in Iterator(modes._modeMap)) if (!mode.extended && mode.name == k)),
|
||||
get mainModes() (mode
|
||||
for ([k, mode] of iter(modes._modeMap))
|
||||
if (!mode.extended && mode.name == k)),
|
||||
|
||||
get mainMode() this._modeMap[this._main],
|
||||
|
||||
@@ -236,7 +238,7 @@ var Modes = Module("modes", {
|
||||
|
||||
dumpStack: function dumpStack() {
|
||||
util.dump("Mode stack:");
|
||||
for (let [i, mode] in array.iterItems(this._modeStack))
|
||||
for (let [i, mode] of array.iterItems(this._modeStack))
|
||||
util.dump(" " + i + ": " + mode);
|
||||
},
|
||||
|
||||
@@ -283,7 +285,7 @@ var Modes = Module("modes", {
|
||||
|
||||
save: function save(id, obj, prop, test) {
|
||||
if (!(id in this.boundProperties))
|
||||
for (let elem in array.iterValues(this._modeStack))
|
||||
for (let elem of array.iterValues(this._modeStack))
|
||||
elem.saved[id] = { obj: obj, prop: prop, value: obj[prop], test: test };
|
||||
this.boundProperties[id] = { obj: util.weakReference(obj), prop: prop, test: test };
|
||||
},
|
||||
@@ -328,7 +330,7 @@ var Modes = Module("modes", {
|
||||
dactyl.trapErrors("leave", this.topOfStack.params,
|
||||
{ push: push }, push);
|
||||
|
||||
for (let [id, { obj, prop, test }] in Iterator(this.boundProperties)) {
|
||||
for (let [id, { obj, prop, test }] of iter(this.boundProperties)) {
|
||||
obj = obj.get();
|
||||
if (!obj)
|
||||
delete this.boundProperties[id];
|
||||
@@ -346,7 +348,7 @@ var Modes = Module("modes", {
|
||||
});
|
||||
|
||||
if (stack && stack.pop)
|
||||
for (let { obj, prop, value, test } in values(this.topOfStack.saved))
|
||||
for (let { obj, prop, value, test } of values(this.topOfStack.saved))
|
||||
if (!test || !test(stack, prev))
|
||||
dactyl.trapErrors(function () { obj[prop] = value });
|
||||
|
||||
@@ -442,10 +444,10 @@ var Modes = Module("modes", {
|
||||
this.allBases.indexOf(obj) >= 0 || callable(obj) && this instanceof obj,
|
||||
|
||||
allBases: Class.Memoize(function () {
|
||||
let seen = RealSet(),
|
||||
let seen = new RealSet,
|
||||
res = [],
|
||||
queue = [this].concat(this.bases);
|
||||
for (let mode in array.iterValues(queue))
|
||||
for (let mode of array.iterValues(queue))
|
||||
if (!seen.add(mode)) {
|
||||
res.push(mode);
|
||||
queue.push.apply(queue, mode.bases);
|
||||
@@ -537,15 +539,15 @@ var Modes = Module("modes", {
|
||||
|
||||
let tree = {};
|
||||
|
||||
for (let mode in values(list))
|
||||
for (let mode of values(list))
|
||||
tree[mode.name] = {};
|
||||
|
||||
for (let mode in values(list))
|
||||
for (let base in values(mode.bases))
|
||||
for (let mode of values(list))
|
||||
for (let base of values(mode.bases))
|
||||
tree[base.name][mode.name] = tree[mode.name];
|
||||
|
||||
let roots = iter([m.name, tree[m.name]]
|
||||
for (m in values(list))
|
||||
for (m of values(list))
|
||||
if (!m.bases.length)).toObject();
|
||||
|
||||
function rec(obj) {
|
||||
@@ -632,7 +634,7 @@ var Modes = Module("modes", {
|
||||
.every(k => hasOwnProperty(this.values, k)),
|
||||
|
||||
get values() array.toObject([[m.name.toLowerCase(), m.description]
|
||||
for (m in values(modes._modes)) if (!m.hidden)])
|
||||
for (m of values(modes._modes)) if (!m.hidden)])
|
||||
};
|
||||
|
||||
options.add(["passunknown", "pu"],
|
||||
|
||||
@@ -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-2014 Kris Maglione <maglione.k@gmail.com>
|
||||
// Copyright (c) 2008-2015 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.
|
||||
@@ -69,6 +69,7 @@ var MOW = Module("mow", {
|
||||
__noSuchMethod__: function (meth, args) Buffer[meth].apply(Buffer, [this.body].concat(args)),
|
||||
|
||||
get widget() this.widgets.multilineOutput,
|
||||
|
||||
widgets: Class.Memoize(function widgets() commandline.widgets),
|
||||
|
||||
body: Class.Memoize(function body() this.widget.contentDocument.documentElement),
|
||||
@@ -94,7 +95,7 @@ var MOW = Module("mow", {
|
||||
|
||||
leave: stack => {
|
||||
if (stack.pop)
|
||||
for (let message in values(this.messages))
|
||||
for (let message of values(this.messages))
|
||||
if (message.leave)
|
||||
message.leave(stack);
|
||||
},
|
||||
@@ -198,7 +199,7 @@ var MOW = Module("mow", {
|
||||
selection: !window.document.commandDispatcher.focusedWindow.getSelection().isCollapsed
|
||||
};
|
||||
|
||||
for (let node in array.iterValues(menu.children)) {
|
||||
for (let node of array.iterValues(menu.children)) {
|
||||
let group = node.getAttributeNS(NS, "group");
|
||||
node.hidden = group && !group.split(/\s+/).every(g => enabled[g]);
|
||||
}
|
||||
@@ -228,7 +229,7 @@ var MOW = Module("mow", {
|
||||
if (!(open || this.visible))
|
||||
return;
|
||||
|
||||
let doc = this.widget.contentDocument;
|
||||
let doc = this.document;
|
||||
|
||||
let trim = this.spaceNeeded;
|
||||
let availableHeight = config.outputHeight - trim;
|
||||
@@ -270,7 +271,7 @@ var MOW = Module("mow", {
|
||||
if (!this.visible || !isinstance(modes.main, modes.OUTPUT_MULTILINE))
|
||||
return this.widgets.message = null;
|
||||
|
||||
let elem = this.widget.contentDocument.documentElement;
|
||||
let elem = this.document.documentElement;
|
||||
|
||||
if (showHelp)
|
||||
this.widgets.message = ["MoreMsg", _("mow.moreHelp")];
|
||||
|
||||
@@ -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-2013 Kris Maglione <maglione.k@gmail.com>
|
||||
// Copyright (c) 2008-2015 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.
|
||||
@@ -39,7 +39,7 @@ var QuickMarks = Module("quickmarks", {
|
||||
*/
|
||||
find: function find(url) {
|
||||
let res = [];
|
||||
for (let [k, v] in this._qmarks)
|
||||
for (let [k, v] of this._qmarks)
|
||||
if (dactyl.parseURLs(v).some(u => String.replace(u, /#.*/, "") == url))
|
||||
res.push(k);
|
||||
return res;
|
||||
@@ -63,7 +63,7 @@ var QuickMarks = Module("quickmarks", {
|
||||
remove: function remove(filter) {
|
||||
let pattern = util.charListToRegexp(filter, "a-zA-Z0-9");
|
||||
|
||||
for (let [qmark, ] in this._qmarks) {
|
||||
for (let [qmark, ] of this._qmarks) {
|
||||
if (pattern.test(qmark))
|
||||
this._qmarks.remove(qmark);
|
||||
}
|
||||
@@ -98,7 +98,7 @@ var QuickMarks = Module("quickmarks", {
|
||||
* @param {string} filter The list of quickmarks to display, e.g. "a-c i O-X".
|
||||
*/
|
||||
list: function list(filter) {
|
||||
let marks = [k for ([k, v] in this._qmarks)];
|
||||
let marks = [k for ([k, v] of this._qmarks)];
|
||||
let lowercaseMarks = marks.filter(bind("test", /[a-z]/)).sort();
|
||||
let uppercaseMarks = marks.filter(bind("test", /[A-Z]/)).sort();
|
||||
let numberMarks = marks.filter(bind("test", /[0-9]/)).sort();
|
||||
@@ -110,11 +110,11 @@ var QuickMarks = Module("quickmarks", {
|
||||
if (filter.length > 0) {
|
||||
let pattern = util.charListToRegexp(filter, "a-zA-Z0-9");
|
||||
marks = marks.filter(qmark => pattern.test(qmark));
|
||||
dactyl.assert(marks.length >= 0, _("quickmark.noMatching", filter.quote()));
|
||||
dactyl.assert(marks.length >= 0, _("quickmark.noMatching", JSON.stringify(filter)));
|
||||
}
|
||||
|
||||
commandline.commandOutput(template.tabular(["QuickMark", "URL"], [],
|
||||
([mark, quickmarks._qmarks.get(mark)] for ([k, mark] in Iterator(marks)))));
|
||||
([mark, quickmarks._qmarks.get(mark)] for (mark of marks))));
|
||||
}
|
||||
}, {
|
||||
}, {
|
||||
|
||||
@@ -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-2014 Kris Maglione <maglione.k@gmail.com>
|
||||
// Copyright (c) 2008-2015 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.
|
||||
|
||||
@@ -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-2014 Kris Maglione <maglione.k at Gmail>
|
||||
// Copyright (c) 2008-2015 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.
|
||||
@@ -42,7 +42,7 @@ var Tabs = Module("tabs", {
|
||||
false, true);
|
||||
|
||||
this.timeout(function () {
|
||||
for (let { linkedBrowser: { contentDocument } } in values(this.allTabs))
|
||||
for (let { linkedBrowser: { contentDocument } } of this.allTabs)
|
||||
if (contentDocument.readyState === "complete")
|
||||
dactyl.initDocument(contentDocument);
|
||||
}, 1000);
|
||||
@@ -61,9 +61,9 @@ var Tabs = Module("tabs", {
|
||||
_alternates: Class.Memoize(() => [config.tabbrowser.mCurrentTab, null]),
|
||||
|
||||
cleanup: function cleanup() {
|
||||
for (let [i, tab] in Iterator(this.allTabs)) {
|
||||
for (let tab of this.allTabs) {
|
||||
let node = function node(class_) document.getAnonymousElementByAttribute(tab, "class", class_);
|
||||
for (let elem in values(["dactyl-tab-icon-number", "dactyl-tab-number"].map(node)))
|
||||
for (let elem of values(["dactyl-tab-icon-number", "dactyl-tab-number"].map(node)))
|
||||
if (elem)
|
||||
elem.parentNode.parentNode.removeChild(elem.parentNode);
|
||||
|
||||
@@ -73,7 +73,7 @@ var Tabs = Module("tabs", {
|
||||
},
|
||||
|
||||
updateTabCount: function updateTabCount() {
|
||||
for (let [i, tab] in Iterator(this.visibleTabs)) {
|
||||
for (let [i, tab] of iter(this.visibleTabs)) {
|
||||
let node = function node(class_) document.getAnonymousElementByAttribute(tab, "class", class_);
|
||||
if (!node("dactyl-tab-number")) {
|
||||
let img = node("tab-icon-image");
|
||||
@@ -101,7 +101,7 @@ var Tabs = Module("tabs", {
|
||||
statusline.updateTabCount(true);
|
||||
},
|
||||
|
||||
_onTabSelect: function _onTabSelect() {
|
||||
_onTabSelect: function* _onTabSelect() {
|
||||
// TODO: is all of that necessary?
|
||||
// I vote no. --Kris
|
||||
modes.reset();
|
||||
@@ -214,7 +214,7 @@ var Tabs = Module("tabs", {
|
||||
*/
|
||||
// FIXME: Only called once...necessary?
|
||||
getContentIndex: function getContentIndex(content) {
|
||||
for (let [i, browser] in this.browsers) {
|
||||
for (let browser of this.browsers) {
|
||||
if (browser.contentWindow == content || browser.contentDocument == content)
|
||||
return i;
|
||||
}
|
||||
@@ -353,7 +353,7 @@ var Tabs = Module("tabs", {
|
||||
* @param {boolean} all If true, match against all tabs. If
|
||||
* false, match only tabs in the current tab group.
|
||||
*/
|
||||
match: function match(filter, count, regexp, all) {
|
||||
match: function* match(filter, count, regexp, all) {
|
||||
if (!filter && count == null)
|
||||
yield tabs.getTab();
|
||||
else if (!filter)
|
||||
@@ -369,7 +369,7 @@ var Tabs = Module("tabs", {
|
||||
else
|
||||
var matcher = Styles.matchFilter(filter);
|
||||
|
||||
for (let tab in values(tabs[all ? "allTabs" : "visibleTabs"])) {
|
||||
for (let tab of values(tabs[all ? "allTabs" : "visibleTabs"])) {
|
||||
let browser = tab.linkedBrowser;
|
||||
let uri = browser.currentURI;
|
||||
let title;
|
||||
@@ -510,7 +510,7 @@ var Tabs = Module("tabs", {
|
||||
* Stops loading all tabs.
|
||||
*/
|
||||
stopAll: function stopAll() {
|
||||
for (let [, browser] in this.browsers)
|
||||
for (let browser of this.browsers)
|
||||
browser.stop();
|
||||
},
|
||||
|
||||
@@ -620,7 +620,7 @@ var Tabs = Module("tabs", {
|
||||
commands.add(params.name, params.description,
|
||||
function (args) {
|
||||
let removed = 0;
|
||||
for (let tab in tabs.match(args[0], args.count, args.bang, !params.visible)) {
|
||||
for (let tab of tabs.match(args[0], args.count, args.bang, !params.visible)) {
|
||||
config.removeTab(tab);
|
||||
removed++;
|
||||
}
|
||||
@@ -643,7 +643,7 @@ var Tabs = Module("tabs", {
|
||||
commands.add(["pin[tab]"],
|
||||
"Pin tab as an application tab",
|
||||
function (args) {
|
||||
for (let tab in tabs.match(args[0], args.count))
|
||||
for (let tab of tabs.match(args[0], args.count))
|
||||
config.browser[!args.bang || !tab.pinned ? "pinTab" : "unpinTab"](tab);
|
||||
},
|
||||
{
|
||||
@@ -660,7 +660,7 @@ var Tabs = Module("tabs", {
|
||||
commands.add(["unpin[tab]"],
|
||||
"Unpin tab as an application tab",
|
||||
function (args) {
|
||||
for (let tab in tabs.match(args[0], args.count))
|
||||
for (let tab of tabs.match(args[0], args.count))
|
||||
config.browser.unpinTab(tab);
|
||||
},
|
||||
{
|
||||
@@ -719,7 +719,7 @@ var Tabs = Module("tabs", {
|
||||
commands.add(["tabd[o]", "bufd[o]"],
|
||||
"Execute a command in each tab",
|
||||
function (args) {
|
||||
for (let tab in values(tabs.visibleTabs)) {
|
||||
for (let tab of values(tabs.visibleTabs)) {
|
||||
tabs.select(tab);
|
||||
dactyl.execute(args[0], null, true);
|
||||
}
|
||||
@@ -841,7 +841,7 @@ var Tabs = Module("tabs", {
|
||||
let arg = args[0];
|
||||
|
||||
if (tabs.indexFromSpec(arg) == -1) {
|
||||
let list = [tab for (tab in tabs.match(args[0], args.count, true))];
|
||||
let list = [tab for (tab of tabs.match(args[0], args.count, true))];
|
||||
dactyl.assert(list.length, _("error.invalidArgument", arg));
|
||||
dactyl.assert(list.length == 1, _("buffer.multipleMatching", arg));
|
||||
arg = list[0];
|
||||
@@ -886,7 +886,7 @@ var Tabs = Module("tabs", {
|
||||
if (options.get("activate").has("tabopen"))
|
||||
activate = !activate;
|
||||
|
||||
for (let i in util.range(0, Math.max(1, args.count)))
|
||||
for (let i of util.range(0, Math.max(1, args.count)))
|
||||
tabs.cloneTab(tab, activate);
|
||||
}, {
|
||||
argCount: "0",
|
||||
@@ -982,7 +982,7 @@ var Tabs = Module("tabs", {
|
||||
if (m)
|
||||
window.undoCloseTab(Number(m[1]) - 1);
|
||||
else if (args) {
|
||||
for (let [i, item] in Iterator(tabs.closedTabs))
|
||||
for (let [i, item] of iter(tabs.closedTabs))
|
||||
if (item.state.entries[item.state.index - 1].url == args) {
|
||||
window.undoCloseTab(i);
|
||||
return;
|
||||
@@ -1009,7 +1009,7 @@ var Tabs = Module("tabs", {
|
||||
commands.add(["undoa[ll]"],
|
||||
"Undo closing of all closed tabs",
|
||||
function (args) {
|
||||
for (let i in Iterator(tabs.closedTabs))
|
||||
for (let i of iter(tabs.closedTabs))
|
||||
window.undoCloseTab(0);
|
||||
|
||||
},
|
||||
@@ -1064,7 +1064,7 @@ var Tabs = Module("tabs", {
|
||||
context.compare = CompletionContext.Sort.number;
|
||||
context.filters[0] = CompletionContext.Filter.textDescription;
|
||||
|
||||
for (let [id, vals] in Iterator(tabGroups))
|
||||
for (let [id, vals] of iter(tabGroups))
|
||||
context.fork(id, 0, this, function (context, [name, browsers]) {
|
||||
context.title = [name || "Buffers"];
|
||||
context.generate = () =>
|
||||
@@ -1111,7 +1111,7 @@ var Tabs = Module("tabs", {
|
||||
function callback() {
|
||||
tabs.timeout(function () { this.updateTabCount(); });
|
||||
}
|
||||
for (let event in values(["TabMove", "TabOpen", "TabClose"]))
|
||||
for (let event of ["TabMove", "TabOpen", "TabClose"])
|
||||
events.listen(tabContainer, event, callback, false);
|
||||
events.listen(tabContainer, "TabSelect", tabs.bound._onTabSelect, false);
|
||||
},
|
||||
@@ -1257,13 +1257,13 @@ var Tabs = Module("tabs", {
|
||||
];
|
||||
options.add(["activate", "act"],
|
||||
"Define when newly created tabs are automatically activated",
|
||||
"stringlist", [g[0] for (g in values(activateGroups.slice(1))) if (!g[2] || !prefs.get("browser.tabs." + g[2]))].join(","),
|
||||
"stringlist", [g[0] for (g of values(activateGroups.slice(1))) if (!g[2] || !prefs.get("browser.tabs." + g[2]))].join(","),
|
||||
{
|
||||
values: activateGroups,
|
||||
has: Option.has.toggleAll,
|
||||
setter: function (newValues) {
|
||||
let valueSet = RealSet(newValues);
|
||||
for (let group in values(activateGroups))
|
||||
let valueSet = new RealSet(newValues);
|
||||
for (let group of values(activateGroups))
|
||||
if (group[2])
|
||||
prefs.safeSet("browser.tabs." + group[2],
|
||||
!(valueSet.has("all") ^ valueSet.has(group[0])),
|
||||
@@ -1292,7 +1292,7 @@ var Tabs = Module("tabs", {
|
||||
{
|
||||
setter: function (values) {
|
||||
let open = 1, restriction = 0;
|
||||
for (let [, opt] in Iterator(values)) {
|
||||
for (let opt of values) {
|
||||
if (opt == "tab")
|
||||
open = 3;
|
||||
else if (opt == "window")
|
||||
|
||||
Reference in New Issue
Block a user