summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2016-08-27 10:54:52 +0100
committerMaxime Coste <frrrwww@gmail.com>2016-08-27 10:55:07 +0100
commit85f54a77acd7844dd2f6db4a10428301cbc6c7cf (patch)
treefb80eaa758a3cc4cf8e6c9d8b66548db1d7efa57 /src
parent2bf100bdd0522f1427fc6da5ac093895a3c80ce0 (diff)
Display the capture used in select/split prompt
Fixes #770
Diffstat (limited to 'src')
-rw-r--r--src/normal.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/normal.cc b/src/normal.cc
index 49aab27f..f7efdfa7 100644
--- a/src/normal.cc
+++ b/src/normal.cc
@@ -590,12 +590,12 @@ void paste_all(Context& context, NormalParams params)
}
template<typename T>
-void regex_prompt(Context& context, const String prompt, T func)
+void regex_prompt(Context& context, String prompt, T func)
{
CharCoord position = context.has_window() ? context.window().position() : CharCoord{};
SelectionList selections = context.selections();
context.input_handler().prompt(
- prompt, "", get_face("Prompt"), PromptFlags::None, complete_nothing,
+ std::move(prompt), "", get_face("Prompt"), PromptFlags::None, complete_nothing,
[=](StringView str, PromptEvent event, Context& context) mutable {
try
{
@@ -716,7 +716,9 @@ void select_regex(Context& context, NormalParams params)
{
const char reg = to_lower(params.reg ? params.reg : '/');
unsigned capture = (unsigned)params.count;
- regex_prompt(context, "select:", [reg, capture](Regex ex, PromptEvent event, Context& context) {
+ auto prompt = capture ? format("select (capture {}):", capture) : "select:"_str;
+ regex_prompt(context, std::move(prompt),
+ [reg, capture](Regex ex, PromptEvent event, Context& context) {
if (ex.empty())
ex = Regex{context.main_sel_register_value(reg)};
else if (event == PromptEvent::Validate)
@@ -730,7 +732,9 @@ void split_regex(Context& context, NormalParams params)
{
const char reg = to_lower(params.reg ? params.reg : '/');
unsigned capture = (unsigned)params.count;
- regex_prompt(context, "split:", [reg, capture](Regex ex, PromptEvent event, Context& context) {
+ auto prompt = capture ? format("split (on capture {}):", capture) : "split:"_str;
+ regex_prompt(context, std::move(prompt),
+ [reg, capture](Regex ex, PromptEvent event, Context& context) {
if (ex.empty())
ex = Regex{context.main_sel_register_value(reg)};
else if (event == PromptEvent::Validate)