1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 11:47:58 +01:00

[bootstrap] Add a :rehash (temporarily undocumented) command.

--HG--
branch : bootstrapped
This commit is contained in:
Kris Maglione
2010-12-25 09:46:07 -05:00
parent a759ab3606
commit 8da718d47b
5 changed files with 23 additions and 3 deletions

2
common/bootstrap.js vendored
View File

@@ -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) {

View File

@@ -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;
},

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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) {