Merge remote-tracking branch 'Screwtapello/support-user-map-options'
This commit is contained in:
commit
df655422d1
|
@ -77,10 +77,13 @@ are exclusively available to built-in options.
|
|||
|
||||
*coord*::
|
||||
a line, column pair (separated by a comma)
|
||||
Cannot be used with `declare-option`
|
||||
|
||||
*<type>-list*::
|
||||
a list, elements are specified as separate arguments to the command.
|
||||
`set -add` appends the new element to the list
|
||||
Only `int-list` and `str-list` options can be created with
|
||||
`declare-option`.
|
||||
|
||||
*range-specs*::
|
||||
a list of a pair of a buffer range (`<begin line>.<begin column>,
|
||||
|
@ -110,16 +113,19 @@ are exclusively available to built-in options.
|
|||
|
||||
*enum(value1|value2|...)*::
|
||||
an enum, taking one of the given values
|
||||
Cannot be used with `declare-option`
|
||||
|
||||
*flags(value1|value2|...)*::
|
||||
a set of flags, taking a combination of the given values joined by a
|
||||
'|' character.
|
||||
`set -add` adds the new flag to the combination
|
||||
Cannot be used with `declare-option`
|
||||
|
||||
*<type>-to-<type>-map*::
|
||||
a list of `key=value` pairs.
|
||||
`set -add` adds the new pair to the hashmap or replace an already
|
||||
existing key.
|
||||
Only `str-to-str-map` options can be created with `declare-option`.
|
||||
|
||||
== Builtin options
|
||||
|
||||
|
|
|
@ -1448,7 +1448,8 @@ const CommandDesc declare_option_cmd = {
|
|||
" str-list: list of character strings\n"
|
||||
" completions: list of completion candidates\n"
|
||||
" line-specs: list of line specs\n"
|
||||
" range-specs: list of range specs\n",
|
||||
" range-specs: list of range specs\n"
|
||||
" str-to-str-map: map from strings to strings\n",
|
||||
ParameterDesc{
|
||||
{ { "hidden", { false, "do not display option name when completing" } },
|
||||
{ "docstring", { true, "specify option description" } } },
|
||||
|
@ -1459,7 +1460,7 @@ const CommandDesc declare_option_cmd = {
|
|||
make_completer(
|
||||
[](const Context& context, CompletionFlags flags,
|
||||
const String& prefix, ByteCount cursor_pos) -> Completions {
|
||||
auto c = {"int", "bool", "str", "regex", "int-list", "str-list", "completions", "line-specs", "range-specs"};
|
||||
auto c = {"int", "bool", "str", "regex", "int-list", "str-list", "completions", "line-specs", "range-specs", "str-to-str-map"};
|
||||
return { 0_byte, cursor_pos, complete(prefix, cursor_pos, c) };
|
||||
}),
|
||||
[](const ParametersParser& parser, Context& context, const ShellContext&)
|
||||
|
@ -1492,6 +1493,8 @@ const CommandDesc declare_option_cmd = {
|
|||
opt = ®.declare_option<TimestampedList<LineAndSpec>>(parser[1], docstring, {}, flags);
|
||||
else if (parser[0] == "range-specs")
|
||||
opt = ®.declare_option<TimestampedList<RangeAndString>>(parser[1], docstring, {}, flags);
|
||||
else if (parser[0] == "str-to-str-map")
|
||||
opt = ®.declare_option<HashMap<String, String, MemoryDomain::Options>>(parser[1], docstring, {}, flags);
|
||||
else
|
||||
throw runtime_error(format("no such option type: '{}'", parser[0]));
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user