Change custom object syntax, use a single prompt

Take a description of the object, in <open>,<close> format
This commit is contained in:
Maxime Coste 2016-03-11 00:14:42 +00:00
parent 428b18c0c1
commit 92f96f9455

View File

@ -953,23 +953,24 @@ void select_object(Context& context, NormalParams params)
if (*cp == ':') if (*cp == ':')
{ {
const bool info = show_auto_info_ifn(
"Enter object desc", "format: <open text>,<close text>",
AutoInfo::Command, context);
context.input_handler().prompt( context.input_handler().prompt(
"opening:", "", get_face("Prompt"), complete_nothing, "object desc:", "", get_face("Prompt"), complete_nothing,
[level](StringView cmdline, PromptEvent event, Context& context) { [level,info](StringView cmdline, PromptEvent event, Context& context) {
if (event != PromptEvent::Change)
hide_auto_info_ifn(context, info);
if (event != PromptEvent::Validate) if (event != PromptEvent::Validate)
return; return;
String opening = cmdline.str(); Vector<String> params = split(cmdline, ',', '\\');
context.input_handler().prompt( if (params.size() != 2)
"closing:", "", get_face("Prompt"), complete_nothing, throw runtime_error{"desc parsing failed, expected <open>,<close>"};
[level, opening](StringView cmdline, PromptEvent event, Context& context) {
if (event != PromptEvent::Validate)
return;
String closing = cmdline.str(); return select<mode>(context, std::bind(select_surrounding, _1, _2,
return select<mode>(context, std::bind(select_surrounding, _1, _2, params[0], params[1], level, flags));
opening, closing, level, flags));
});
}); });
} }
@ -1012,7 +1013,7 @@ void select_object(Context& context, NormalParams params)
"i: indent \n" "i: indent \n"
"u: argument \n" "u: argument \n"
"n: number \n" "n: number \n"
":: prompt for object \n"); ":: custom object desc \n");
} }
template<Direction direction, bool half = false> template<Direction direction, bool half = false>