1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 12:38:00 +01:00

Import minor changes from groups branch.

This commit is contained in:
Kris Maglione
2011-02-05 03:11:21 -05:00
parent e9fd99dafa
commit 1af39e6424
12 changed files with 49 additions and 42 deletions

View File

@@ -245,7 +245,7 @@ var AutoCommands = Module("autocommands", {
}; };
}, },
javascript: function () { javascript: function () {
JavaScript.setCompleter(this.get, [function () Iterator(config.autocommands)]); JavaScript.setCompleter(autocommands.get, [function () Iterator(config.autocommands)]);
}, },
options: function () { options: function () {
options.add(["eventignore", "ei"], options.add(["eventignore", "ei"],

View File

@@ -262,7 +262,7 @@ var Buffer = Module("buffer", {
dactylLoadCount: 0, dactylLoadCount: 0,
// XXX: function may later be needed to detect a canceled synchronous openURL() // XXX: function may later be needed to detect a canceled synchronous openURL()
onStateChange: function onStateChange(webProgress, request, flags, status) { onStateChange: util.wrapCallback(function onStateChange(webProgress, request, flags, status) {
onStateChange.superapply(this, arguments); onStateChange.superapply(this, arguments);
// STATE_IS_DOCUMENT | STATE_IS_WINDOW is important, because we also // STATE_IS_DOCUMENT | STATE_IS_WINDOW is important, because we also
// receive statechange events for loading images and other parts of the web page // receive statechange events for loading images and other parts of the web page
@@ -286,9 +286,9 @@ var Buffer = Module("buffer", {
statusline.updateUrl(); statusline.updateUrl();
} }
} }
}, }),
// for notifying the user about secure web pages // for notifying the user about secure web pages
onSecurityChange: function onSecurityChange(webProgress, request, state) { onSecurityChange: util.wrapCallback(function onSecurityChange(webProgress, request, state) {
onSecurityChange.superapply(this, arguments); onSecurityChange.superapply(this, arguments);
if (state & Ci.nsIWebProgressListener.STATE_IS_BROKEN) if (state & Ci.nsIWebProgressListener.STATE_IS_BROKEN)
statusline.security = "broken"; statusline.security = "broken";
@@ -300,19 +300,19 @@ var Buffer = Module("buffer", {
statusline.security = "insecure"; statusline.security = "insecure";
if (webProgress && webProgress.DOMWindow) if (webProgress && webProgress.DOMWindow)
webProgress.DOMWindow.document.dactylSecurity = statusline.security; webProgress.DOMWindow.document.dactylSecurity = statusline.security;
}, }),
onStatusChange: function onStatusChange(webProgress, request, status, message) { onStatusChange: util.wrapCallback(function onStatusChange(webProgress, request, status, message) {
onStatusChange.superapply(this, arguments); onStatusChange.superapply(this, arguments);
statusline.updateUrl(message); statusline.updateUrl(message);
}, }),
onProgressChange: function onProgressChange(webProgress, request, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress) { onProgressChange: util.wrapCallback(function onProgressChange(webProgress, request, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress) {
onProgressChange.superapply(this, arguments); onProgressChange.superapply(this, arguments);
if (webProgress.DOMWindow) if (webProgress && webProgress.DOMWindow)
webProgress.DOMWindow.dactylProgress = curTotalProgress / maxTotalProgress; webProgress.DOMWindow.dactylProgress = curTotalProgress / maxTotalProgress;
statusline.progress = curTotalProgress / maxTotalProgress; statusline.progress = curTotalProgress / maxTotalProgress;
}, }),
// happens when the users switches tabs // happens when the users switches tabs
onLocationChange: function onLocationChange(webProgress, request, uri) { onLocationChange: util.wrapCallback(function onLocationChange(webProgress, request, uri) {
onLocationChange.superapply(this, arguments); onLocationChange.superapply(this, arguments);
delete mappings.hives; delete mappings.hives;
@@ -352,13 +352,13 @@ var Buffer = Module("buffer", {
if (loaded.commandline) if (loaded.commandline)
commandline.clear(); commandline.clear();
}, 500); }, 500);
}, }),
// called at the very end of a page load // called at the very end of a page load
asyncUpdateUI: function asyncUpdateUI() { asyncUpdateUI: util.wrapCallback(function asyncUpdateUI() {
asyncUpdateUI.superapply(this, arguments); asyncUpdateUI.superapply(this, arguments);
util.timeout(function () { statusline.updateUrl(); }, 100); util.timeout(function () { statusline.updateUrl(); }, 100);
}, }),
setOverLink: function setOverLink(link, b) { setOverLink: util.wrapCallback(function setOverLink(link, b) {
setOverLink.superapply(this, arguments); setOverLink.superapply(this, arguments);
switch (options["showstatuslinks"]) { switch (options["showstatuslinks"]) {
case "status": case "status":
@@ -371,7 +371,7 @@ var Buffer = Module("buffer", {
commandline.clear(); commandline.clear();
break; break;
} }
}, }),
}, },
/** /**

View File

@@ -352,8 +352,8 @@ var CommandMode = Class("CommandMode", {
if (this.history) if (this.history)
this.history.save(); this.history.save();
commandline.hideCompletions();
this.resetCompletions(); this.resetCompletions();
commandline.hideCompletions();
modes.delay(function () { modes.delay(function () {
if (!this.keepCommand || commandline.silent || commandline.quiet) if (!this.keepCommand || commandline.silent || commandline.quiet)
@@ -504,11 +504,6 @@ var CommandLine = Module("commandline", {
}, message)); }, message));
} }
}; //}}} }; //}}}
this._silent = false;
this._quiet = false;
this._lastEcho = null;
}, },
/** /**
@@ -546,12 +541,14 @@ var CommandLine = Module("commandline", {
get completionContext() this._completions.context, get completionContext() this._completions.context,
_silent: false,
get silent() this._silent, get silent() this._silent,
set silent(val) { set silent(val) {
this._silent = val; this._silent = val;
this.quiet = this.quiet; this.quiet = this.quiet;
}, },
_quite: false,
get quiet() this._quiet, get quiet() this._quiet,
set quiet(val) { set quiet(val) {
this._quiet = val; this._quiet = val;
@@ -665,6 +662,8 @@ var CommandLine = Module("commandline", {
} }
}, },
_lastEcho: null,
/** /**
* Output the given string onto the command line. With no flags, the * Output the given string onto the command line. With no flags, the
* message will be shown in the status line if it's short enough to * message will be shown in the status line if it's short enough to

View File

@@ -12,7 +12,6 @@ default xml namespace = XHTML;
XML.ignoreWhitespace = false; XML.ignoreWhitespace = false;
XML.prettyPrinting = false; XML.prettyPrinting = false;
var plugins = { __proto__: modules };
var userContext = { __proto__: modules }; var userContext = { __proto__: modules };
var _userContext = newContext(userContext); var _userContext = newContext(userContext);
@@ -53,7 +52,6 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
destroy: function () { destroy: function () {
autocommands.trigger("LeavePre", {}); autocommands.trigger("LeavePre", {});
storage.saveAll();
dactyl.triggerObserver("shutdown", null); dactyl.triggerObserver("shutdown", null);
util.dump("All dactyl modules destroyed\n"); util.dump("All dactyl modules destroyed\n");
autocommands.trigger("Leave", {}); autocommands.trigger("Leave", {});
@@ -337,7 +335,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
dactyl.reportError(str); dactyl.reportError(str);
if (typeof str == "object" && "echoerr" in str) if (typeof str == "object" && "echoerr" in str)
str = str.echoerr; str = str.echoerr;
else if (isinstance(str, ["Error"])) else if (isinstance(str, ["Error"]) && str.fileName)
str = <>{str.fileName.replace(/^.* -> /, "")}: {str.lineNumber}: {str}</>; str = <>{str.fileName.replace(/^.* -> /, "")}: {str.lineNumber}: {str}</>;
if (options["errorbells"]) if (options["errorbells"])

View File

@@ -862,7 +862,7 @@ var Mappings = Module("mappings", {
}; };
}, },
javascript: function () { javascript: function () {
JavaScript.setCompleter(this.get, JavaScript.setCompleter(mappings.get,
[ [
null, null,
function (context, obj, args) { function (context, obj, args) {

View File

@@ -4,6 +4,7 @@
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
"use strict";
var MOW = Module("mow", { var MOW = Module("mow", {
init: function () { init: function () {
@@ -71,7 +72,6 @@ var MOW = Module("mow", {
if (!commandline.commandVisible) if (!commandline.commandVisible)
commandline.hide(); commandline.hide();
this._startHints = false;
if (modes.main != modes.OUTPUT_MULTILINE) { if (modes.main != modes.OUTPUT_MULTILINE) {
modes.push(modes.OUTPUT_MULTILINE, null, { modes.push(modes.OUTPUT_MULTILINE, null, {
onKeyPress: this.closure.onKeyPress, onKeyPress: this.closure.onKeyPress,
@@ -170,6 +170,7 @@ var MOW = Module("mow", {
event.preventDefault(); event.preventDefault();
} }
}, },
contextEvents: { contextEvents: {
popupshowing: function (event) { popupshowing: function (event) {
let menu = commandline.widgets.contextMenu; let menu = commandline.widgets.contextMenu;
@@ -261,8 +262,7 @@ var MOW = Module("mow", {
if (!value && elem && elem.contentWindow == document.commandDispatcher.focusedWindow) if (!value && elem && elem.contentWindow == document.commandDispatcher.focusedWindow)
document.commandDispatcher.focusedWindow = content; document.commandDispatcher.focusedWindow = content;
} }
}), })
}, { }, {
}, { }, {
mappings: function () { mappings: function () {
@@ -277,7 +277,7 @@ var MOW = Module("mow", {
mow.echo(mow.lastOutput, "Normal"); mow.echo(mow.lastOutput, "Normal");
}); });
bind = function bind(keys, description, action, test, default_) { let bind = function bind(keys, description, action, test, default_) {
mappings.add([modes.OUTPUT_MULTILINE], mappings.add([modes.OUTPUT_MULTILINE],
keys, description, keys, description,
function (command) { function (command) {

View File

@@ -1295,7 +1295,7 @@ var Options = Module("options", {
}; };
}, },
javascript: function () { javascript: function () {
JavaScript.setCompleter(this.get, [function () ([o.name, o.description] for (o in options))]); JavaScript.setCompleter(options.get, [function () ([o.name, o.description] for (o in options))]);
}, },
sanitizer: function () { sanitizer: function () {
sanitizer.addItem("options", { sanitizer.addItem("options", {

View File

@@ -35,12 +35,12 @@ var AddonListener = Class("AddonListener", {
onExternalInstall: function (addon, existingAddon, needsRestart) {}, onExternalInstall: function (addon, existingAddon, needsRestart) {},
onDownloadStarted: listener("download", "started"), onDownloadStarted: listener("download", "started"),
onDownloadEnded: listener("download", "complete"), onDownloadEnded: listener("download", "complete"),
onDownloadCancelled: listener("download", "cancelled"), onDownloadCancelled: listener("download", "canceled"),
onDownloadFailed: listener("download", "failed"), onDownloadFailed: listener("download", "failed"),
onDownloadProgress: function (install) {}, onDownloadProgress: function (install) {},
onInstallStarted: function (install) {}, onInstallStarted: function (install) {},
onInstallEnded: listener("installation", "complete"), onInstallEnded: listener("installation", "complete"),
onInstallCancelled: listener("installation", "cancelled"), onInstallCancelled: listener("installation", "canceled"),
onInstallFailed: listener("installation", "failed") onInstallFailed: listener("installation", "failed")
}); });

View File

@@ -616,12 +616,12 @@ function update(target) {
if (desc.value instanceof Class.Property) if (desc.value instanceof Class.Property)
desc = desc.value.init(k) || desc.value; desc = desc.value.init(k) || desc.value;
if (typeof desc.value == "function" && Object.getPrototypeOf(target)) { if (typeof desc.value == "function" && Object.getPrototypeOf(target)) {
let func = desc.value; let func = desc.value.wrapped || desc.value;
desc.value.__defineGetter__("super", function () Object.getPrototypeOf(target)[k]); func.__defineGetter__("super", function () Object.getPrototypeOf(target)[k]);
desc.value.superapply = function superapply(self, args) func.superapply = function superapply(self, args)
let (meth = Object.getPrototypeOf(target)[k]) let (meth = Object.getPrototypeOf(target)[k])
meth && meth.apply(self, args); meth && meth.apply(self, args);
desc.value.supercall = function supercall(self) func.supercall = function supercall(self)
func.superapply(self, Array.slice(arguments, 1)); func.superapply(self, Array.slice(arguments, 1));
} }
Object.defineProperty(target, k, desc); Object.defineProperty(target, k, desc);
@@ -663,7 +663,7 @@ function Class() {
superclass = args.shift(); superclass = args.shift();
var Constructor = eval(String.replace(<![CDATA[ var Constructor = eval(String.replace(<![CDATA[
(function constructor() { (function constructor(PARAMS) {
var self = Object.create(Constructor.prototype, { var self = Object.create(Constructor.prototype, {
constructor: { value: Constructor }, constructor: { value: Constructor },
}); });
@@ -671,7 +671,9 @@ function Class() {
var res = self.init.apply(self, arguments); var res = self.init.apply(self, arguments);
return res !== undefined ? res : self; return res !== undefined ? res : self;
})]]>, })]]>,
"constructor", (name || superclass.className).replace(/\W/g, "_"))); "constructor", (name || superclass.className).replace(/\W/g, "_"))
.replace("PARAMS", /^function .*?\((.*?)\)/.exec(args[0] && args[0].init || Class.prototype.init)[1]));
Constructor.className = name || superclass.className || superclass.name; Constructor.className = name || superclass.className || superclass.name;
if ("init" in superclass.prototype) if ("init" in superclass.prototype)

View File

@@ -144,6 +144,7 @@ var Overlay = Module("Overlay", {
return sandbox; return sandbox;
} }
}); });
modules.plugins = create(modules);
modules.modules = modules; modules.modules = modules;
window.dactyl = { modules: modules }; window.dactyl = { modules: modules };

View File

@@ -152,6 +152,8 @@ var Storage = Module("Storage", {
}, },
cleanup: function () { cleanup: function () {
this.saveAll();
for (let key in keys(this.keys)) { for (let key in keys(this.keys)) {
if (this[key].timer) if (this[key].timer)
this[key].timer.flush(); this[key].timer.flush();

View File

@@ -32,8 +32,8 @@ memoize(this, "Commands", function () {
var FailedAssertion = Class("FailedAssertion", ErrorBase); var FailedAssertion = Class("FailedAssertion", ErrorBase);
var Point = Struct("x", "y"); var Point = Struct("x", "y");
var wrapCallback = function wrapCallback(fn) var wrapCallback = function wrapCallback(fn) {
fn.wrapper = (function wrappedCallback () { fn.wrapper = function wrappedCallback () {
try { try {
return fn.apply(this, arguments); return fn.apply(this, arguments);
} }
@@ -41,7 +41,10 @@ var wrapCallback = function wrapCallback(fn)
util.reportError(e); util.reportError(e);
return undefined; return undefined;
} }
}) };
fn.wrapper.wrapped = fn;
return fn.wrapper;
}
var getAttr = function getAttr(elem, ns, name) var getAttr = function getAttr(elem, ns, name)
elem.hasAttributeNS(ns, name) ? elem.getAttributeNS(ns, name) : null; elem.hasAttributeNS(ns, name) ? elem.getAttributeNS(ns, name) : null;
@@ -1585,6 +1588,8 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
})(); })();
}, },
wrapCallback: wrapCallback,
/** /**
* Traps errors in the called function, possibly reporting them. * Traps errors in the called function, possibly reporting them.
* *