From 275c0c67d4d15c2a275b0fab758d22a36c827677 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 22 Feb 2012 21:48:14 +0000 Subject: [PATCH] Final attribute support for DisplayAtom When DisplayAtoms have the Final attributes, highlighters may not modify them anymore. --- src/display_buffer.hh | 1 + src/highlighters.cc | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/display_buffer.hh b/src/display_buffer.hh index 8ac5381e..3f253940 100644 --- a/src/display_buffer.hh +++ b/src/display_buffer.hh @@ -30,6 +30,7 @@ enum Attributes Reverse = 2, Blink = 4, Bold = 8, + Final = 16 }; enum class Color diff --git a/src/highlighters.cc b/src/highlighters.cc index b11ef9c5..3c6bbe0a 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -51,6 +51,9 @@ void colorize_regex_range(DisplayBuffer& display_buffer, for (auto it = begin_atom_it; it != end_atom_it; ++it) { + if (it->attribute() & Attributes::Final) + continue; + it->fg_color() = fg_color; it->bg_color() = bg_color; } @@ -165,7 +168,8 @@ void show_line_numbers(DisplayBuffer& display_buffer) atom_it, DisplayAtom(atom_it->coord(), atom_it->begin(), atom_it->begin(), - Color::Black, Color::White)); + Color::Black, Color::White, + Attributes::Final)); char buffer[10]; snprintf(buffer, 10, format, coord.line + 1); @@ -219,6 +223,11 @@ public: BufferRange& sel = *sel_it; DisplayAtom& atom = *atom_it; + if (atom.attribute() & Attributes::Final) + { + ++atom_it; + continue; + } // [###------] if (atom.begin() >= sel.first and atom.begin() < sel.second and atom.end() > sel.second)