From ea2aeea3a497fa6183d25981dc5f1e58e0b7f03c Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 24 Nov 2011 19:11:58 +0000 Subject: [PATCH] Filters: generalize colorize_regex in colorize_regex_range --- src/filters.cc | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/filters.cc b/src/filters.cc index 1b75fbe7..a4c03d73 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -9,12 +9,16 @@ namespace Kakoune { -void colorize_regex(DisplayBuffer& display_buffer, - const boost::regex& ex, - Color fg_color, Color bg_color = Color::Default) +void colorize_regex_range(DisplayBuffer& display_buffer, + const BufferIterator& range_begin, + const BufferIterator& range_end, + const boost::regex& ex, + Color fg_color, Color bg_color = Color::Default) { - BufferIterator display_begin = display_buffer.begin()->begin(); - BufferIterator display_end = display_buffer.back().end(); + BufferIterator display_begin = std::max(range_begin, + display_buffer.front().begin()); + BufferIterator display_end = std::min(range_end, + display_buffer.back().end()); boost::regex_iterator re_it(display_begin, display_end, ex, boost::match_nosubs); @@ -48,6 +52,14 @@ void colorize_regex(DisplayBuffer& display_buffer, } } +void colorize_regex(DisplayBuffer& display_buffer, + const boost::regex& ex, + Color fg_color, Color bg_color = Color::Default) +{ + colorize_regex_range(display_buffer, display_buffer.front().begin(), + display_buffer.back().end(), ex, fg_color, bg_color); +} + Color parse_color(const std::string& color) { if (color == "default") return Color::Default;