From 8da718d47b7823678621527af304475709439bc6 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Sat, 25 Dec 2010 09:46:07 -0500 Subject: [PATCH] [bootstrap] Add a :rehash (temporarily undocumented) command. --HG-- branch : bootstrapped --- common/bootstrap.js | 2 ++ common/content/commandline.js | 4 ++++ common/content/dactyl.js | 7 +++++-- common/modules/services.jsm | 1 + common/modules/util.jsm | 12 +++++++++++- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/common/bootstrap.js b/common/bootstrap.js index 68954ad9..a3f2ac97 100755 --- a/common/bootstrap.js +++ b/common/bootstrap.js @@ -41,6 +41,7 @@ let addon = null; let basePath = null; let components = {}; let getURI = null; +storage.set("dactyl.bootstrap", this); var JSMLoader = storage.get("dactyl.JSMLoader", { get load() Cu.import }); function startup(data, reason) { @@ -53,6 +54,7 @@ function startup(data, reason) { dump("dactyl: bootstrap: init" + " " + data.id + "\n"); addon = data; + AddonManager.getAddonByID(addon.id, function (a) { addon = a }); if (basePath.isDirectory()) getURI = function getURI(path) { diff --git a/common/content/commandline.js b/common/content/commandline.js index 3498ca1b..eb79c3ef 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -255,6 +255,8 @@ const CommandWidgets = Class("CommandWidgets", { let elem = this.multilineOutput; elem.contentWindow.addEventListener("unload", function (event) { event.preventDefault(); }, true); elem.contentDocument.body.id = "dactyl-multiline-output-content"; + elem.__defineGetter__("atEnd", function () + !Buffer.isScrollable(elem.contentDocument.documentElement, 1)); ["copy", "copylink", "selectall"].forEach(function (tail) { // some host apps use "hostPrefixContext-copy" ids @@ -617,6 +619,8 @@ const CommandLine = Module("commandline", { this.widgets.message = null; if (modes.main != modes.COMMAND_LINE) this.widgets.command = null; + if ((modes.extended & modes.OUTPUT_MULTILINE) && this.widgets.multilineOutput.atEnd) + modes.pop(); if (modes.extended != modes.OUTPUT_MULTILINE) this.multilineOutputVisible = false; }, diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 3afd5310..3d1fae24 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -1865,10 +1865,13 @@ const Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), bang: true }); + commands.add(["reh[ash]"], + "Reload the " + config.appName + " add-on", + function () { util.rehash(); }); + commands.add(["res[tart]"], "Force " + config.appName + " to restart", - function () { dactyl.restart(); }, - { argCount: "0" }); + function () { dactyl.restart(); }); var toolbox = document.getElementById("navigator-toolbox"); if (toolbox) { diff --git a/common/modules/services.jsm b/common/modules/services.jsm index da3faf17..d9d4ad91 100644 --- a/common/modules/services.jsm +++ b/common/modules/services.jsm @@ -36,6 +36,7 @@ var Services = Module("Services", { this.add("extensionManager", "@mozilla.org/extensions/manager;1", Ci.nsIExtensionManager); this.add("favicon", "@mozilla.org/browser/favicon-service;1", Ci.nsIFaviconService); this.add("focus", "@mozilla.org/focus-manager;1", Ci.nsIFocusManager); + this.add("fuel", "@mozilla.org/fuel/application;1", Ci.fuelIApplication); this.add("history", "@mozilla.org/browser/global-history;2", [Ci.nsIBrowserHistory, Ci.nsIGlobalHistory3, Ci.nsINavHistoryService, Ci.nsPIPlacesDatabase]); this.add("io", "@mozilla.org/network/io-service;1", Ci.nsIIOService); diff --git a/common/modules/util.jsm b/common/modules/util.jsm index 26e56e7a..82bb0009 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -59,6 +59,8 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), } }, + get addon() services.fuel.storage.get("dactyl.bootstrap", null).addon, + // FIXME: Only works for Pentadactyl get activeWindow() services.windowMediator.getMostRecentWindow("navigator:browser"), dactyl: update(function dactyl(obj) { @@ -920,7 +922,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), services.observer.removeObserver(this, "dactyl-rehash"); util.dump("dactyl: util: observe: dactyl-rehash"); - if (true) + if (this.rehashing) JSMLoader.purge(); else for (let module in values(defineModule.modules)) { @@ -1144,6 +1146,14 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), getSource: function regexp_getSource(re) re.source.replace(/\\(.)/g, function (m0, m1) m1 === "/" ? "/" : m0) }), + rehash: function () { + this.rehashing = true; + this.addon.userDisabled = true; + this.timeout(function () { + this.addon.userDisabled = false; + }); + }, + maxErrors: 15, errors: Class.memoize(function () []), reportError: function (error) {