summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2011-09-29 08:37:27 +0000
committerMaxime Coste <frrrwww@gmail.com>2011-09-29 08:37:27 +0000
commit822fc0f82247e4f83b3776bfd38ebbab3e7fd9d6 (patch)
treec5f39a0b397619b90bd1520fb4ba600dfeace267 /src
parentba2800ddacf69f3f9cc8389b1f1aa415cdd3fac1 (diff)
Window: add a test filter to make 'void' blink
Diffstat (limited to 'src')
-rw-r--r--src/window.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/window.cc b/src/window.cc
index 314a31c7..58a85f48 100644
--- a/src/window.cc
+++ b/src/window.cc
@@ -117,6 +117,30 @@ private:
const Window& m_window;
};
+static void blink_void(DisplayBuffer& display_buffer)
+{
+ for (auto atom_it = display_buffer.begin();
+ atom_it != display_buffer.end();)
+ {
+ DisplayAtom& atom = *atom_it;
+ size_t pos = atom.content.find("void");
+ if (pos != std::string::npos)
+ {
+ DisplayAtom prefix(atom.begin, atom.begin + pos,
+ atom.content.substr(0, pos));
+ prefix.attribute = atom.attribute;
+ DisplayAtom match(prefix.end, prefix.end + 4, "void");
+ match.attribute = atom.attribute | Attributes::Blink;
+ atom.begin = prefix.end + 4;
+ atom.content = atom.content.substr(pos + 4);
+ atom_it = display_buffer.insert(atom_it, match);
+ atom_it = display_buffer.insert(atom_it, prefix) + 2;
+ }
+ else
+ ++atom_it;
+ }
+}
+
Window::Window(Buffer& buffer)
: m_buffer(buffer),
m_position(0, 0),
@@ -125,6 +149,7 @@ Window::Window(Buffer& buffer)
m_current_inserter(nullptr)
{
m_selections.push_back(Selection(buffer.begin(), buffer.begin()));
+ m_filters.push_back(blink_void);
m_filters.push_back(HighlightSelections(*this));
}