Tweak regex constructor calls
This commit is contained in:
parent
6bed464105
commit
1af82e2e24
|
@ -405,7 +405,7 @@ public:
|
||||||
DynamicRegexHighlighter(RegexGetter regex_getter, FaceGetter face_getter)
|
DynamicRegexHighlighter(RegexGetter regex_getter, FaceGetter face_getter)
|
||||||
: m_regex_getter(std::move(regex_getter)),
|
: m_regex_getter(std::move(regex_getter)),
|
||||||
m_face_getter(std::move(face_getter)),
|
m_face_getter(std::move(face_getter)),
|
||||||
m_highlighter(Regex(), FacesSpec{}) {}
|
m_highlighter(Regex{}, FacesSpec{}) {}
|
||||||
|
|
||||||
void highlight(const Context& context, HighlightFlags flags, DisplayBuffer& display_buffer, BufferRange range)
|
void highlight(const Context& context, HighlightFlags flags, DisplayBuffer& display_buffer, BufferRange range)
|
||||||
{
|
{
|
||||||
|
|
|
@ -483,7 +483,7 @@ public:
|
||||||
if (m_edit_filter)
|
if (m_edit_filter)
|
||||||
{
|
{
|
||||||
m_edit_filter = false;
|
m_edit_filter = false;
|
||||||
m_filter = Regex(".*");
|
m_filter = Regex{".*"};
|
||||||
m_filter_editor.reset("");
|
m_filter_editor.reset("");
|
||||||
context().print_status(DisplayLine{});
|
context().print_status(DisplayLine{});
|
||||||
}
|
}
|
||||||
|
@ -522,7 +522,7 @@ public:
|
||||||
m_filter_editor.handle_key(key);
|
m_filter_editor.handle_key(key);
|
||||||
|
|
||||||
auto search = ".*" + m_filter_editor.line() + ".*";
|
auto search = ".*" + m_filter_editor.line() + ".*";
|
||||||
m_filter = Regex(search.begin(), search.end());
|
m_filter = Regex{search};
|
||||||
auto it = std::find_if(m_selected, m_choices.end(), match_filter);
|
auto it = std::find_if(m_selected, m_choices.end(), match_filter);
|
||||||
if (it == m_choices.end())
|
if (it == m_choices.end())
|
||||||
it = std::find_if(m_choices.begin(), m_selected, match_filter);
|
it = std::find_if(m_choices.begin(), m_selected, match_filter);
|
||||||
|
@ -562,7 +562,7 @@ private:
|
||||||
m_callback(selected, MenuEvent::Select, context());
|
m_callback(selected, MenuEvent::Select, context());
|
||||||
}
|
}
|
||||||
|
|
||||||
Regex m_filter = Regex(".*");
|
Regex m_filter = Regex{".*"};
|
||||||
bool m_edit_filter = false;
|
bool m_edit_filter = false;
|
||||||
LineEditor m_filter_editor;
|
LineEditor m_filter_editor;
|
||||||
};
|
};
|
||||||
|
|
|
@ -592,9 +592,8 @@ void regex_prompt(Context& context, const String prompt, T func)
|
||||||
|
|
||||||
if (event == PromptEvent::Validate)
|
if (event == PromptEvent::Validate)
|
||||||
context.push_jump();
|
context.push_jump();
|
||||||
Regex regex = str.empty() ? Regex{}
|
|
||||||
: Regex{str.begin(), str.end()};
|
func(str.empty() ? Regex{} : Regex{str}, event, context);
|
||||||
func(std::move(regex), event, context);
|
|
||||||
}
|
}
|
||||||
catch (regex_error& err)
|
catch (regex_error& err)
|
||||||
{
|
{
|
||||||
|
@ -620,7 +619,7 @@ void search(Context& context, NormalParams)
|
||||||
regex_prompt(context, direction == Forward ? "search:" : "reverse search:",
|
regex_prompt(context, direction == Forward ? "search:" : "reverse search:",
|
||||||
[](Regex ex, PromptEvent event, Context& context) {
|
[](Regex ex, PromptEvent event, Context& context) {
|
||||||
if (ex.empty())
|
if (ex.empty())
|
||||||
ex = Regex{context.main_sel_register_value("/").str()};
|
ex = Regex{context.main_sel_register_value("/")};
|
||||||
else if (event == PromptEvent::Validate)
|
else if (event == PromptEvent::Validate)
|
||||||
RegisterManager::instance()['/'] = ex.str();
|
RegisterManager::instance()['/'] = ex.str();
|
||||||
if (not ex.empty() and not ex.str().empty())
|
if (not ex.empty() and not ex.str().empty())
|
||||||
|
@ -634,7 +633,7 @@ void search_next(Context& context, NormalParams params)
|
||||||
StringView str = context.main_sel_register_value("/");
|
StringView str = context.main_sel_register_value("/");
|
||||||
if (not str.empty())
|
if (not str.empty())
|
||||||
{
|
{
|
||||||
Regex ex{str.begin(), str.end()};
|
Regex ex{str};
|
||||||
do {
|
do {
|
||||||
select_next_match<direction, mode>(context.buffer(), context.selections(), ex);
|
select_next_match<direction, mode>(context.buffer(), context.selections(), ex);
|
||||||
} while (--params.count > 0);
|
} while (--params.count > 0);
|
||||||
|
@ -679,7 +678,7 @@ void select_regex(Context& context, NormalParams)
|
||||||
{
|
{
|
||||||
regex_prompt(context, "select:", [](Regex ex, PromptEvent event, Context& context) {
|
regex_prompt(context, "select:", [](Regex ex, PromptEvent event, Context& context) {
|
||||||
if (ex.empty())
|
if (ex.empty())
|
||||||
ex = Regex{context.main_sel_register_value("/").str()};
|
ex = Regex{context.main_sel_register_value("/")};
|
||||||
else if (event == PromptEvent::Validate)
|
else if (event == PromptEvent::Validate)
|
||||||
RegisterManager::instance()['/'] = ex.str();
|
RegisterManager::instance()['/'] = ex.str();
|
||||||
if (not ex.empty() and not ex.str().empty())
|
if (not ex.empty() and not ex.str().empty())
|
||||||
|
@ -691,7 +690,7 @@ void split_regex(Context& context, NormalParams)
|
||||||
{
|
{
|
||||||
regex_prompt(context, "split:", [](Regex ex, PromptEvent event, Context& context) {
|
regex_prompt(context, "split:", [](Regex ex, PromptEvent event, Context& context) {
|
||||||
if (ex.empty())
|
if (ex.empty())
|
||||||
ex = Regex{context.main_sel_register_value("/").str()};
|
ex = Regex{context.main_sel_register_value("/")};
|
||||||
else if (event == PromptEvent::Validate)
|
else if (event == PromptEvent::Validate)
|
||||||
RegisterManager::instance()['/'] = ex.str();
|
RegisterManager::instance()['/'] = ex.str();
|
||||||
if (not ex.empty() and not ex.str().empty())
|
if (not ex.empty() and not ex.str().empty())
|
||||||
|
|
|
@ -13,7 +13,7 @@ String option_to_string(const Regex& re)
|
||||||
|
|
||||||
void option_from_string(StringView str, Regex& re)
|
void option_from_string(StringView str, Regex& re)
|
||||||
{
|
{
|
||||||
re = Regex{str.begin(), str.end()};
|
re = Regex{str};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ std::pair<String, int> ShellManager::eval(
|
||||||
void ShellManager::register_env_var(StringView regex,
|
void ShellManager::register_env_var(StringView regex,
|
||||||
EnvVarRetriever retriever)
|
EnvVarRetriever retriever)
|
||||||
{
|
{
|
||||||
m_env_vars.push_back({ Regex(regex.begin(), regex.end()), std::move(retriever) });
|
m_env_vars.push_back({ Regex{regex}, std::move(retriever) });
|
||||||
}
|
}
|
||||||
|
|
||||||
String ShellManager::get_val(StringView name, const Context& context) const
|
String ShellManager::get_val(StringView name, const Context& context) const
|
||||||
|
|
Loading…
Reference in New Issue
Block a user