mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 11:18:00 +01:00
Allow :se foo nobar baz="Foo. No bar in this town."
This commit is contained in:
@@ -417,7 +417,7 @@ function Commands() //{{{
|
|||||||
argCount = "*";
|
argCount = "*";
|
||||||
|
|
||||||
var args = []; // parsed options
|
var args = []; // parsed options
|
||||||
args.__iterator__ = util.Array.iterator2;
|
args.__iterator__ = function () util.Array.iterator2(this);
|
||||||
args.string = str; // for access to the unparsed string
|
args.string = str; // for access to the unparsed string
|
||||||
args.literalArg = "";
|
args.literalArg = "";
|
||||||
|
|
||||||
|
|||||||
@@ -351,18 +351,18 @@ function Options() //{{{
|
|||||||
|
|
||||||
function loadPreference(name, forcedDefault, defaultBranch)
|
function loadPreference(name, forcedDefault, defaultBranch)
|
||||||
{
|
{
|
||||||
var defaultValue = null; // XXX
|
let defaultValue = null; // XXX
|
||||||
if (forcedDefault != null) // this argument sets defaults for non-user settable options (like extensions.history.comp_history)
|
if (forcedDefault != null) // this argument sets defaults for non-user settable options (like extensions.history.comp_history)
|
||||||
defaultValue = forcedDefault;
|
defaultValue = forcedDefault;
|
||||||
|
|
||||||
var branch = defaultBranch ? prefService.getDefaultBranch("") : prefService;
|
let branch = defaultBranch ? prefService.getDefaultBranch("") : prefService;
|
||||||
var type = prefService.getPrefType(name);
|
let type = prefService.getPrefType(name);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case prefService.PREF_STRING:
|
case prefService.PREF_STRING:
|
||||||
var value = branch.getComplexValue(name, Components.interfaces.nsISupportsString).data;
|
let value = branch.getComplexValue(name, Components.interfaces.nsISupportsString).data;
|
||||||
// try in case it's a localized string (will throw an exception if not)
|
// try in case it's a localized string (will throw an exception if not)
|
||||||
if (!prefService.prefIsLocked(name) && !prefService.prefHasUserValue(name) &&
|
if (!prefService.prefIsLocked(name) && !prefService.prefHasUserValue(name) &&
|
||||||
/^chrome:\/\/.+\/locale\/.+\.properties/.test(value))
|
/^chrome:\/\/.+\/locale\/.+\.properties/.test(value))
|
||||||
@@ -562,114 +562,114 @@ function Options() //{{{
|
|||||||
function (args, modifiers)
|
function (args, modifiers)
|
||||||
{
|
{
|
||||||
let bang = args.bang;
|
let bang = args.bang;
|
||||||
args = args.string;
|
if (!args.length)
|
||||||
if (bang)
|
args[0] = "all";
|
||||||
|
|
||||||
|
for (let [,arg] in args)
|
||||||
{
|
{
|
||||||
var onlyNonDefault = false;
|
if (bang)
|
||||||
if (!args)
|
|
||||||
{
|
{
|
||||||
args = "all";
|
var onlyNonDefault = false;
|
||||||
onlyNonDefault = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
let [matches, name, postfix, valueGiven, operator, value] =
|
let [matches, name, postfix, valueGiven, operator, value] =
|
||||||
args.match(/^\s*?([a-zA-Z0-9\.\-_{}]+)([?&!])?\s*(([-+^]?)=(.*))?\s*$/);
|
arg.match(/^\s*?([a-zA-Z0-9\.\-_{}]+)([?&!])?\s*(([-+^]?)=(.*))?\s*$/);
|
||||||
let reset = (postfix == "&");
|
let reset = (postfix == "&");
|
||||||
let invertBoolean = (postfix == "!");
|
let invertBoolean = (postfix == "!");
|
||||||
|
|
||||||
if (name == "all" && reset)
|
if (name == "all" && reset)
|
||||||
liberator.echoerr("You can't reset all options, it could make " + config.hostApplication + " unusable.");
|
liberator.echoerr("You can't reset all options, it could make " + config.hostApplication + " unusable.");
|
||||||
else if (name == "all")
|
else if (name == "all")
|
||||||
options.listPrefs(onlyNonDefault, "");
|
options.listPrefs(onlyNonDefault, "");
|
||||||
else if (reset)
|
else if (reset)
|
||||||
options.resetPref(name);
|
options.resetPref(name);
|
||||||
else if (invertBoolean)
|
else if (invertBoolean)
|
||||||
options.invertPref(name);
|
options.invertPref(name);
|
||||||
else if (valueGiven)
|
else if (valueGiven)
|
||||||
{
|
|
||||||
switch (value)
|
|
||||||
{
|
{
|
||||||
case undefined:
|
switch (value)
|
||||||
value = "";
|
{
|
||||||
break;
|
case undefined:
|
||||||
case "true":
|
value = "";
|
||||||
value = true;
|
break;
|
||||||
break;
|
case "true":
|
||||||
case "false":
|
value = true;
|
||||||
value = false;
|
break;
|
||||||
break;
|
case "false":
|
||||||
default:
|
value = false;
|
||||||
if (/^\d+$/.test(value))
|
break;
|
||||||
value = parseInt(value, 10);
|
default:
|
||||||
|
if (/^\d+$/.test(value))
|
||||||
|
value = parseInt(value, 10);
|
||||||
|
}
|
||||||
|
options.setPref(name, value);
|
||||||
}
|
}
|
||||||
options.setPref(name, value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
options.listPrefs(onlyNonDefault, name);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let opt = options.parseOpt(args, modifiers);
|
|
||||||
if (!opt)
|
|
||||||
{
|
|
||||||
liberator.echoerr("Error parsing :set command: " + args);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let option = opt.option;
|
|
||||||
if (option == null && !opt.all)
|
|
||||||
{
|
|
||||||
liberator.echoerr("No such option: " + opt.name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// reset a variable to its default value
|
|
||||||
if (opt.reset)
|
|
||||||
{
|
|
||||||
if (opt.all)
|
|
||||||
{
|
|
||||||
for (let option in options)
|
|
||||||
option.reset();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
option.reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// read access
|
|
||||||
else if (opt.get)
|
|
||||||
{
|
|
||||||
if (opt.all)
|
|
||||||
{
|
|
||||||
options.list(opt.onlyNonDefault, opt.scope);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (option.type == "boolean")
|
|
||||||
liberator.echo((opt.optionValue ? " " : "no") + option.name);
|
|
||||||
else
|
else
|
||||||
liberator.echo(" " + option.name + "=" + opt.optionValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// write access
|
|
||||||
// NOTE: the behavior is generally Vim compatible but could be
|
|
||||||
// improved. i.e. Vim's behavior is pretty sloppy to no real benefit
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (opt.option.type == "boolean")
|
|
||||||
{
|
|
||||||
if (opt.valueGiven)
|
|
||||||
{
|
{
|
||||||
liberator.echoerr("E474: Invalid argument: " + args);
|
options.listPrefs(onlyNonDefault, name);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
opt.values = !opt.unsetBoolean;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let opt = options.parseOpt(arg, modifiers);
|
||||||
|
if (!opt)
|
||||||
|
{
|
||||||
|
liberator.echoerr("Error parsing :set command: " + arg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let option = opt.option;
|
||||||
|
if (option == null && !opt.all)
|
||||||
|
{
|
||||||
|
liberator.echoerr("No such option: " + opt.name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// reset a variable to its default value
|
||||||
|
if (opt.reset)
|
||||||
|
{
|
||||||
|
if (opt.all)
|
||||||
|
{
|
||||||
|
for (let option in options)
|
||||||
|
option.reset();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
option.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// read access
|
||||||
|
else if (opt.get)
|
||||||
|
{
|
||||||
|
if (opt.all)
|
||||||
|
{
|
||||||
|
options.list(opt.onlyNonDefault, opt.scope);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (option.type == "boolean")
|
||||||
|
liberator.echo((opt.optionValue ? " " : "no") + option.name);
|
||||||
|
else
|
||||||
|
liberator.echo(" " + option.name + "=" + opt.optionValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// write access
|
||||||
|
// NOTE: the behavior is generally Vim compatible but could be
|
||||||
|
// improved. i.e. Vim's behavior is pretty sloppy to no real benefit
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (opt.option.type == "boolean")
|
||||||
|
{
|
||||||
|
if (opt.valueGiven)
|
||||||
|
{
|
||||||
|
liberator.echoerr("E474: Invalid argument: " + arg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
opt.values = !opt.unsetBoolean;
|
||||||
|
}
|
||||||
|
let res = opt.option.op(opt.operator || "=", opt.values, opt.scope, opt.invert);
|
||||||
|
if (res)
|
||||||
|
liberator.echoerr(res);
|
||||||
}
|
}
|
||||||
let res = opt.option.op(opt.operator || "=", opt.values, opt.scope, opt.invert);
|
|
||||||
if (res)
|
|
||||||
liberator.echoerr(res);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -684,7 +684,11 @@ function Options() //{{{
|
|||||||
if (filter[filter.length - 1] == "=")
|
if (filter[filter.length - 1] == "=")
|
||||||
{
|
{
|
||||||
context.advance(filter.length);
|
context.advance(filter.length);
|
||||||
context.completions = [options.getPref(filter.substr(0, filter.length - 1)), "Current Value"];
|
filter = filter.substr(0, filter.length - 1);
|
||||||
|
context.completions = [
|
||||||
|
[loadPreference(filter, null, false), "Current Value"],
|
||||||
|
[loadPreference(filter, null, true), "Default Value"]
|
||||||
|
];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -728,7 +732,6 @@ function Options() //{{{
|
|||||||
|
|
||||||
completion.optionValue(context, opt.name, opt.operator);
|
completion.optionValue(context, opt.name, opt.operator);
|
||||||
},
|
},
|
||||||
literal: 0,
|
|
||||||
serial: function () [
|
serial: function () [
|
||||||
{
|
{
|
||||||
command: this.name,
|
command: this.name,
|
||||||
@@ -886,7 +889,7 @@ function Options() //{{{
|
|||||||
let prefs = function () {
|
let prefs = function () {
|
||||||
for each (let pref in prefArray)
|
for each (let pref in prefArray)
|
||||||
{
|
{
|
||||||
var userValue = prefService.prefHasUserValue(pref);
|
let userValue = prefService.prefHasUserValue(pref);
|
||||||
if (onlyNonDefault && !userValue || pref.indexOf(filter) == -1)
|
if (onlyNonDefault && !userValue || pref.indexOf(filter) == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
2008-XX-XX:
|
2008-XX-XX:
|
||||||
* version 2.0 (probably)
|
* version 2.0 (probably)
|
||||||
|
* IMPORTANT: :set now sets multiple options, as in Vim. Spaces in values
|
||||||
|
must be quoted or escaped.
|
||||||
* IMPORTANT: Due to much improved autocompletion, changed default 'complete' option
|
* IMPORTANT: Due to much improved autocompletion, changed default 'complete' option
|
||||||
value to 'sfl', listing intelligent Firefox location bar results. Removed possibility
|
value to 'sfl', listing intelligent Firefox location bar results. Removed possibility
|
||||||
to use 'h' in 'complete'.
|
to use 'h' in 'complete'.
|
||||||
|
|||||||
@@ -26,36 +26,44 @@ Show all options. Show all options.
|
|||||||
____
|
____
|
||||||
|
|
||||||
|E518| |E519|
|
|E518| |E519|
|
||||||
||:se[t] {option}?||
|
||:se[t] {option}*||
|
||||||
____
|
____
|
||||||
Show value of {option}.
|
Show value of {option}.
|
||||||
____
|
____
|
||||||
|
|
||||||
||:se[t] {option}||
|
||:se[t] {option} [...]||
|
||||||
____
|
____
|
||||||
Toggle option: set, switch it on. +
|
Toggle option: set, switch it on. +
|
||||||
Number option: show value. +
|
Number option: show value. +
|
||||||
String option: show value.
|
String option: show value.
|
||||||
____
|
____
|
||||||
|
|
||||||
||:se[t] no((option))|| +
|
||:se[t] no((option)) [...]|| +
|
||||||
____
|
____
|
||||||
Toggle option: Reset, switch it off.
|
Toggle option: Reset, switch it off.
|
||||||
____
|
____
|
||||||
|
|
||||||
||:se[t] {option}!|| +
|
||:se[t] {option}! [...]|| +
|
||||||
||:se[t] inv((option))|| +
|
||:se[t] inv((option)) [...]|| +
|
||||||
____
|
____
|
||||||
Toggle option: Invert value.
|
Toggle option: Invert value.
|
||||||
____
|
____
|
||||||
|
|
||||||
||:se[t] inv((option))={value}|| +
|
||:se[t] inv((option))={value} [...]|| +
|
||||||
|
||:se[t] {option}!={value} [...]|| +
|
||||||
____
|
____
|
||||||
For list options, toggle the specified values.
|
For list options, toggle the specified values.
|
||||||
|
|
||||||
|
If the option is a list, the given values are toggled. Given
|
||||||
|
:set opt=foo,bar
|
||||||
|
Then,
|
||||||
|
:set opt!=foo,baz
|
||||||
|
results in
|
||||||
|
opt=bar,baz
|
||||||
____
|
____
|
||||||
|
|
||||||
|:set-default|
|
|:set-default|
|
||||||
||:se[t] {option}&||
|
||:se[t] {option}& [...]||
|
||||||
____
|
____
|
||||||
Reset option to its default value.
|
Reset option to its default value.
|
||||||
____
|
____
|
||||||
@@ -66,7 +74,7 @@ Set all options to their default value.
|
|||||||
____
|
____
|
||||||
|
|
||||||
|:set-args| |E487| |E521|
|
|:set-args| |E487| |E521|
|
||||||
||:se[t] {option}={value}|| +
|
||:se[t] {option}={value} [...]|| +
|
||||||
____
|
____
|
||||||
Set string or number option to {value}. +
|
Set string or number option to {value}. +
|
||||||
For numeric options the value must be given in decimal.
|
For numeric options the value must be given in decimal.
|
||||||
@@ -74,7 +82,7 @@ The old value can be inserted by typing [m]<Tab>[m].
|
|||||||
____
|
____
|
||||||
|
|
||||||
|:set+=|
|
|:set+=|
|
||||||
||:se[t] {option}+={value}|| +
|
||:se[t] {option}+={value} [...]|| +
|
||||||
____
|
____
|
||||||
Add the {value} to a number option, or append the
|
Add the {value} to a number option, or append the
|
||||||
{value} to a string option. When the option is a
|
{value} to a string option. When the option is a
|
||||||
@@ -86,7 +94,7 @@ present the option value doesn't change.
|
|||||||
____
|
____
|
||||||
|
|
||||||
|:set^=|
|
|:set^=|
|
||||||
||:se[t] {option}^={value}|| +
|
||:se[t] {option}^={value} [...]|| +
|
||||||
____
|
____
|
||||||
Multiply the {value} to a number option, or prepend
|
Multiply the {value} to a number option, or prepend
|
||||||
the {value} to a string option. When the option is a
|
the {value} to a string option. When the option is a
|
||||||
@@ -95,7 +103,7 @@ value was empty.
|
|||||||
____
|
____
|
||||||
|
|
||||||
|:set-=|
|
|:set-=|
|
||||||
||:se[t] {option}-={value}|| +
|
||:se[t] {option}-={value} [...]|| +
|
||||||
|
|
||||||
____
|
____
|
||||||
Subtract the {value} from a number option, or remove
|
Subtract the {value} from a number option, or remove
|
||||||
|
|||||||
Reference in New Issue
Block a user