mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-07 10:24:11 +01:00
Add missing function name. Fix cleanup on window close. Fix minor mode change bug and add guards.
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* @instance buffer
|
||||
*/
|
||||
var Buffer = Module("buffer", {
|
||||
init: function () {
|
||||
init: function init() {
|
||||
this.evaluateXPath = util.evaluateXPath;
|
||||
this.pageInfo = {};
|
||||
|
||||
@@ -165,7 +165,7 @@ var Buffer = Module("buffer", {
|
||||
);
|
||||
},
|
||||
|
||||
climbUrlPath: function (count) {
|
||||
climbUrlPath: function climbUrlPath(count) {
|
||||
let url = buffer.documentURI.clone();
|
||||
dactyl.assert(url instanceof Ci.nsIURL);
|
||||
|
||||
@@ -176,7 +176,7 @@ var Buffer = Module("buffer", {
|
||||
dactyl.open(url.spec);
|
||||
},
|
||||
|
||||
incrementURL: function (count) {
|
||||
incrementURL: function incrementURL(count) {
|
||||
let matches = buffer.uri.spec.match(/(.*?)(\d+)(\D*)$/);
|
||||
dactyl.assert(matches);
|
||||
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.
|
||||
*/
|
||||
allFrames: function (win, focusedFirst) {
|
||||
allFrames: function allFrames(win, focusedFirst) {
|
||||
let frames = [];
|
||||
(function rec(frame) {
|
||||
if (frame.document.body instanceof HTMLBodyElement)
|
||||
@@ -343,7 +343,7 @@ var Buffer = Module("buffer", {
|
||||
* @param {Node|Window}
|
||||
* @returns {boolean}
|
||||
*/
|
||||
focusAllowed: function (elem) {
|
||||
focusAllowed: function focusAllowed(elem) {
|
||||
if (elem instanceof Window && !Editor.getEditor(elem))
|
||||
return true;
|
||||
let doc = elem.ownerDocument || elem.document || elem;
|
||||
@@ -357,7 +357,7 @@ var Buffer = Module("buffer", {
|
||||
*
|
||||
* @param {Node} elem The element to focus.
|
||||
*/
|
||||
focusElement: function (elem) {
|
||||
focusElement: function focusElement(elem) {
|
||||
let win = elem.ownerDocument && elem.ownerDocument.defaultView || elem;
|
||||
win.document.dactylFocusAllowed = true;
|
||||
|
||||
@@ -427,7 +427,7 @@ var Buffer = Module("buffer", {
|
||||
function followDocumentRelationship(rel) {
|
||||
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;
|
||||
|
||||
function followFrame(frame) {
|
||||
@@ -475,7 +475,7 @@ var Buffer = Module("buffer", {
|
||||
* @param {number} where Where to open the link. See
|
||||
* {@link dactyl.open}.
|
||||
*/
|
||||
followLink: function (elem, where) {
|
||||
followLink: function followLink(elem, where) {
|
||||
let doc = elem.ownerDocument;
|
||||
let view = doc.defaultView;
|
||||
let { left: offsetX, top: offsetY } = elem.getBoundingClientRect();
|
||||
@@ -538,7 +538,7 @@ var Buffer = Module("buffer", {
|
||||
*
|
||||
* @param {Node} elem The context element.
|
||||
*/
|
||||
openContextMenu: function (elem) {
|
||||
openContextMenu: function openContextMenu(elem) {
|
||||
document.popupNode = elem;
|
||||
let menu = document.getElementById("contentAreaContextMenu");
|
||||
menu.showPopup(elem, -1, -1, "context", "bottomleft", "topleft");
|
||||
@@ -549,7 +549,7 @@ var Buffer = Module("buffer", {
|
||||
*
|
||||
* @param {HTMLAnchorElement} elem The page link to save.
|
||||
*/
|
||||
saveLink: function (elem) {
|
||||
saveLink: function saveLink(elem) {
|
||||
let doc = elem.ownerDocument;
|
||||
let uri = util.newURI(elem.href || elem.src, null, util.newURI(elem.baseURI));
|
||||
let referrer = util.newURI(doc.documentURI, doc.characterSet);
|
||||
@@ -588,7 +588,7 @@ var Buffer = Module("buffer", {
|
||||
* @param {nsIURI} uri The URI to save
|
||||
* @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();
|
||||
persist.persistFlags = persist.PERSIST_FLAGS_FROM_CACHE
|
||||
| persist.PERSIST_FLAGS_REPLACE_EXISTING_FILES;
|
||||
@@ -645,7 +645,7 @@ var Buffer = Module("buffer", {
|
||||
* @param {number} count The multiple of 'scroll' lines to scroll.
|
||||
* @optional
|
||||
*/
|
||||
scrollByScrollSize: function (direction, count) {
|
||||
scrollByScrollSize: function scrollByScrollSize(direction, count) {
|
||||
direction = direction ? 1 : -1;
|
||||
count = count || 1;
|
||||
|
||||
@@ -732,7 +732,7 @@ var Buffer = Module("buffer", {
|
||||
* @param {number} count The number of frames to skip through. A negative
|
||||
* count skips backwards.
|
||||
*/
|
||||
shiftFrameFocus: function (count) {
|
||||
shiftFrameFocus: function shiftFrameFocus(count) {
|
||||
if (!(content.document instanceof HTMLDocument))
|
||||
return;
|
||||
|
||||
@@ -780,7 +780,7 @@ var Buffer = Module("buffer", {
|
||||
*
|
||||
* @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);
|
||||
},
|
||||
|
||||
@@ -791,7 +791,7 @@ var Buffer = Module("buffer", {
|
||||
* @param {string} sections A string limiting the displayed sections.
|
||||
* @default The value of 'pageinfo'.
|
||||
*/
|
||||
showPageInfo: function (verbose, sections) {
|
||||
showPageInfo: function showPageInfo(verbose, sections) {
|
||||
// Ctrl-g single line output
|
||||
if (!verbose) {
|
||||
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
|
||||
* range.
|
||||
*/
|
||||
viewSelectionSource: function () {
|
||||
viewSelectionSource: function viewSelectionSource() {
|
||||
// copied (and tuned somewhat) from browser.jar -> nsContextMenu.js
|
||||
let win = document.commandDispatcher.focusedWindow;
|
||||
if (win == window)
|
||||
@@ -852,7 +852,7 @@ var Buffer = Module("buffer", {
|
||||
* @default The current buffer.
|
||||
* @param {boolean} useExternalEditor View the source in the external editor.
|
||||
*/
|
||||
viewSource: function (url, useExternalEditor) {
|
||||
viewSource: function viewSource(url, useExternalEditor) {
|
||||
let doc = this.focusedFrame.document;
|
||||
|
||||
if (isArray(url)) {
|
||||
@@ -893,7 +893,7 @@ var Buffer = Module("buffer", {
|
||||
*/
|
||||
viewSourceExternally: Class("viewSourceExternally",
|
||||
XPCOM([Ci.nsIWebProgressListener, Ci.nsISupportsWeakReference]), {
|
||||
init: function (doc, callback) {
|
||||
init: function init(doc, callback) {
|
||||
this.callback = callable(callback) ? callback :
|
||||
function (file, temp) {
|
||||
editor.editFileExternally({ file: file.path, line: callback },
|
||||
@@ -924,7 +924,7 @@ var Buffer = Module("buffer", {
|
||||
return null;
|
||||
},
|
||||
|
||||
onStateChange: function (progress, request, flag, status) {
|
||||
onStateChange: function onStateChange(progress, request, flag, status) {
|
||||
if ((flag & this.STATE_STOP) && status == 0) {
|
||||
try {
|
||||
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 {boolean} fullZoom Whether to use full zoom or text zoom.
|
||||
*/
|
||||
zoomIn: function (steps, fullZoom) {
|
||||
zoomIn: function zoomIn(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 {boolean} fullZoom Whether to use full zoom or text zoom.
|
||||
*/
|
||||
zoomOut: function (steps, fullZoom) {
|
||||
zoomOut: function zoomOut(steps, fullZoom) {
|
||||
this.bumpZoomLevel(-steps, fullZoom);
|
||||
},
|
||||
|
||||
@@ -1037,7 +1037,7 @@ var Buffer = Module("buffer", {
|
||||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
currentWord: function (win) {
|
||||
currentWord: function currentWord(win) {
|
||||
let selection = win.getSelection();
|
||||
if (selection.rangeCount == 0)
|
||||
return "";
|
||||
@@ -1206,7 +1206,7 @@ var Buffer = Module("buffer", {
|
||||
|
||||
openUploadPrompt: function openUploadPrompt(elem) {
|
||||
io.CommandFileMode("Upload file: ", {
|
||||
onSubmit: function (path) {
|
||||
onSubmit: function onSubmit(path) {
|
||||
let file = io.File(path);
|
||||
dactyl.assert(file.exists());
|
||||
|
||||
@@ -1216,7 +1216,7 @@ var Buffer = Module("buffer", {
|
||||
}).open(elem.value);
|
||||
}
|
||||
}, {
|
||||
commands: function () {
|
||||
commands: function initCommands(dactyl, modules, window) {
|
||||
commands.add(["frameo[nly]"],
|
||||
"Show only the current frame's page",
|
||||
function (args) {
|
||||
@@ -1417,7 +1417,7 @@ var Buffer = Module("buffer", {
|
||||
bang: true
|
||||
});
|
||||
},
|
||||
completion: function () {
|
||||
completion: function initCompletion(dactyl, modules, window) {
|
||||
completion.alternateStyleSheet = function alternateStylesheet(context) {
|
||||
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);
|
||||
},
|
||||
mappings: function () {
|
||||
mappings: function initMappings(dactyl, modules, window) {
|
||||
mappings.add([modes.NORMAL],
|
||||
["y", "<yank-location>"], "Yank current location to the clipboard",
|
||||
function () { dactyl.clipboardWrite(buffer.uri.spec, true); });
|
||||
@@ -1774,7 +1774,7 @@ var Buffer = Module("buffer", {
|
||||
"Print file information",
|
||||
function () { buffer.showPageInfo(true); });
|
||||
},
|
||||
options: function () {
|
||||
options: function initOptions(dactyl, modules, window) {
|
||||
options.add(["encoding", "enc"],
|
||||
"The current buffer's character encoding",
|
||||
"string", "UTF-8",
|
||||
|
||||
@@ -88,9 +88,9 @@ var CommandWidgets = Class("CommandWidgets", {
|
||||
|
||||
this.addElement({
|
||||
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",
|
||||
get: function (elem) {
|
||||
get: function command_get(elem) {
|
||||
// The long path is because of complications with the
|
||||
// completion preview.
|
||||
try {
|
||||
@@ -102,7 +102,7 @@ var CommandWidgets = Class("CommandWidgets", {
|
||||
},
|
||||
getElement: CommandWidgets.getEditor,
|
||||
getGroup: function (value) this.activeGroup.commandline,
|
||||
onChange: function (elem, value) {
|
||||
onChange: function command_onChange(elem, value) {
|
||||
if (elem.inputField != dactyl.focusedElement)
|
||||
try {
|
||||
elem.selectionStart = elem.value.length;
|
||||
@@ -113,7 +113,7 @@ var CommandWidgets = Class("CommandWidgets", {
|
||||
if (!elem.collapsed)
|
||||
dactyl.focus(elem);
|
||||
},
|
||||
onVisibility: function (elem, visible) {
|
||||
onVisibility: function command_onVisibility(elem, visible) {
|
||||
if (visible)
|
||||
dactyl.focus(elem);
|
||||
}
|
||||
@@ -431,8 +431,8 @@ var CommandExMode = Class("CommandExMode", CommandMode, {
|
||||
|
||||
onSubmit: function onSubmit(command) {
|
||||
contexts.withContext({ file: "[Command Line]", line: 1 },
|
||||
function () {
|
||||
io.withSavedValues(["readHeredoc"], function () {
|
||||
function _onSubmit() {
|
||||
io.withSavedValues(["readHeredoc"], function _onSubmit() {
|
||||
this.readHeredoc = commandline.readHeredoc;
|
||||
commands.repeat = command;
|
||||
dactyl.execute(command);
|
||||
|
||||
@@ -66,6 +66,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
|
||||
for (let mod in values(mods))
|
||||
if (mod instanceof ModuleBase || mod && mod.isLocalModule) {
|
||||
mod.stale = true;
|
||||
if ("cleanup" in mod)
|
||||
this.trapErrors(mod.cleanup, mod);
|
||||
if ("destroy" in mod)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
/** @scope modules */
|
||||
|
||||
var Modes = Module("modes", {
|
||||
init: function () {
|
||||
init: function init() {
|
||||
this.modeChars = {};
|
||||
this._main = 1; // NORMAL
|
||||
this._extended = 0; // NONE
|
||||
@@ -197,11 +197,11 @@ var Modes = Module("modes", {
|
||||
}
|
||||
});
|
||||
},
|
||||
cleanup: function () {
|
||||
cleanup: function cleanup() {
|
||||
modes.reset();
|
||||
},
|
||||
|
||||
_getModeMessage: function () {
|
||||
_getModeMessage: function _getModeMessage() {
|
||||
// when recording a macro
|
||||
let macromode = "";
|
||||
if (this.recording)
|
||||
@@ -217,7 +217,7 @@ var Modes = Module("modes", {
|
||||
|
||||
NONE: 0,
|
||||
|
||||
__iterator__: function () array.iterValues(this.all),
|
||||
__iterator__: function __iterator__() array.iterValues(this.all),
|
||||
|
||||
get all() this._modes.slice(),
|
||||
|
||||
@@ -229,7 +229,7 @@ var Modes = Module("modes", {
|
||||
|
||||
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);
|
||||
|
||||
this[name] = mode;
|
||||
@@ -245,23 +245,23 @@ var Modes = Module("modes", {
|
||||
dactyl.triggerObserver("mode-add", mode);
|
||||
},
|
||||
|
||||
dumpStack: function () {
|
||||
dumpStack: function dumpStack() {
|
||||
util.dump("Mode stack:");
|
||||
for (let [i, mode] in array.iterItems(this._modeStack))
|
||||
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(),
|
||||
|
||||
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)),
|
||||
|
||||
matchModes: function (obj)
|
||||
matchModes: function matchModes(obj)
|
||||
this._modes.filter(function (mode) Object.keys(obj)
|
||||
.every(function (k) obj[k] == (mode[k] || false))),
|
||||
|
||||
@@ -287,7 +287,7 @@ var Modes = Module("modes", {
|
||||
},
|
||||
|
||||
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) {
|
||||
if (!(id in this.boundProperties))
|
||||
@@ -296,56 +296,69 @@ var Modes = Module("modes", {
|
||||
this.boundProperties[id] = { obj: Cu.getWeakReference(obj), prop: prop, test: test };
|
||||
},
|
||||
|
||||
inSet: false,
|
||||
|
||||
// helper function to set both modes in one go
|
||||
set: function set(mainMode, extendedMode, params, stack) {
|
||||
params = params || this.getMode(mainMode || this.main).params;
|
||||
var delayed, oldExtended, oldMain, prev, push;
|
||||
|
||||
if (!stack && mainMode != null && this._modeStack.length > 1)
|
||||
this.reset();
|
||||
|
||||
let oldMain = this._main, oldExtended = this._extended;
|
||||
|
||||
if (extendedMode != null)
|
||||
this._extended = extendedMode;
|
||||
if (mainMode != null) {
|
||||
this._main = mainMode;
|
||||
if (!extendedMode)
|
||||
this._extended = this.NONE;
|
||||
if (this.inSet) {
|
||||
dactyl.reportError(Error("Not executing modes.set recursively"), true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (stack && stack.pop && stack.pop.params.leave)
|
||||
dactyl.trapErrors("leave", stack.pop.params,
|
||||
stack, this.topOfStack);
|
||||
this.withSavedValues(["inSet"], function set() {
|
||||
this.inSet = true;
|
||||
|
||||
let push = mainMode != null && !(stack && stack.pop) &&
|
||||
Modes.StackElement(this._main, this._extended, params, {});
|
||||
params = params || this.getMode(mainMode || this.main).params;
|
||||
|
||||
if (push && this.topOfStack) {
|
||||
if (this.topOfStack.params.leave)
|
||||
dactyl.trapErrors("leave", this.topOfStack.params,
|
||||
{ push: push }, push);
|
||||
if (!stack && mainMode != null && this._modeStack.length > 1)
|
||||
this.reset();
|
||||
|
||||
for (let [id, { obj, prop, test }] in Iterator(this.boundProperties)) {
|
||||
if (!obj.get())
|
||||
delete this.boundProperties[id];
|
||||
else
|
||||
this.topOfStack.saved[id] = { obj: obj.get(), prop: prop, value: obj.get()[prop], test: test };
|
||||
oldMain = this._main, oldExtended = this._extended;
|
||||
|
||||
if (extendedMode != null)
|
||||
this._extended = extendedMode;
|
||||
if (mainMode != null) {
|
||||
this._main = mainMode;
|
||||
if (!extendedMode)
|
||||
this._extended = this.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
let delayed = this.delayed;
|
||||
this.delayed = [];
|
||||
if (stack && stack.pop && stack.pop.params.leave)
|
||||
dactyl.trapErrors("leave", stack.pop.params,
|
||||
stack, this.topOfStack);
|
||||
|
||||
let prev = stack && stack.pop || this.topOfStack;
|
||||
if (push)
|
||||
this._modeStack.push(push);
|
||||
push = mainMode != null && !(stack && stack.pop) &&
|
||||
Modes.StackElement(this._main, this._extended, params, {});
|
||||
|
||||
if (stack && stack.pop)
|
||||
for (let { obj, prop, value, test } in values(this.topOfStack.saved))
|
||||
if (!test || !test(stack, prev))
|
||||
obj[prop] = value;
|
||||
if (push && this.topOfStack) {
|
||||
if (this.topOfStack.params.leave)
|
||||
dactyl.trapErrors("leave", this.topOfStack.params,
|
||||
{ push: push }, push);
|
||||
|
||||
this.show();
|
||||
for (let [id, { obj, prop, test }] in Iterator(this.boundProperties)) {
|
||||
if (!obj.get())
|
||||
delete this.boundProperties[id];
|
||||
else
|
||||
this.topOfStack.saved[id] = { obj: obj.get(), prop: prop, value: obj.get()[prop], test: test };
|
||||
}
|
||||
}
|
||||
|
||||
delayed = this.delayed;
|
||||
this.delayed = [];
|
||||
|
||||
prev = stack && stack.pop || this.topOfStack;
|
||||
if (push)
|
||||
this._modeStack.push(push);
|
||||
|
||||
if (stack && stack.pop)
|
||||
for (let { obj, prop, value, test } in values(this.topOfStack.saved))
|
||||
if (!test || !test(stack, prev))
|
||||
dactyl.trapErrors(function () { obj[prop] = value });
|
||||
|
||||
this.show();
|
||||
});
|
||||
|
||||
delayed.forEach(function ([fn, self]) dactyl.trapErrors(fn, self));
|
||||
|
||||
@@ -417,7 +430,7 @@ var Modes = Module("modes", {
|
||||
}, options);
|
||||
},
|
||||
|
||||
isinstance: function (obj)
|
||||
isinstance: function isinstance(obj)
|
||||
this === obj || this.allBases.indexOf(obj) >= 0 || callable(obj) && this instanceof obj,
|
||||
|
||||
allBases: Class.memoize(function () {
|
||||
@@ -436,17 +449,17 @@ var Modes = Module("modes", {
|
||||
|
||||
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,
|
||||
|
||||
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,
|
||||
|
||||
@@ -454,7 +467,7 @@ var Modes = Module("modes", {
|
||||
|
||||
get toStringParams() [this.name],
|
||||
|
||||
valueOf: function () this.id
|
||||
valueOf: function valueOf() this.id
|
||||
}, {
|
||||
_id: 0
|
||||
}),
|
||||
@@ -472,19 +485,21 @@ var Modes = Module("modes", {
|
||||
return StackElement;
|
||||
})(),
|
||||
cacheId: 0,
|
||||
boundProperty: function boundProperty(desc) {
|
||||
boundProperty: function BoundProperty(desc) {
|
||||
let id = this.cacheId++;
|
||||
let value;
|
||||
|
||||
desc = desc || {};
|
||||
let id = this.cacheId++, value;
|
||||
return Class.Property(update({
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
init: function (prop) update(this, {
|
||||
get: function () {
|
||||
enumerable: true,
|
||||
init: function bound_init(prop) update(this, {
|
||||
get: function bound_get() {
|
||||
if (desc.get)
|
||||
var val = desc.get.call(this, value);
|
||||
return val === undefined ? value : val;
|
||||
},
|
||||
set: function (val) {
|
||||
set: function bound_set(val) {
|
||||
modes.save(id, this, prop, desc.test);
|
||||
if (desc.set)
|
||||
value = desc.set.call(this, val);
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
"use strict";
|
||||
|
||||
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)
|
||||
this.resize(false);
|
||||
|
||||
@@ -17,7 +17,7 @@ var MOW = Module("mow", {
|
||||
this.updateMorePrompt();
|
||||
}, this);
|
||||
|
||||
this._timer = Timer(20, 400, function () {
|
||||
this._timer = Timer(20, 400, function _timer() {
|
||||
if (modes.have(modes.OUTPUT_MULTILINE)) {
|
||||
this.resize(true);
|
||||
|
||||
@@ -80,9 +80,9 @@ 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 () 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 window() this.widget.contentWindow,
|
||||
|
||||
@@ -195,7 +195,7 @@ var MOW = Module("mow", {
|
||||
},
|
||||
|
||||
contextEvents: {
|
||||
popupshowing: function (event) {
|
||||
popupshowing: function onPopupShowing(event) {
|
||||
let menu = commandline.widgets.contextMenu;
|
||||
let enabled = {
|
||||
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
|
||||
* already so.
|
||||
*/
|
||||
resize: function updateOutputHeight(open, extra) {
|
||||
resize: function resize(open, extra) {
|
||||
if (!(open || this.visible))
|
||||
return;
|
||||
|
||||
@@ -266,7 +266,6 @@ var MOW = Module("mow", {
|
||||
* and what they do.
|
||||
*/
|
||||
updateMorePrompt: function updateMorePrompt(force, showHelp) {
|
||||
util.dump("\n"); modes.dumpStack(); util.dumpStack(); util.dump("\n");
|
||||
if (!this.visible || !isinstance(modes.main, modes.OUTPUT_MULTILINE))
|
||||
return this.widgets.message = null;
|
||||
|
||||
@@ -286,13 +285,19 @@ var MOW = Module("mow", {
|
||||
this.widgets.mowContainer.collapsed = !value;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
})
|
||||
}, {
|
||||
}, {
|
||||
mappings: function () {
|
||||
mappings: function initMappings() {
|
||||
const PASS = true;
|
||||
const DROP = false;
|
||||
const BEEP = {};
|
||||
@@ -376,7 +381,7 @@ var MOW = Module("mow", {
|
||||
function () {},
|
||||
function () false, DROP);
|
||||
},
|
||||
options: function () {
|
||||
options: function initOptions() {
|
||||
options.add(["more"],
|
||||
"Pause the message list window when the full output will not fit on one page",
|
||||
"boolean", true);
|
||||
|
||||
Reference in New Issue
Block a user