select and split operations use the search pattern register
This commit is contained in:
parent
02b01e2f0a
commit
682e4faff0
28
src/main.cc
28
src/main.cc
|
@ -269,18 +269,34 @@ void do_paste(Context& context)
|
||||||
void do_select_regex(Context& context)
|
void do_select_regex(Context& context)
|
||||||
{
|
{
|
||||||
context.input_handler().prompt("select: ", complete_nothing,
|
context.input_handler().prompt("select: ", complete_nothing,
|
||||||
[](const String& ex, PromptEvent event, Context& context) {
|
[](const String& str, PromptEvent event, Context& context) {
|
||||||
if (event == PromptEvent::Validate and not ex.empty())
|
if (event == PromptEvent::Validate)
|
||||||
context.editor().multi_select(std::bind(select_all_matches, _1, ex));
|
{
|
||||||
|
String ex = str;
|
||||||
|
if (ex.empty())
|
||||||
|
ex = RegisterManager::instance()['/'].values(context)[0];
|
||||||
|
else
|
||||||
|
RegisterManager::instance()['/'] = ex;
|
||||||
|
if (not ex.empty())
|
||||||
|
context.editor().multi_select(std::bind(select_all_matches, _1, ex));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_split_regex(Context& context)
|
void do_split_regex(Context& context)
|
||||||
{
|
{
|
||||||
context.input_handler().prompt("split: ", complete_nothing,
|
context.input_handler().prompt("split: ", complete_nothing,
|
||||||
[](const String& ex, PromptEvent event, Context& context) {
|
[](const String& str, PromptEvent event, Context& context) {
|
||||||
if (event == PromptEvent::Validate and not ex.empty())
|
if (event == PromptEvent::Validate)
|
||||||
context.editor().multi_select(std::bind(split_selection, _1, ex));
|
{
|
||||||
|
String ex = str;
|
||||||
|
if (ex.empty())
|
||||||
|
ex = RegisterManager::instance()['/'].values(context)[0];
|
||||||
|
else
|
||||||
|
RegisterManager::instance()['/'] = ex;
|
||||||
|
if (not ex.empty())
|
||||||
|
context.editor().multi_select(std::bind(split_selection, _1, ex));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user