1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-19 18:37:58 +01:00

Add missing function name. Fix cleanup on window close. Fix minor mode change bug and add guards.

This commit is contained in:
Kris Maglione
2011-02-19 02:13:05 -05:00
parent 18f9b6908d
commit 77157eaff8
8 changed files with 193 additions and 168 deletions

View File

@@ -15,7 +15,7 @@
* @instance buffer * @instance buffer
*/ */
var Buffer = Module("buffer", { var Buffer = Module("buffer", {
init: function () { init: function init() {
this.evaluateXPath = util.evaluateXPath; this.evaluateXPath = util.evaluateXPath;
this.pageInfo = {}; this.pageInfo = {};
@@ -165,7 +165,7 @@ var Buffer = Module("buffer", {
); );
}, },
climbUrlPath: function (count) { climbUrlPath: function climbUrlPath(count) {
let url = buffer.documentURI.clone(); let url = buffer.documentURI.clone();
dactyl.assert(url instanceof Ci.nsIURL); dactyl.assert(url instanceof Ci.nsIURL);
@@ -176,7 +176,7 @@ var Buffer = Module("buffer", {
dactyl.open(url.spec); dactyl.open(url.spec);
}, },
incrementURL: function (count) { incrementURL: function incrementURL(count) {
let matches = buffer.uri.spec.match(/(.*?)(\d+)(\D*)$/); let matches = buffer.uri.spec.match(/(.*?)(\d+)(\D*)$/);
dactyl.assert(matches); dactyl.assert(matches);
let oldNum = matches[2]; let oldNum = matches[2];
@@ -302,7 +302,7 @@ var Buffer = Module("buffer", {
/** /**
* Returns a list of all frames in the given window or current buffer. * Returns a list of all frames in the given window or current buffer.
*/ */
allFrames: function (win, focusedFirst) { allFrames: function allFrames(win, focusedFirst) {
let frames = []; let frames = [];
(function rec(frame) { (function rec(frame) {
if (frame.document.body instanceof HTMLBodyElement) if (frame.document.body instanceof HTMLBodyElement)
@@ -343,7 +343,7 @@ var Buffer = Module("buffer", {
* @param {Node|Window} * @param {Node|Window}
* @returns {boolean} * @returns {boolean}
*/ */
focusAllowed: function (elem) { focusAllowed: function focusAllowed(elem) {
if (elem instanceof Window && !Editor.getEditor(elem)) if (elem instanceof Window && !Editor.getEditor(elem))
return true; return true;
let doc = elem.ownerDocument || elem.document || elem; let doc = elem.ownerDocument || elem.document || elem;
@@ -357,7 +357,7 @@ var Buffer = Module("buffer", {
* *
* @param {Node} elem The element to focus. * @param {Node} elem The element to focus.
*/ */
focusElement: function (elem) { focusElement: function focusElement(elem) {
let win = elem.ownerDocument && elem.ownerDocument.defaultView || elem; let win = elem.ownerDocument && elem.ownerDocument.defaultView || elem;
win.document.dactylFocusAllowed = true; win.document.dactylFocusAllowed = true;
@@ -427,7 +427,7 @@ var Buffer = Module("buffer", {
function followDocumentRelationship(rel) { function followDocumentRelationship(rel) {
this.findLink(rel, options[rel + "pattern"], 0, true); this.findLink(rel, options[rel + "pattern"], 0, true);
}), }),
findLink: function (rel, regexps, count, follow, path) { findLink: function findLink(rel, regexps, count, follow, path) {
let selector = path || options.get("hinttags").stringDefaultValue; let selector = path || options.get("hinttags").stringDefaultValue;
function followFrame(frame) { function followFrame(frame) {
@@ -475,7 +475,7 @@ var Buffer = Module("buffer", {
* @param {number} where Where to open the link. See * @param {number} where Where to open the link. See
* {@link dactyl.open}. * {@link dactyl.open}.
*/ */
followLink: function (elem, where) { followLink: function followLink(elem, where) {
let doc = elem.ownerDocument; let doc = elem.ownerDocument;
let view = doc.defaultView; let view = doc.defaultView;
let { left: offsetX, top: offsetY } = elem.getBoundingClientRect(); let { left: offsetX, top: offsetY } = elem.getBoundingClientRect();
@@ -538,7 +538,7 @@ var Buffer = Module("buffer", {
* *
* @param {Node} elem The context element. * @param {Node} elem The context element.
*/ */
openContextMenu: function (elem) { openContextMenu: function openContextMenu(elem) {
document.popupNode = elem; document.popupNode = elem;
let menu = document.getElementById("contentAreaContextMenu"); let menu = document.getElementById("contentAreaContextMenu");
menu.showPopup(elem, -1, -1, "context", "bottomleft", "topleft"); menu.showPopup(elem, -1, -1, "context", "bottomleft", "topleft");
@@ -549,7 +549,7 @@ var Buffer = Module("buffer", {
* *
* @param {HTMLAnchorElement} elem The page link to save. * @param {HTMLAnchorElement} elem The page link to save.
*/ */
saveLink: function (elem) { saveLink: function saveLink(elem) {
let doc = elem.ownerDocument; let doc = elem.ownerDocument;
let uri = util.newURI(elem.href || elem.src, null, util.newURI(elem.baseURI)); let uri = util.newURI(elem.href || elem.src, null, util.newURI(elem.baseURI));
let referrer = util.newURI(doc.documentURI, doc.characterSet); let referrer = util.newURI(doc.documentURI, doc.characterSet);
@@ -588,7 +588,7 @@ var Buffer = Module("buffer", {
* @param {nsIURI} uri The URI to save * @param {nsIURI} uri The URI to save
* @param {nsIFile} file The file into which to write the result. * @param {nsIFile} file The file into which to write the result.
*/ */
saveURI: function (uri, file, callback, self) { saveURI: function saveURI(uri, file, callback, self) {
var persist = services.Persist(); var persist = services.Persist();
persist.persistFlags = persist.PERSIST_FLAGS_FROM_CACHE persist.persistFlags = persist.PERSIST_FLAGS_FROM_CACHE
| persist.PERSIST_FLAGS_REPLACE_EXISTING_FILES; | persist.PERSIST_FLAGS_REPLACE_EXISTING_FILES;
@@ -645,7 +645,7 @@ var Buffer = Module("buffer", {
* @param {number} count The multiple of 'scroll' lines to scroll. * @param {number} count The multiple of 'scroll' lines to scroll.
* @optional * @optional
*/ */
scrollByScrollSize: function (direction, count) { scrollByScrollSize: function scrollByScrollSize(direction, count) {
direction = direction ? 1 : -1; direction = direction ? 1 : -1;
count = count || 1; count = count || 1;
@@ -732,7 +732,7 @@ var Buffer = Module("buffer", {
* @param {number} count The number of frames to skip through. A negative * @param {number} count The number of frames to skip through. A negative
* count skips backwards. * count skips backwards.
*/ */
shiftFrameFocus: function (count) { shiftFrameFocus: function shiftFrameFocus(count) {
if (!(content.document instanceof HTMLDocument)) if (!(content.document instanceof HTMLDocument))
return; return;
@@ -780,7 +780,7 @@ var Buffer = Module("buffer", {
* *
* @param {Node} elem The element to query. * @param {Node} elem The element to query.
*/ */
showElementInfo: function (elem) { showElementInfo: function showElementInfo(elem) {
dactyl.echo(<>Element:<br/>{util.objectToString(elem, true)}</>, commandline.FORCE_MULTILINE); dactyl.echo(<>Element:<br/>{util.objectToString(elem, true)}</>, commandline.FORCE_MULTILINE);
}, },
@@ -791,7 +791,7 @@ var Buffer = Module("buffer", {
* @param {string} sections A string limiting the displayed sections. * @param {string} sections A string limiting the displayed sections.
* @default The value of 'pageinfo'. * @default The value of 'pageinfo'.
*/ */
showPageInfo: function (verbose, sections) { showPageInfo: function showPageInfo(verbose, sections) {
// Ctrl-g single line output // Ctrl-g single line output
if (!verbose) { if (!verbose) {
let file = content.location.pathname.split("/").pop() || "[No Name]"; let file = content.location.pathname.split("/").pop() || "[No Name]";
@@ -830,7 +830,7 @@ var Buffer = Module("buffer", {
* Opens a viewer to inspect the source of the currently selected * Opens a viewer to inspect the source of the currently selected
* range. * range.
*/ */
viewSelectionSource: function () { viewSelectionSource: function viewSelectionSource() {
// copied (and tuned somewhat) from browser.jar -> nsContextMenu.js // copied (and tuned somewhat) from browser.jar -> nsContextMenu.js
let win = document.commandDispatcher.focusedWindow; let win = document.commandDispatcher.focusedWindow;
if (win == window) if (win == window)
@@ -852,7 +852,7 @@ var Buffer = Module("buffer", {
* @default The current buffer. * @default The current buffer.
* @param {boolean} useExternalEditor View the source in the external editor. * @param {boolean} useExternalEditor View the source in the external editor.
*/ */
viewSource: function (url, useExternalEditor) { viewSource: function viewSource(url, useExternalEditor) {
let doc = this.focusedFrame.document; let doc = this.focusedFrame.document;
if (isArray(url)) { if (isArray(url)) {
@@ -893,7 +893,7 @@ var Buffer = Module("buffer", {
*/ */
viewSourceExternally: Class("viewSourceExternally", viewSourceExternally: Class("viewSourceExternally",
XPCOM([Ci.nsIWebProgressListener, Ci.nsISupportsWeakReference]), { XPCOM([Ci.nsIWebProgressListener, Ci.nsISupportsWeakReference]), {
init: function (doc, callback) { init: function init(doc, callback) {
this.callback = callable(callback) ? callback : this.callback = callable(callback) ? callback :
function (file, temp) { function (file, temp) {
editor.editFileExternally({ file: file.path, line: callback }, editor.editFileExternally({ file: file.path, line: callback },
@@ -924,7 +924,7 @@ var Buffer = Module("buffer", {
return null; return null;
}, },
onStateChange: function (progress, request, flag, status) { onStateChange: function onStateChange(progress, request, flag, status) {
if ((flag & this.STATE_STOP) && status == 0) { if ((flag & this.STATE_STOP) && status == 0) {
try { try {
var ok = this.callback(this.file, true); var ok = this.callback(this.file, true);
@@ -944,7 +944,7 @@ var Buffer = Module("buffer", {
* @param {number} steps The number of zoom levels to jump. * @param {number} steps The number of zoom levels to jump.
* @param {boolean} fullZoom Whether to use full zoom or text zoom. * @param {boolean} fullZoom Whether to use full zoom or text zoom.
*/ */
zoomIn: function (steps, fullZoom) { zoomIn: function zoomIn(steps, fullZoom) {
this.bumpZoomLevel(steps, fullZoom); this.bumpZoomLevel(steps, fullZoom);
}, },
@@ -954,7 +954,7 @@ var Buffer = Module("buffer", {
* @param {number} steps The number of zoom levels to jump. * @param {number} steps The number of zoom levels to jump.
* @param {boolean} fullZoom Whether to use full zoom or text zoom. * @param {boolean} fullZoom Whether to use full zoom or text zoom.
*/ */
zoomOut: function (steps, fullZoom) { zoomOut: function zoomOut(steps, fullZoom) {
this.bumpZoomLevel(-steps, fullZoom); this.bumpZoomLevel(-steps, fullZoom);
}, },
@@ -1037,7 +1037,7 @@ var Buffer = Module("buffer", {
* *
* @returns {string} * @returns {string}
*/ */
currentWord: function (win) { currentWord: function currentWord(win) {
let selection = win.getSelection(); let selection = win.getSelection();
if (selection.rangeCount == 0) if (selection.rangeCount == 0)
return ""; return "";
@@ -1206,7 +1206,7 @@ var Buffer = Module("buffer", {
openUploadPrompt: function openUploadPrompt(elem) { openUploadPrompt: function openUploadPrompt(elem) {
io.CommandFileMode("Upload file: ", { io.CommandFileMode("Upload file: ", {
onSubmit: function (path) { onSubmit: function onSubmit(path) {
let file = io.File(path); let file = io.File(path);
dactyl.assert(file.exists()); dactyl.assert(file.exists());
@@ -1216,7 +1216,7 @@ var Buffer = Module("buffer", {
}).open(elem.value); }).open(elem.value);
} }
}, { }, {
commands: function () { commands: function initCommands(dactyl, modules, window) {
commands.add(["frameo[nly]"], commands.add(["frameo[nly]"],
"Show only the current frame's page", "Show only the current frame's page",
function (args) { function (args) {
@@ -1417,7 +1417,7 @@ var Buffer = Module("buffer", {
bang: true bang: true
}); });
}, },
completion: function () { completion: function initCompletion(dactyl, modules, window) {
completion.alternateStyleSheet = function alternateStylesheet(context) { completion.alternateStyleSheet = function alternateStylesheet(context) {
context.title = ["Stylesheet", "Location"]; context.title = ["Stylesheet", "Location"];
@@ -1496,10 +1496,10 @@ var Buffer = Module("buffer", {
}); });
}; };
}, },
events: function () { events: function initEvents(dactyl, modules, window) {
events.listen(config.browser, "scroll", buffer.closure._updateBufferPosition, false); events.listen(config.browser, "scroll", buffer.closure._updateBufferPosition, false);
}, },
mappings: function () { mappings: function initMappings(dactyl, modules, window) {
mappings.add([modes.NORMAL], mappings.add([modes.NORMAL],
["y", "<yank-location>"], "Yank current location to the clipboard", ["y", "<yank-location>"], "Yank current location to the clipboard",
function () { dactyl.clipboardWrite(buffer.uri.spec, true); }); function () { dactyl.clipboardWrite(buffer.uri.spec, true); });
@@ -1774,7 +1774,7 @@ var Buffer = Module("buffer", {
"Print file information", "Print file information",
function () { buffer.showPageInfo(true); }); function () { buffer.showPageInfo(true); });
}, },
options: function () { options: function initOptions(dactyl, modules, window) {
options.add(["encoding", "enc"], options.add(["encoding", "enc"],
"The current buffer's character encoding", "The current buffer's character encoding",
"string", "UTF-8", "string", "UTF-8",

View File

@@ -88,9 +88,9 @@ var CommandWidgets = Class("CommandWidgets", {
this.addElement({ this.addElement({
name: "command", name: "command",
test: function (stack, prev) stack.pop && !isinstance(prev.main, modes.COMMAND_LINE), test: function test(stack, prev) stack.pop && !isinstance(prev.main, modes.COMMAND_LINE),
id: "commandline-command", id: "commandline-command",
get: function (elem) { get: function command_get(elem) {
// The long path is because of complications with the // The long path is because of complications with the
// completion preview. // completion preview.
try { try {
@@ -102,7 +102,7 @@ var CommandWidgets = Class("CommandWidgets", {
}, },
getElement: CommandWidgets.getEditor, getElement: CommandWidgets.getEditor,
getGroup: function (value) this.activeGroup.commandline, getGroup: function (value) this.activeGroup.commandline,
onChange: function (elem, value) { onChange: function command_onChange(elem, value) {
if (elem.inputField != dactyl.focusedElement) if (elem.inputField != dactyl.focusedElement)
try { try {
elem.selectionStart = elem.value.length; elem.selectionStart = elem.value.length;
@@ -113,7 +113,7 @@ var CommandWidgets = Class("CommandWidgets", {
if (!elem.collapsed) if (!elem.collapsed)
dactyl.focus(elem); dactyl.focus(elem);
}, },
onVisibility: function (elem, visible) { onVisibility: function command_onVisibility(elem, visible) {
if (visible) if (visible)
dactyl.focus(elem); dactyl.focus(elem);
} }
@@ -431,8 +431,8 @@ var CommandExMode = Class("CommandExMode", CommandMode, {
onSubmit: function onSubmit(command) { onSubmit: function onSubmit(command) {
contexts.withContext({ file: "[Command Line]", line: 1 }, contexts.withContext({ file: "[Command Line]", line: 1 },
function () { function _onSubmit() {
io.withSavedValues(["readHeredoc"], function () { io.withSavedValues(["readHeredoc"], function _onSubmit() {
this.readHeredoc = commandline.readHeredoc; this.readHeredoc = commandline.readHeredoc;
commands.repeat = command; commands.repeat = command;
dactyl.execute(command); dactyl.execute(command);

View File

@@ -66,6 +66,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
for (let mod in values(mods)) for (let mod in values(mods))
if (mod instanceof ModuleBase || mod && mod.isLocalModule) { if (mod instanceof ModuleBase || mod && mod.isLocalModule) {
mod.stale = true;
if ("cleanup" in mod) if ("cleanup" in mod)
this.trapErrors(mod.cleanup, mod); this.trapErrors(mod.cleanup, mod);
if ("destroy" in mod) if ("destroy" in mod)

View File

@@ -9,7 +9,7 @@
/** @scope modules */ /** @scope modules */
var Modes = Module("modes", { var Modes = Module("modes", {
init: function () { init: function init() {
this.modeChars = {}; this.modeChars = {};
this._main = 1; // NORMAL this._main = 1; // NORMAL
this._extended = 0; // NONE this._extended = 0; // NONE
@@ -197,11 +197,11 @@ var Modes = Module("modes", {
} }
}); });
}, },
cleanup: function () { cleanup: function cleanup() {
modes.reset(); modes.reset();
}, },
_getModeMessage: function () { _getModeMessage: function _getModeMessage() {
// when recording a macro // when recording a macro
let macromode = ""; let macromode = "";
if (this.recording) if (this.recording)
@@ -217,7 +217,7 @@ var Modes = Module("modes", {
NONE: 0, NONE: 0,
__iterator__: function () array.iterValues(this.all), __iterator__: function __iterator__() array.iterValues(this.all),
get all() this._modes.slice(), get all() this._modes.slice(),
@@ -229,7 +229,7 @@ var Modes = Module("modes", {
get topOfStack() this._modeStack[this._modeStack.length - 1], get topOfStack() this._modeStack[this._modeStack.length - 1],
addMode: function (name, options, params) { addMode: function addMode(name, options, params) {
let mode = Modes.Mode(name, options, params); let mode = Modes.Mode(name, options, params);
this[name] = mode; this[name] = mode;
@@ -245,23 +245,23 @@ var Modes = Module("modes", {
dactyl.triggerObserver("mode-add", mode); dactyl.triggerObserver("mode-add", mode);
}, },
dumpStack: function () { dumpStack: function dumpStack() {
util.dump("Mode stack:"); util.dump("Mode stack:");
for (let [i, mode] in array.iterItems(this._modeStack)) for (let [i, mode] in array.iterItems(this._modeStack))
util.dump(" " + i + ": " + mode); util.dump(" " + i + ": " + mode);
}, },
getMode: function (name) this._modeMap[name], getMode: function getMode(name) this._modeMap[name],
getStack: function (idx) this._modeStack[this._modeStack.length - idx - 1] || this._modeStack[0], getStack: function getStack(idx) this._modeStack[this._modeStack.length - idx - 1] || this._modeStack[0],
get stack() this._modeStack.slice(), get stack() this._modeStack.slice(),
getCharModes: function (chr) (this.modeChars[chr] || []).slice(), getCharModes: function getCharModes(chr) (this.modeChars[chr] || []).slice(),
have: function have(mode) this._modeStack.some(function (m) isinstance(m.main, mode)), have: function have(mode) this._modeStack.some(function (m) isinstance(m.main, mode)),
matchModes: function (obj) matchModes: function matchModes(obj)
this._modes.filter(function (mode) Object.keys(obj) this._modes.filter(function (mode) Object.keys(obj)
.every(function (k) obj[k] == (mode[k] || false))), .every(function (k) obj[k] == (mode[k] || false))),
@@ -287,7 +287,7 @@ var Modes = Module("modes", {
}, },
delayed: [], delayed: [],
delay: function (callback, self) { this.delayed.push([callback, self]); }, delay: function delay(callback, self) { this.delayed.push([callback, self]); },
save: function save(id, obj, prop, test) { save: function save(id, obj, prop, test) {
if (!(id in this.boundProperties)) if (!(id in this.boundProperties))
@@ -296,14 +296,26 @@ var Modes = Module("modes", {
this.boundProperties[id] = { obj: Cu.getWeakReference(obj), prop: prop, test: test }; this.boundProperties[id] = { obj: Cu.getWeakReference(obj), prop: prop, test: test };
}, },
inSet: false,
// helper function to set both modes in one go // helper function to set both modes in one go
set: function set(mainMode, extendedMode, params, stack) { set: function set(mainMode, extendedMode, params, stack) {
var delayed, oldExtended, oldMain, prev, push;
if (this.inSet) {
dactyl.reportError(Error("Not executing modes.set recursively"), true);
return;
}
this.withSavedValues(["inSet"], function set() {
this.inSet = true;
params = params || this.getMode(mainMode || this.main).params; params = params || this.getMode(mainMode || this.main).params;
if (!stack && mainMode != null && this._modeStack.length > 1) if (!stack && mainMode != null && this._modeStack.length > 1)
this.reset(); this.reset();
let oldMain = this._main, oldExtended = this._extended; oldMain = this._main, oldExtended = this._extended;
if (extendedMode != null) if (extendedMode != null)
this._extended = extendedMode; this._extended = extendedMode;
@@ -317,7 +329,7 @@ var Modes = Module("modes", {
dactyl.trapErrors("leave", stack.pop.params, dactyl.trapErrors("leave", stack.pop.params,
stack, this.topOfStack); stack, this.topOfStack);
let push = mainMode != null && !(stack && stack.pop) && push = mainMode != null && !(stack && stack.pop) &&
Modes.StackElement(this._main, this._extended, params, {}); Modes.StackElement(this._main, this._extended, params, {});
if (push && this.topOfStack) { if (push && this.topOfStack) {
@@ -333,19 +345,20 @@ var Modes = Module("modes", {
} }
} }
let delayed = this.delayed; delayed = this.delayed;
this.delayed = []; this.delayed = [];
let prev = stack && stack.pop || this.topOfStack; prev = stack && stack.pop || this.topOfStack;
if (push) if (push)
this._modeStack.push(push); this._modeStack.push(push);
if (stack && stack.pop) if (stack && stack.pop)
for (let { obj, prop, value, test } in values(this.topOfStack.saved)) for (let { obj, prop, value, test } in values(this.topOfStack.saved))
if (!test || !test(stack, prev)) if (!test || !test(stack, prev))
obj[prop] = value; dactyl.trapErrors(function () { obj[prop] = value });
this.show(); this.show();
});
delayed.forEach(function ([fn, self]) dactyl.trapErrors(fn, self)); delayed.forEach(function ([fn, self]) dactyl.trapErrors(fn, self));
@@ -417,7 +430,7 @@ var Modes = Module("modes", {
}, options); }, options);
}, },
isinstance: function (obj) isinstance: function isinstance(obj)
this === obj || this.allBases.indexOf(obj) >= 0 || callable(obj) && this instanceof obj, this === obj || this.allBases.indexOf(obj) >= 0 || callable(obj) && this instanceof obj,
allBases: Class.memoize(function () { allBases: Class.memoize(function () {
@@ -436,17 +449,17 @@ var Modes = Module("modes", {
get description() this._display, get description() this._display,
_display: Class.memoize(function () this.name.replace("_", " ", "g")), _display: Class.memoize(function _display() this.name.replace("_", " ", "g")),
display: function () this._display, display: function display() this._display,
extended: false, extended: false,
hidden: false, hidden: false,
input: Class.memoize(function () this.bases.length && this.bases.some(function (b) b.input)), input: Class.memoize(function input() this.bases.length && this.bases.some(function (b) b.input)),
ownsFocus: Class.memoize(function () this.bases.length && this.bases.some(function (b) b.ownsFocus)), ownsFocus: Class.memoize(function ownsFocus() this.bases.length && this.bases.some(function (b) b.ownsFocus)),
get passUnknown() this.input, get passUnknown() this.input,
@@ -454,7 +467,7 @@ var Modes = Module("modes", {
get toStringParams() [this.name], get toStringParams() [this.name],
valueOf: function () this.id valueOf: function valueOf() this.id
}, { }, {
_id: 0 _id: 0
}), }),
@@ -472,19 +485,21 @@ var Modes = Module("modes", {
return StackElement; return StackElement;
})(), })(),
cacheId: 0, cacheId: 0,
boundProperty: function boundProperty(desc) { boundProperty: function BoundProperty(desc) {
let id = this.cacheId++;
let value;
desc = desc || {}; desc = desc || {};
let id = this.cacheId++, value;
return Class.Property(update({ return Class.Property(update({
enumerable: true,
configurable: true, configurable: true,
init: function (prop) update(this, { enumerable: true,
get: function () { init: function bound_init(prop) update(this, {
get: function bound_get() {
if (desc.get) if (desc.get)
var val = desc.get.call(this, value); var val = desc.get.call(this, value);
return val === undefined ? value : val; return val === undefined ? value : val;
}, },
set: function (val) { set: function bound_set(val) {
modes.save(id, this, prop, desc.test); modes.save(id, this, prop, desc.test);
if (desc.set) if (desc.set)
value = desc.set.call(this, val); value = desc.set.call(this, val);

View File

@@ -7,9 +7,9 @@
"use strict"; "use strict";
var MOW = Module("mow", { var MOW = Module("mow", {
init: function () { init: function init() {
this._resize = Timer(20, 400, function () { this._resize = Timer(20, 400, function _resize() {
if (this.visible) if (this.visible)
this.resize(false); this.resize(false);
@@ -17,7 +17,7 @@ var MOW = Module("mow", {
this.updateMorePrompt(); this.updateMorePrompt();
}, this); }, this);
this._timer = Timer(20, 400, function () { this._timer = Timer(20, 400, function _timer() {
if (modes.have(modes.OUTPUT_MULTILINE)) { if (modes.have(modes.OUTPUT_MULTILINE)) {
this.resize(true); this.resize(true);
@@ -80,9 +80,9 @@ var MOW = Module("mow", {
__noSuchMethod__: function (meth, args) Buffer[meth].apply(Buffer, [this.body].concat(args)), __noSuchMethod__: function (meth, args) Buffer[meth].apply(Buffer, [this.body].concat(args)),
get widget() this.widgets.multilineOutput, get widget() this.widgets.multilineOutput,
widgets: Class.memoize(function () commandline.widgets), widgets: Class.memoize(function widgets() commandline.widgets),
body: Class.memoize(function () this.widget.contentDocument.documentElement), body: Class.memoize(function body() this.widget.contentDocument.documentElement),
get document() this.widget.contentDocument, get document() this.widget.contentDocument,
get window() this.widget.contentWindow, get window() this.widget.contentWindow,
@@ -195,7 +195,7 @@ var MOW = Module("mow", {
}, },
contextEvents: { contextEvents: {
popupshowing: function (event) { popupshowing: function onPopupShowing(event) {
let menu = commandline.widgets.contextMenu; let menu = commandline.widgets.contextMenu;
let enabled = { let enabled = {
link: window.document.popupNode instanceof HTMLAnchorElement, link: window.document.popupNode instanceof HTMLAnchorElement,
@@ -229,7 +229,7 @@ var MOW = Module("mow", {
* @param {boolean} open If true, the widget will be opened if it's not * @param {boolean} open If true, the widget will be opened if it's not
* already so. * already so.
*/ */
resize: function updateOutputHeight(open, extra) { resize: function resize(open, extra) {
if (!(open || this.visible)) if (!(open || this.visible))
return; return;
@@ -266,7 +266,6 @@ var MOW = Module("mow", {
* and what they do. * and what they do.
*/ */
updateMorePrompt: function updateMorePrompt(force, showHelp) { updateMorePrompt: function updateMorePrompt(force, showHelp) {
util.dump("\n"); modes.dumpStack(); util.dumpStack(); util.dump("\n");
if (!this.visible || !isinstance(modes.main, modes.OUTPUT_MULTILINE)) if (!this.visible || !isinstance(modes.main, modes.OUTPUT_MULTILINE))
return this.widgets.message = null; return this.widgets.message = null;
@@ -286,13 +285,19 @@ var MOW = Module("mow", {
this.widgets.mowContainer.collapsed = !value; this.widgets.mowContainer.collapsed = !value;
let elem = this.widget; let elem = this.widget;
if (!value && elem && elem.contentWindow == document.commandDispatcher.focusedWindow) if (!value && elem && elem.contentWindow == document.commandDispatcher.focusedWindow) {
let focused = content.document.activeElement;
if (Events.isInputElement(focused))
focused.blur();
document.commandDispatcher.focusedWindow = content; document.commandDispatcher.focusedWindow = content;
} }
}
}) })
}, { }, {
}, { }, {
mappings: function () { mappings: function initMappings() {
const PASS = true; const PASS = true;
const DROP = false; const DROP = false;
const BEEP = {}; const BEEP = {};
@@ -376,7 +381,7 @@ var MOW = Module("mow", {
function () {}, function () {},
function () false, DROP); function () false, DROP);
}, },
options: function () { options: function initOptions() {
options.add(["more"], options.add(["more"],
"Pause the message list window when the full output will not fit on one page", "Pause the message list window when the full output will not fit on one page",
"boolean", true); "boolean", true);

View File

@@ -828,9 +828,9 @@ Class.prototype = {
* Initializes new instances of this class. Called automatically * Initializes new instances of this class. Called automatically
* when new instances are created. * when new instances are created.
*/ */
init: function () {}, init: function c_init() {},
withSavedValues: function (names, callback, self) { withSavedValues: function withSavedValues(names, callback, self) {
let vals = names.map(function (name) this[name], this); let vals = names.map(function (name) this[name], this);
try { try {
return callback.call(self || this); return callback.call(self || this);
@@ -840,7 +840,7 @@ Class.prototype = {
} }
}, },
toString: function () { toString: function C_toString() {
if (this.toStringParams) if (this.toStringParams)
var params = "(" + this.toStringParams.map(function (m) isArray(m) ? "[" + m + "]" : var params = "(" + this.toStringParams.map(function (m) isArray(m) ? "[" + m + "]" :
isString(m) ? m.quote() : String(m)) isString(m) ? m.quote() : String(m))
@@ -857,19 +857,20 @@ Class.prototype = {
* before calling *callback*. * before calling *callback*.
* @returns {nsITimer} The timer which backs this timeout. * @returns {nsITimer} The timer which backs this timeout.
*/ */
timeout: function (callback, timeout) { timeout: function timeout(callback, timeout) {
const self = this; const self = this;
function notify(timer) { function timeout_notify(timer) {
if (util.rehashing && !isinstance(Cu.getGlobalForObject(callback), ["BackstagePass"])) if (self.stale ||
util.rehashing && !isinstance(Cu.getGlobalForObject(callback), ["BackstagePass"]))
return; return;
util.trapErrors(callback, self); util.trapErrors(callback, self);
} }
return services.Timer(notify, timeout || 0, services.Timer.TYPE_ONE_SHOT); return services.Timer(timeout_notify, timeout || 0, services.Timer.TYPE_ONE_SHOT);
} }
}; };
memoize(Class.prototype, "closure", function () { memoize(Class.prototype, "closure", function closure() {
const self = this; const self = this;
function closure(fn) function () { function closure(fn) function _closure() {
try { try {
return fn.apply(self, arguments); return fn.apply(self, arguments);
} }
@@ -919,7 +920,7 @@ function XPCOM(interfaces, superClass) {
*/ */
var ErrorBase = Class("ErrorBase", Error, { var ErrorBase = Class("ErrorBase", Error, {
level: 2, level: 2,
init: function (message, level) { init: function EB_init(message, level) {
level = level || 0; level = level || 0;
update(this, Error(message)) update(this, Error(message))
this.message = message; this.message = message;
@@ -957,7 +958,7 @@ function Module(name, prototype) {
return module; return module;
} }
Module.INIT = { Module.INIT = {
init: function (dactyl, modules, window) { init: function Module_INIT_init(dactyl, modules, window) {
let args = arguments; let args = arguments;
let locals = []; let locals = [];
@@ -1008,28 +1009,28 @@ function Struct() {
return Struct; return Struct;
} }
let StructBase = Class("StructBase", Array, { let StructBase = Class("StructBase", Array, {
init: function () { init: function struct_init() {
for (let i = 0; i < arguments.length; i++) for (let i = 0; i < arguments.length; i++)
if (arguments[i] != undefined) if (arguments[i] != undefined)
this[i] = arguments[i]; this[i] = arguments[i];
}, },
clone: function clone() this.constructor.apply(null, this.slice()), clone: function struct_clone() this.constructor.apply(null, this.slice()),
closure: Class.Property(Object.getOwnPropertyDescriptor(Class.prototype, "closure")), closure: Class.Property(Object.getOwnPropertyDescriptor(Class.prototype, "closure")),
get: function (key, val) this[this.members[key]], get: function struct_get(key, val) this[this.members[key]],
set: function (key, val) this[this.members[key]] = val, set: function struct_set(key, val) this[this.members[key]] = val,
toString: function () Class.prototype.toString.apply(this, arguments), toString: function struct_toString() Class.prototype.toString.apply(this, arguments),
// Iterator over our named members // Iterator over our named members
__iterator__: function () { __iterator__: function struct__iterator__() {
let self = this; let self = this;
return ([k, self[k]] for (k in keys(self.members))) return ([k, self[k]] for (k in keys(self.members)))
} }
}, { }, {
fromArray: function (ary) { fromArray: function fromArray(ary) {
if (!(ary instanceof this)) if (!(ary instanceof this))
ary.__proto__ = this.prototype; ary.__proto__ = this.prototype;
return ary; return ary;
@@ -1045,7 +1046,7 @@ let StructBase = Class("StructBase", Array, {
* @param {function} val The function which is to generate * @param {function} val The function which is to generate
* the default value. * the default value.
*/ */
defaultValue: function (key, val) { defaultValue: function defaultValue(key, val) {
let i = this.prototype.members[key]; let i = this.prototype.members[key];
this.prototype.__defineGetter__(i, function () (this[i] = val.call(this))); this.prototype.__defineGetter__(i, function () (this[i] = val.call(this)));
this.prototype.__defineSetter__(i, function (value) this.prototype.__defineSetter__(i, function (value)
@@ -1054,7 +1055,7 @@ let StructBase = Class("StructBase", Array, {
}); });
var Timer = Class("Timer", { var Timer = Class("Timer", {
init: function (minInterval, maxInterval, callback, self) { init: function init(minInterval, maxInterval, callback, self) {
this._timer = services.Timer(); this._timer = services.Timer();
this.callback = callback; this.callback = callback;
this.self = self || this; this.self = self || this;
@@ -1064,7 +1065,7 @@ var Timer = Class("Timer", {
this.latest = 0; this.latest = 0;
}, },
notify: function (timer, force) { notify: function notify(timer, force) {
try { try {
if (!loaded || loaded.util && util.rehashing || typeof util === "undefined" || !force && this.doneAt == 0) if (!loaded || loaded.util && util.rehashing || typeof util === "undefined" || !force && this.doneAt == 0)
return; return;
@@ -1087,7 +1088,7 @@ var Timer = Class("Timer", {
} }
}, },
tell: function (arg) { tell: function tell(arg) {
if (arguments.length > 0) if (arguments.length > 0)
this.arg = arg; this.arg = arg;
@@ -1107,12 +1108,12 @@ var Timer = Class("Timer", {
this.doneAt = -1; this.doneAt = -1;
}, },
reset: function () { reset: function reset() {
this._timer.cancel(); this._timer.cancel();
this.doneAt = 0; this.doneAt = 0;
}, },
flush: function (force) { flush: function flush(force) {
if (this.doneAt == -1 || force) if (this.doneAt == -1 || force)
this.notify(null, true); this.notify(null, true);
} }

View File

@@ -66,7 +66,7 @@ update(CommandOption, {
* @property {object} The option accepts a boolean argument. * @property {object} The option accepts a boolean argument.
* @final * @final
*/ */
BOOL: ArgType("boolean", function (val) Commands.parseBool(val)), BOOL: ArgType("boolean", function parseBool(val) Commands.parseBool(val)),
/** /**
* @property {object} The option accepts a string argument. * @property {object} The option accepts a string argument.
* @final * @final
@@ -76,18 +76,18 @@ update(CommandOption, {
* @property {object} The option accepts an integer argument. * @property {object} The option accepts an integer argument.
* @final * @final
*/ */
INT: ArgType("int", function (val) parseInt(val)), INT: ArgType("int", function parseInt(val) parseInt(val)),
/** /**
* @property {object} The option accepts a float argument. * @property {object} The option accepts a float argument.
* @final * @final
*/ */
FLOAT: ArgType("float", function (val) parseFloat(val)), FLOAT: ArgType("float", function parseFloat(val) parseFloat(val)),
/** /**
* @property {object} The option accepts a string list argument. * @property {object} The option accepts a string list argument.
* E.g. "foo,bar" * E.g. "foo,bar"
* @final * @final
*/ */
LIST: ArgType("list", function (arg, quoted) Option.splitList(quoted)) LIST: ArgType("list", function parseList(arg, quoted) Option.splitList(quoted))
}); });
/** /**
@@ -116,7 +116,7 @@ update(CommandOption, {
* @private * @private
*/ */
var Command = Class("Command", { var Command = Class("Command", {
init: function (specs, description, action, extraInfo) { init: function init(specs, description, action, extraInfo) {
specs = Array.concat(specs); // XXX specs = Array.concat(specs); // XXX
let parsedSpecs = extraInfo.parsedSpecs || Command.parseSpecs(specs); let parsedSpecs = extraInfo.parsedSpecs || Command.parseSpecs(specs);
@@ -147,7 +147,7 @@ var Command = Class("Command", {
* @param {Args} args The Args object passed to {@link #action}. * @param {Args} args The Args object passed to {@link #action}.
* @param {Object} modifiers Any modifiers to be passed to {@link #action}. * @param {Object} modifiers Any modifiers to be passed to {@link #action}.
*/ */
execute: function (args, modifiers) { execute: function execute(args, modifiers) {
const { dactyl } = this.modules; const { dactyl } = this.modules;
let context = args.context; let context = args.context;
@@ -184,7 +184,7 @@ var Command = Class("Command", {
* @param {string} name The candidate name. * @param {string} name The candidate name.
* @returns {boolean} * @returns {boolean}
*/ */
hasName: function (name) this.parsedSpecs.some( hasName: function hasName(name) this.parsedSpecs.some(
function ([long, short]) name.indexOf(short) == 0 && long.indexOf(name) == 0), function ([long, short]) name.indexOf(short) == 0 && long.indexOf(name) == 0),
/** /**
@@ -276,22 +276,22 @@ var Command = Class("Command", {
.map(function (opt) opt.names.map(function (name) [name, opt])) .map(function (opt) opt.names.map(function (name) [name, opt]))
.flatten().toObject()), .flatten().toObject()),
newArgs: function (base) { newArgs: function newArgs(base) {
let res = []; let res = [];
update(res, base); update(res, base);
res.__proto__ = this.argsPrototype; res.__proto__ = this.argsPrototype;
return res; return res;
}, },
argsPrototype: Class.memoize(function () { argsPrototype: Class.memoize(function argsPrototype() {
let res = update([], { let res = update([], {
__iterator__: function () array.iterItems(this), __iterator__: function AP__iterator__() array.iterItems(this),
command: this, command: this,
explicitOpts: Class.memoize(function () ({})), explicitOpts: Class.memoize(function () ({})),
has: function (opt) set.has(this.explicitOpts, opt) || typeof opt === "number" && set.has(this, opt), has: function AP_has(opt) set.has(this.explicitOpts, opt) || typeof opt === "number" && set.has(this, opt),
get literalArg() this.command.literal != null && this[this.command.literal] || "", get literalArg() this.command.literal != null && this[this.command.literal] || "",
@@ -378,7 +378,7 @@ var Ex = Module("Ex", {
get context() modules.contexts.context get context() modules.contexts.context
}), }),
_args: function (cmd, args) { _args: function E_args(cmd, args) {
args = Array.slice(args); args = Array.slice(args);
let res = cmd.newArgs({ context: this.context }); let res = cmd.newArgs({ context: this.context });
@@ -401,7 +401,7 @@ var Ex = Module("Ex", {
return res; return res;
}, },
_complete: function (cmd) let (self = this) _complete: function E_complete(cmd) let (self = this)
function _complete(context, func, obj, args) { function _complete(context, func, obj, args) {
args = self._args(cmd, args); args = self._args(cmd, args);
args.completeArg = args.length - 1; args.completeArg = args.length - 1;
@@ -409,7 +409,7 @@ var Ex = Module("Ex", {
return cmd.completer(context, args); return cmd.completer(context, args);
}, },
_run: function (name) { _run: function E_run(name) {
const self = this; const self = this;
let cmd = this.commands.get(name); let cmd = this.commands.get(name);
util.assert(cmd, "No such command"); util.assert(cmd, "No such command");
@@ -423,7 +423,7 @@ var Ex = Module("Ex", {
}); });
}, },
__noSuchMethod__: function (meth, args) this._run(meth).apply(this, args) __noSuchMethod__: function __noSuchMethod__(meth, args) this._run(meth).apply(this, args)
}); });
var CommandHive = Class("CommandHive", Contexts.Hive, { var CommandHive = Class("CommandHive", Contexts.Hive, {
@@ -434,7 +434,7 @@ var CommandHive = Class("CommandHive", Contexts.Hive, {
}, },
/** @property {Iterator(Command)} @private */ /** @property {Iterator(Command)} @private */
__iterator__: function () array.iterValues(this._list.sort(function (a, b) a.name > b.name)), __iterator__: function __iterator__() array.iterValues(this._list.sort(function (a, b) a.name > b.name)),
/** @property {string} The last executed Ex command line. */ /** @property {string} The last executed Ex command line. */
repeat: null, repeat: null,
@@ -450,7 +450,7 @@ var CommandHive = Class("CommandHive", Contexts.Hive, {
* @param {Object} extra An optional extra configuration hash. * @param {Object} extra An optional extra configuration hash.
* @optional * @optional
*/ */
add: function (names, description, action, extra, replace) { add: function add(names, description, action, extra, replace) {
const { commands, contexts } = this.modules; const { commands, contexts } = this.modules;
extra = extra || {}; extra = extra || {};
@@ -486,7 +486,7 @@ var CommandHive = Class("CommandHive", Contexts.Hive, {
return name; return name;
}, },
_add: function (names, description, action, extra, replace) { _add: function _add(names, description, action, extra, replace) {
const { contexts } = this.modules; const { contexts } = this.modules;
extra = extra || {}; extra = extra || {};
@@ -540,7 +540,7 @@ var Commands = Module("commands", {
lazyInit: true, lazyInit: true,
Local: function Local(dactyl, modules, window) let ({ Group, contexts } = modules) ({ Local: function Local(dactyl, modules, window) let ({ Group, contexts } = modules) ({
init: function () { init: function init() {
this.Command = Class("Command", Command, { modules: modules }); this.Command = Class("Command", Command, { modules: modules });
update(this, { update(this, {
hives: contexts.Hives("commands", Class("CommandHive", CommandHive, { modules: modules })), hives: contexts.Hives("commands", Class("CommandHive", CommandHive, { modules: modules })),
@@ -569,11 +569,11 @@ var Commands = Module("commands", {
* the file that is being or has been sourced to obtain the * the file that is being or has been sourced to obtain the
* command string. * command string.
*/ */
execute: function (string, tokens, silent, args, context) { execute: function execute(string, tokens, silent, args, context) {
contexts.withContext(context || this.context || { file: "[Command Line]", line: 1 }, contexts.withContext(context || this.context || { file: "[Command Line]", line: 1 },
function (context) { function (context) {
modules.io.withSavedValues(["readHeredoc"], function () { modules.io.withSavedValues(["readHeredoc"], function () {
this.readHeredoc = function (end) { this.readHeredoc = function readHeredoc(end) {
let res = []; let res = [];
contexts.context.line++; contexts.context.line++;
while (++i < lines.length) { while (++i < lines.length) {
@@ -679,14 +679,14 @@ var Commands = Module("commands", {
COUNT_ALL: -2, // :%... COUNT_ALL: -2, // :%...
/** @property {Iterator(Command)} @private */ /** @property {Iterator(Command)} @private */
iterator: function () iter.apply(null, this.hives) iterator: function iterator() iter.apply(null, this.hives)
.sort(function (a, b) a.serialGroup - b.serialGroup || a.name > b.name) .sort(function (a, b) a.serialGroup - b.serialGroup || a.name > b.name)
.iterValues(), .iterValues(),
/** @property {string} The last executed Ex command line. */ /** @property {string} The last executed Ex command line. */
repeat: null, repeat: null,
add: function () this.builtin._add.apply(this.builtin, arguments), add: function add() this.builtin._add.apply(this.builtin, arguments),
addUserCommand: deprecated("group.commands.add", { get: function addUserCommand() this.user.closure._add }), addUserCommand: deprecated("group.commands.add", { get: function addUserCommand() this.user.closure._add }),
getUserCommands: deprecated("iter(group.commands)", function getUserCommands() iter(this.user).toArray()), getUserCommands: deprecated("iter(group.commands)", function getUserCommands() iter(this.user).toArray()),
removeUserCommand: deprecated("group.commands.remove", { get: function removeUserCommand() this.user.closure.remove }), removeUserCommand: deprecated("group.commands.remove", { get: function removeUserCommand() this.user.closure.remove }),
@@ -698,7 +698,7 @@ var Commands = Module("commands", {
* @param {Object} args The command invocation object. * @param {Object} args The command invocation object.
* @returns {string} * @returns {string}
*/ */
commandToString: function (args) { commandToString: function commandToString(args) {
let res = [args.command + (args.bang ? "!" : "")]; let res = [args.command + (args.bang ? "!" : "")];
let defaults = {}; let defaults = {};
@@ -734,7 +734,7 @@ var Commands = Module("commands", {
* any of the command's names. * any of the command's names.
* @returns {Command} * @returns {Command}
*/ */
get: function (name, full) iter(this.hives).map(function ([i, hive]) hive.get(name, full)) get: function get(name, full) iter(this.hives).map(function ([i, hive]) hive.get(name, full))
.nth(util.identity, 0), .nth(util.identity, 0),
/** /**
@@ -745,7 +745,7 @@ var Commands = Module("commands", {
* @param {string} host * @param {string} host
* @returns {boolean} * @returns {boolean}
*/ */
hasDomain: function (command, host) { hasDomain: function hasDomain(command, host) {
try { try {
for (let [cmd, args] in this.subCommands(command)) for (let [cmd, args] in this.subCommands(command))
if (Array.concat(cmd.domains(args)).some(function (domain) util.isSubdomain(domain, host))) if (Array.concat(cmd.domains(args)).some(function (domain) util.isSubdomain(domain, host)))
@@ -764,7 +764,7 @@ var Commands = Module("commands", {
* @param {string} command * @param {string} command
* @returns {boolean} * @returns {boolean}
*/ */
hasPrivateData: function (command) { hasPrivateData: function hasPrivateData(command) {
for (let [cmd, args] in this.subCommands(command)) for (let [cmd, args] in this.subCommands(command))
if (cmd.privateData) if (cmd.privateData)
return !callable(cmd.privateData) || cmd.privateData(args); return !callable(cmd.privateData) || cmd.privateData(args);
@@ -1122,9 +1122,9 @@ var Commands = Module("commands", {
]]>, /U/g, "\\u"), "x") ]]>, /U/g, "\\u"), "x")
}), }),
validName: Class.memoize(function () util.regexp("^" + this.nameRegexp.source + "$")), validName: Class.memoize(function validName() util.regexp("^" + this.nameRegexp.source + "$")),
commandRegexp: Class.memoize(function () util.regexp(<![CDATA[ commandRegexp: Class.memoize(function commandRegexp() util.regexp(<![CDATA[
^ ^
(?P<spec> (?P<spec>
(?P<prespace> [:\s]*) (?P<prespace> [:\s]*)
@@ -1158,7 +1158,7 @@ var Commands = Module("commands", {
* @returns {Array} * @returns {Array}
*/ */
// FIXME: why does this return an Array rather than Object? // FIXME: why does this return an Array rather than Object?
parseCommand: function (str) { parseCommand: function parseCommand(str) {
// remove comments // remove comments
str.replace(/\s*".*$/, ""); str.replace(/\s*".*$/, "");
@@ -1182,7 +1182,7 @@ var Commands = Module("commands", {
return [count, cmd, !!bang, args || "", spec.length, group]; return [count, cmd, !!bang, args || "", spec.length, group];
}, },
parseCommands: function (str, complete) { parseCommands: function parseCommands(str, complete) {
const { contexts } = this.modules; const { contexts } = this.modules;
do { do {
let [count, cmd, bang, args, len, group] = commands.parseCommand(str); let [count, cmd, bang, args, len, group] = commands.parseCommand(str);
@@ -1216,7 +1216,7 @@ var Commands = Module("commands", {
while (str); while (str);
}, },
subCommands: function (command) { subCommands: function subCommands(command) {
let commands = [command]; let commands = [command];
while (command = commands.shift()) while (command = commands.shift())
try { try {
@@ -1347,7 +1347,7 @@ var Commands = Module("commands", {
}; };
}, },
commands: function (dactyl, modules, window) { commands: function initCommands(dactyl, modules, window) {
const { commands, contexts } = modules; const { commands, contexts } = modules;
// TODO: Vim allows commands to be defined without {rep} if there are {attr}s // TODO: Vim allows commands to be defined without {rep} if there are {attr}s
@@ -1564,7 +1564,7 @@ var Commands = Module("commands", {
literal: 0 literal: 0
}); });
}, },
javascript: function (dactyl, modules, window) { javascript: function initJavascript(dactyl, modules, window) {
const { JavaScript, commands } = modules; const { JavaScript, commands } = modules;
JavaScript.setCompleter([commands.user.get, commands.user.remove], JavaScript.setCompleter([commands.user.get, commands.user.remove],
@@ -1572,7 +1572,7 @@ var Commands = Module("commands", {
JavaScript.setCompleter([commands.get], JavaScript.setCompleter([commands.get],
[function () [[c.names, c.description] for (c in this.iterator())]]); [function () [[c.names, c.description] for (c in this.iterator())]]);
}, },
mappings: function (dactyl, modules, window) { mappings: function initMappings(dactyl, modules, window) {
const { commands, mappings, modes } = modules; const { commands, mappings, modes } = modules;
mappings.add([modes.COMMAND], mappings.add([modes.COMMAND],

View File

@@ -317,9 +317,12 @@ var Overlay = Module("Overlay", {
modules.events.listen(window, "unload", function onUnload() { modules.events.listen(window, "unload", function onUnload() {
window.removeEventListener("unload", onUnload.wrapped, false); window.removeEventListener("unload", onUnload.wrapped, false);
for (let prop in properties(modules)) { for (let prop in properties(modules)) {
let desc = Object.getOwnPropertyDescriptor(modules, prop); let mod = Object.getOwnPropertyDescriptor(modules, prop).value;
if (desc.value instanceof ModuleBase && "destroy" in desc.value) if (mod instanceof ModuleBase || mod && mod.isLocalModule) {
util.trapErrors(desc.value.destroy, desc.value); mod.stale = true;
if ("destroy" in mod)
util.trapErrors("destroy", mod);
}
} }
}, false); }, false);
} }