select and split operations use the search pattern register

This commit is contained in:
Maxime Coste 2013-02-20 14:04:46 +01:00
parent 02b01e2f0a
commit 682e4faff0

View File

@ -269,18 +269,34 @@ void do_paste(Context& context)
void do_select_regex(Context& context)
{
context.input_handler().prompt("select: ", complete_nothing,
[](const String& ex, PromptEvent event, Context& context) {
if (event == PromptEvent::Validate and not ex.empty())
context.editor().multi_select(std::bind(select_all_matches, _1, ex));
[](const String& str, PromptEvent event, Context& context) {
if (event == PromptEvent::Validate)
{
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)
{
context.input_handler().prompt("split: ", complete_nothing,
[](const String& ex, PromptEvent event, Context& context) {
if (event == PromptEvent::Validate and not ex.empty())
context.editor().multi_select(std::bind(split_selection, _1, ex));
[](const String& str, PromptEvent event, Context& context) {
if (event == PromptEvent::Validate)
{
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));
}
});
}