diff options
author | Kris Maglione <maglione.k@gmail.com> | 2011-08-12 17:27:46 -0400 |
---|---|---|
committer | Kris Maglione <maglione.k@gmail.com> | 2011-08-12 17:27:46 -0400 |
commit | 5e86f4ed939d5eb129488995bbff7db5bf529043 (patch) | |
tree | 11b11a3fa548fe68fe9292a4779b09303c98a1a6 /common | |
parent | 0bcba9fb230abaa64bb74689285bafc448d95fb4 (diff) | |
download | pentadactyl-5e86f4ed939d5eb129488995bbff7db5bf529043.tar.gz |
Add -pentadactyl-remote command-line flag and CommandOption.STRINGMAP type.
--HG--
extra : rebase_source : a306ad6e8c2d019b92a6ff58414eb3ff8ab149b9
Diffstat (limited to 'common')
-rw-r--r-- | common/components/commandline-handler.js | 20 | ||||
-rw-r--r-- | common/content/mow.js | 2 | ||||
-rw-r--r-- | common/locale/en-US/messages.properties | 1 | ||||
-rw-r--r-- | common/locale/en-US/starting.xml | 7 | ||||
-rw-r--r-- | common/modules/commands.jsm | 8 | ||||
-rw-r--r-- | common/modules/contexts.jsm | 5 | ||||
-rw-r--r-- | common/modules/options.jsm | 3 |
7 files changed, 41 insertions, 5 deletions
diff --git a/common/components/commandline-handler.js b/common/components/commandline-handler.js index 918d7bf3..e4362d97 100644 --- a/common/components/commandline-handler.js +++ b/common/components/commandline-handler.js @@ -40,8 +40,26 @@ CommandLineHandler.prototype = { QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsICommandLineHandler]), handle: function (commandLine) { + try { + var remote = commandLine.handleFlagWithParam(config.name + "-remote", false); + } + catch (e) { + util.dump("option '-" + config.name + "-remote' requires an argument\n"); + } + + try { + if (remote) { + commandLine.preventDefault = true; + require(global, "services"); + let win = services.windowMediator.getMostRecentWindow("navigator:browser"); + if (win && win.dactyl) + win.dactyl.execute(remote); + } + } + catch(e) { + util.reportError(e) + }; - // TODO: handle remote launches differently? try { this.optionValue = commandLine.handleFlagWithParam(config.name, false); } diff --git a/common/content/mow.js b/common/content/mow.js index 5c7a28c6..bd055746 100644 --- a/common/content/mow.js +++ b/common/content/mow.js @@ -135,7 +135,7 @@ var MOW = Module("mow", { this.messages.push(data); } else { - let style = isString(data) ? "pre" : "nowrap"; + let style = isString(data) ? "pre-wrap" : "nowrap"; this.lastOutput = <div class="ex-command-output" style={"white-space: " + style} highlight={highlightGroup}>{data}</div>; var output = util.xmlToDom(this.lastOutput, this.document); diff --git a/common/locale/en-US/messages.properties b/common/locale/en-US/messages.properties index e9c29911..2c373047 100644 --- a/common/locale/en-US/messages.properties +++ b/common/locale/en-US/messages.properties @@ -236,6 +236,7 @@ mow.contextMenu.selectAll = Select All option.noSuch = No such option option.noSuch-1 = No such option: %S +option.noSuchType-1 = No such option type: %S option.replaceExisting-1 = Warning: %S already exists: replacing existing option option.intRequired = Integer value required option.operatorNotSupported-2 = Operator %S not supported for option type %S diff --git a/common/locale/en-US/starting.xml b/common/locale/en-US/starting.xml index 38935504..39e1c40e 100644 --- a/common/locale/en-US/starting.xml +++ b/common/locale/en-US/starting.xml @@ -15,11 +15,16 @@ <h2 tag="startup-options">Command-line options</h2> <p> - Command-line options can be passed to &dactyl.appName; via the -&dactyl.name; &dactyl.host; + Command-line options can be passed to &dactyl.appName; via the <em>-&dactyl.name;</em> &dactyl.host; option. These are passed as single string argument. E.g., <tt>&dactyl.hostbin; -&dactyl.name; <str><t>++cmd</t> 'set exrc' <t>+u</t> 'tempRcFile' <t>++noplugin</t></str></tt> </p> +<p> + The <em>-&dactyl.name;-remote</em> command-line option can be used to + execute a single Ex command in an already running Pentadactyl instance. +</p> + <item> <tags>+c</tags> <strut/> diff --git a/common/modules/commands.jsm b/common/modules/commands.jsm index 206dc902..95d4b2eb 100644 --- a/common/modules/commands.jsm +++ b/common/modules/commands.jsm @@ -26,6 +26,7 @@ defineModule("commands", { * @property {number} type The option's value type. This is one of: * (@link CommandOption.NOARG), * (@link CommandOption.STRING), + * (@link CommandOption.STRINGMAP), * (@link CommandOption.BOOL), * (@link CommandOption.INT), * (@link CommandOption.FLOAT), @@ -73,6 +74,11 @@ update(CommandOption, { */ STRING: ArgType("string", function (val) val), /** + * @property {object} The option accepts a stringmap argument. + * @final + */ + STRINGMAP: ArgType("stringmap", function (val, quoted) Option.parse.stringmap(quoted)), + /** * @property {object} The option accepts an integer argument. * @final */ @@ -765,7 +771,7 @@ var Commands = Module("commands", { let str = args.literalArg; if (str) res.push(!/\n/.test(str) ? str : - this.hereDoc && false ? "<<EOF\n" + String.replace(str, /\n$/, "") + "\nEOF" + this.serializeHereDoc ? "<<EOF\n" + String.replace(str, /\n$/, "") + "\nEOF" : String.replace(str, /\n/g, "\n" + res[0].replace(/./g, " ").replace(/.$/, "\\"))); return res.join(" "); }, diff --git a/common/modules/contexts.jsm b/common/modules/contexts.jsm index d7b8d7d9..9dad270b 100644 --- a/common/modules/contexts.jsm +++ b/common/modules/contexts.jsm @@ -516,8 +516,11 @@ var Contexts = Module("contexts", { group.args = args["-args"]; } - if (args.context) + if (args.context) { args.context.group = group; + if (args.context.context) + args.context.context.group = group; + } util.assert(!group.builtin || !["-description", "-locations", "-nopersist"] diff --git a/common/modules/options.jsm b/common/modules/options.jsm index b7545ec7..5b0a398b 100644 --- a/common/modules/options.jsm +++ b/common/modules/options.jsm @@ -853,6 +853,9 @@ var Options = Module("options", { */ add: function add(names, description, type, defaultValue, extraInfo) { const self = this; + util.assert(type in Option.types, + _("option.noSuchType", type), + true); if (!extraInfo) extraInfo = {}; |