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

Add -pentadactyl-remote command-line flag and CommandOption.STRINGMAP type.

--HG--
extra : rebase_source : a306ad6e8c2d019b92a6ff58414eb3ff8ab149b9
This commit is contained in:
Kris Maglione
2011-08-12 17:27:46 -04:00
parent 0bcba9fb23
commit 5e86f4ed93
8 changed files with 42 additions and 5 deletions

View File

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

View File

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

View File

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

View File

@@ -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/>

View File

@@ -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),
@@ -72,6 +73,11 @@ update(CommandOption, {
* @final
*/
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(" ");
},

View File

@@ -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"]

View File

@@ -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 = {};

View File

@@ -71,6 +71,7 @@
editing input fields with i_<C-i>. See :h 'editor'. [b4]
• Improved [macro-string] support, including automatic elision
of optional elements, and array subscripts. [b4][b7]
• Add -pentadactyl-remote command-line option. [b8]
• Improvements to marks:
- Marks are now stored as line and column ordinals rather than percentages. [b8]
- Marks now store the marked element and ensure its visibility when followed. [b8]