actions: respect regular expression config when searching in text fields

This commit is contained in:
Andrzej Rybczak
2015-05-17 16:30:11 +02:00
parent 12db40849c
commit c68631b2f0
4 changed files with 8 additions and 8 deletions

1
NEWS
View File

@@ -23,6 +23,7 @@ ncmpcpp-0.7 (????-??-??)
* Selecting items no longer depends on space mode and is bound by default to Insert key. * Selecting items no longer depends on space mode and is bound by default to Insert key.
* Support for Alt, Ctrl and Shift modifiers as well as Escape key was added. * Support for Alt, Ctrl and Shift modifiers as well as Escape key was added.
* Action that updates the environment can now be used in bindings configuration file. * Action that updates the environment can now be used in bindings configuration file.
* Searching in text fields now respects regular expression configuration.
ncmpcpp-0.6.4 (2015-05-02) ncmpcpp-0.6.4 (2015-05-02)

View File

@@ -1812,7 +1812,7 @@ void Find::run()
Statusbar::print("Searching..."); Statusbar::print("Searching...");
auto s = static_cast<Screen<NC::Scrollpad> *>(myScreen); auto s = static_cast<Screen<NC::Scrollpad> *>(myScreen);
s->main().removeProperties(); s->main().removeProperties();
if (token.empty() || s->main().setProperties(NC::Format::Reverse, token, NC::Format::NoReverse)) if (token.empty() || s->main().setProperties(NC::Format::Reverse, token, NC::Format::NoReverse, Config.regex_type))
Statusbar::print("Done"); Statusbar::print("Done");
else else
Statusbar::print("No matching patterns found"); Statusbar::print("No matching patterns found");

View File

@@ -27,7 +27,7 @@
namespace { namespace {
template <typename PropT> template <typename PropT>
bool regexSearch(NC::Buffer &buf, PropT begin, const std::string &ws, PropT end, size_t id, boost::regex::flag_type flags) bool regexSearch(NC::Buffer &buf, PropT begin, const std::string &ws, PropT end, boost::regex::flag_type flags, size_t id)
{ {
try { try {
boost::regex rx(ws, flags); boost::regex rx(ws, flags);
@@ -273,14 +273,14 @@ void Scrollpad::reset()
m_beginning = 0; m_beginning = 0;
} }
bool Scrollpad::setProperties(Color begin, const std::string &s, Color end, size_t id, boost::regex::flag_type flags) bool Scrollpad::setProperties(Color begin, const std::string &s, Color end, size_t flags, size_t id)
{ {
return regexSearch(m_buffer, std::move(begin), s, std::move(end), id, flags); return regexSearch(m_buffer, std::move(begin), s, std::move(end), id, flags);
} }
bool Scrollpad::setProperties(Format begin, const std::string &s, Format end, size_t id, boost::regex::flag_type flags) bool Scrollpad::setProperties(Format begin, const std::string &s, Format end, size_t flags, size_t id)
{ {
return regexSearch(m_buffer, begin, s, end, id, flags); return regexSearch(m_buffer, begin, s, end, flags, id);
} }
void Scrollpad::removeProperties(size_t id) void Scrollpad::removeProperties(size_t id)

View File

@@ -21,7 +21,6 @@
#ifndef NCMPCPP_SCROLLPAD_H #ifndef NCMPCPP_SCROLLPAD_H
#define NCMPCPP_SCROLLPAD_H #define NCMPCPP_SCROLLPAD_H
#include <boost/regex.hpp>
#include "window.h" #include "window.h"
#include "strbuffer.h" #include "strbuffer.h"
@@ -47,8 +46,8 @@ struct Scrollpad: public Window
void flush(); void flush();
void reset(); void reset();
bool setProperties(Color begin, const std::string &s, Color end, size_t id = -2, boost::regex::flag_type flags = boost::regex::icase); bool setProperties(Color begin, const std::string &s, Color end, size_t flags, size_t id = -2);
bool setProperties(Format begin, const std::string &s, Format end, size_t id = -2, boost::regex::flag_type flags = boost::regex::icase); bool setProperties(Format begin, const std::string &s, Format end, size_t flags, size_t id = -2);
void removeProperties(size_t id = -2); void removeProperties(size_t id = -2);
template <typename ItemT> template <typename ItemT>