diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 06756fad..04b4e38d 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -162,7 +162,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { template.usage(results, params.format)); }, { - argCount: "*", + argCount: "0", completer: function (context, args) { context.keys.text = util.identity; context.keys.description = function () seen[this.text] + " matching items"; @@ -1176,14 +1176,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { * @see Commands#parseArgs */ parseCommandLine: function (cmdline) { - const options = [ - [["+u"], CommandOption.STRING], - [["++noplugin"], CommandOption.NOARG], - [["++cmd"], CommandOption.STRING, null, null, true], - [["+c"], CommandOption.STRING, null, null, true] - ].map(CommandOption.fromArray, CommandOption); try { - return commands.parseArgs(cmdline, { options: options, argCount: "*" }); + return commands.get("rehash").parseArgs(cmdline); } catch (e) { dactyl.reportError(e, true); @@ -1688,15 +1682,32 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { filter: function ({ item }) !item.userDisabled, perm: "disable" }, + { + name: "extr[ehash]", + description: "Reload an extension", + action: function (addon) { + dactyl.assert(dactyl.has("Gecko2"), "This command is not useful in this version of " + config.host); + util.timeout(function () { + addon.userDisabled = true; + addon.userDisabled = false; + }); + }, + filter: function ({ item }) !item.userDisabled, + perm: "disable" + }, + { + name: "extt[oggle]", + description: "Toggle an extension's enabled status", + action: function (addon) addon.userDisabled = !addon.userDisabled + }, { name: "extu[pdate]", description: "Update an extension", actions: updateAddons, - filter: function ({ item }) !item.userDisabled, perm: "upgrade" } ].forEach(function (command) { - let perm = AddonManager["PERM_CAN_" + command.perm.toUpperCase()]; + let perm = command.perm && AddonManager["PERM_CAN_" + command.perm.toUpperCase()]; function ok(addon) !perm || addon.permissions & perm; commands.add([command.name], command.description, @@ -1877,7 +1888,31 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { commands.add(["reh[ash]"], "Reload the " + config.appName + " add-on", - function () { util.rehash(); }); + function (args) { util.rehash(args); }, + { + argCount: "0", + options: [ + { + names: ["+u"], + description: "The initialization file to execute at startup", + type: CommandOption.STRING + }, + { + names: ["++noplugin"], + description: "Do not automatically load plugins" + }, + { + names: ["++cmd"], + description: "Ex commands to execute prior to initialization", + multiple: true + }, + { + names: ["+c"], + description: "Ex commands to execute after initialization", + multiple: true + } + ] + }); commands.add(["res[tart]"], "Force " + config.appName + " to restart", @@ -2106,10 +2141,15 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { if (!services.commandLineHandler) services.add("commandLineHandler", "@mozilla.org/commandlinehandler/general-startup;1?type=" + config.name); - if (services.commandLineHandler) { - let commandline = services.commandLineHandler.optionValue; - if (commandline) { - let args = dactyl.parseCommandLine(commandline); + try { + if (services.fuel) + var args = services.fuel.storage.get("dactyl.commandlineArgs", null); + if (!args) { + let commandline = services.commandLineHandler.optionValue; + if (commandline) + args = dactyl.parseCommandLine(commandline); + } + if (args) { dactyl.commandLineOptions.rcFile = args["+u"]; dactyl.commandLineOptions.noPlugins = "++noplugin" in args; dactyl.commandLineOptions.postCommands = args["+c"]; @@ -2117,6 +2157,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { util.dump("Processing command-line option: " + commandline); } } + catch (e) { + dactyl.echoerr("Parsing command line options: " + e); + } dactyl.log("Command-line options: " + util.objectToString(dactyl.commandLineOptions), 3); diff --git a/common/locale/en-US/browsing.xml b/common/locale/en-US/browsing.xml index 2fa669ff..3fc85879 100644 --- a/common/locale/en-US/browsing.xml +++ b/common/locale/en-US/browsing.xml @@ -358,6 +358,28 @@ want to bypass &dactyl.appName;'s key handling and pass keys directly to + + :reh :rehash + :rehash arg + +

+ Reload the &dactyl.appName; add-on, including all code, plugins, + and configuration. For users running directly from the development + repository, this is a good way to update to the latest version or + to test your changes. +

+

+ Any arguments supplied are parsed as command line arguments as + specified in startup-options. +

+ + Not all plugins are designed to cleanly un-apply during a rehash. + While official plugins are safe, beware of possibility instability + if you rehash while running third-party plugins. + +
+
+ :re :reload :reload! diff --git a/common/locale/en-US/gui.xml b/common/locale/en-US/gui.xml index 0db9b588..25c34fb6 100644 --- a/common/locale/en-US/gui.xml +++ b/common/locale/en-US/gui.xml @@ -153,10 +153,33 @@ + + :extr :extrehash + :extrehash extension + :extrehash + +

+ Toggle an extension's enabled status twice. This is useful for rebooting + a restartless extension. +

+
+
+ + + :extt :exttoggle + :exttoggle extension + :exttoggle + +

+ Toggle an extension's enabled status. +

+
+
+ :extu :extupdate :extupdate extension - :extupdate! + :extupdate!

Update an extension. When ! is given, update all diff --git a/common/modules/services.jsm b/common/modules/services.jsm index d9d4ad91..8c30b004 100644 --- a/common/modules/services.jsm +++ b/common/modules/services.jsm @@ -36,7 +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("fuel", "@mozilla.org/fuel/application;1", Ci.extIApplication); 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 c588df6d..a5547713 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -1187,7 +1187,9 @@ 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 () { + rehash: function (args) { + if (services.fuel) + services.fuel.storage.set("dactyl.commandlineArgs", args); this.timeout(function () { this.rehashing = true; this.addon.userDisabled = true; @@ -1443,6 +1445,8 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), */ xmlToDom: function xmlToDom(node, doc, nodes) { XML.prettyPrinting = false; + if (typeof node === "string") // Sandboxes can't currently pass us XML objects. + node = XML(node); if (node.length() != 1) { let domnode = doc.createDocumentFragment(); for each (let child in node) diff --git a/pentadactyl/NEWS b/pentadactyl/NEWS index 6d42bd9b..1bc353fa 100644 --- a/pentadactyl/NEWS +++ b/pentadactyl/NEWS @@ -64,7 +64,7 @@ * :extadd now supports remote URLs as well as local files on Firefox 4. * Added :if/:elseif/:else/:endif conditionals. - Added -keyword, -tags, -title to :delbmarks. - - Added :extupdate command. + - Added :extrehash, :exttoggle, :extupdate, and :rehash commands. - Added :feedkeys command. - Added -sort option to :history. - Added several new options, including -javascript, to :abbrev and :map.