From 92f96f9455a97de17e9234a955d91a0a276319a1 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 11 Mar 2016 00:14:42 +0000 Subject: [PATCH] Change custom object syntax, use a single prompt Take a description of the object, in , format --- src/normal.cc | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/normal.cc b/src/normal.cc index 33c813f6..f0299787 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -953,23 +953,24 @@ void select_object(Context& context, NormalParams params) if (*cp == ':') { + const bool info = show_auto_info_ifn( + "Enter object desc", "format: ,", + AutoInfo::Command, context); + context.input_handler().prompt( - "opening:", "", get_face("Prompt"), complete_nothing, - [level](StringView cmdline, PromptEvent event, Context& context) { + "object desc:", "", get_face("Prompt"), complete_nothing, + [level,info](StringView cmdline, PromptEvent event, Context& context) { + if (event != PromptEvent::Change) + hide_auto_info_ifn(context, info); if (event != PromptEvent::Validate) return; - String opening = cmdline.str(); - context.input_handler().prompt( - "closing:", "", get_face("Prompt"), complete_nothing, - [level, opening](StringView cmdline, PromptEvent event, Context& context) { - if (event != PromptEvent::Validate) - return; + Vector params = split(cmdline, ',', '\\'); + if (params.size() != 2) + throw runtime_error{"desc parsing failed, expected ,"}; - String closing = cmdline.str(); - return select(context, std::bind(select_surrounding, _1, _2, - opening, closing, level, flags)); - }); + return select(context, std::bind(select_surrounding, _1, _2, + params[0], params[1], level, flags)); }); } @@ -1012,7 +1013,7 @@ void select_object(Context& context, NormalParams params) "i: indent \n" "u: argument \n" "n: number \n" - ":: prompt for object \n"); + ":: custom object desc \n"); } template