1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 08:38:00 +01:00

Also add completion.option, just for the hell of it.

This commit is contained in:
Kris Maglione
2008-11-28 08:26:45 +00:00
parent 9415926d75
commit 0cfa5857fc
2 changed files with 17 additions and 19 deletions

View File

@@ -1338,7 +1338,14 @@ function Completion() //{{{
menuItem: function menuItem(filter) commands.get("emenu").completer(filter), // XXX
option: function option(filter) commands.get("set").completer(filter), // XXX
option: function option(context, scope)
{
context.title = ["Option"];
context.keys = { text: "names", description: "description" };
context.completions = options;
if (scope)
context.filters.push(function ({item: opt}) opt.scope & scope);
},
optionValue: function (context, name, op, curValue)
{

View File

@@ -685,30 +685,21 @@ function Options() //{{{
return;
}
let prefix = (filter.match(/^(no|inv)/) || [""])[0];
let opt = options.parseOpt(filter, modifiers);
let prefix = opt.prefix;
if (prefix)
context.filter = filter = filter.substr(prefix.length);
context.advance(prefix.length);
let scope = modifiers && modifiers.scope || options.OPTION_SCOPE_BOTH;
let opts = (opt for (opt in options)
if ((opt.scope & scope) &&
(!prefix || opt.type == "boolean" ||
prefix == "inv" && opt.value instanceof Array)));
if (filter.indexOf("=") == -1)
if (context.filter.indexOf("=") == -1)
{
context.title = ["Option"];
context.quote = [prefix, util.identity, ""];
context.keys = { text: "names", description: "description" };
context.completions = opts;
return;
if (prefix)
context.filters.push(function ({item: opt}) opt.type == "boolean" || prefix == "inv" && opt.values instanceof Array);
return completion.option(context, opt.scope);
}
else if (prefix == "no")
return;
let [name, value] = filter.split("=", 2);
let opt = options.parseOpt(filter, modifiers);
let [name, value] = context.filter.split("=", 2);
let option = opt.option;
context.advance(name.length + 1);
@@ -915,7 +906,7 @@ function Options() //{{{
let matches, prefix, postfix, valueGiven;
[matches, prefix, ret.name, postfix, valueGiven, ret.operator, ret.value] =
args.match(/^\s*(no|inv)?([a-z_]+)([?&!])?\s*(([-+^]?)=(.*))?\s*$/) || [];
args.match(/^\s*(no|inv)?([a-z_]*)([?&!])?\s*(([-+^]?)=(.*))?\s*$/) || [];
ret.args = args;
ret.onlyNonDefault = false; // used for :set to print non-default options