summaryrefslogtreecommitdiff
path: root/src/window.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2011-09-30 19:16:23 +0000
committerMaxime Coste <frrrwww@gmail.com>2011-09-30 19:16:23 +0000
commit01ac17ed04640a4d236c66f4a58d6d6634572018 (patch)
tree4f05958f751d3f5324e7992202dd6b5f4c2414c0 /src/window.cc
parent36c3bb6ae34eda6ec316f109b903ffb3fc007e29 (diff)
Filters: add a colorize_regex filter
Diffstat (limited to 'src/window.cc')
-rw-r--r--src/window.cc33
1 files changed, 12 insertions, 21 deletions
diff --git a/src/window.cc b/src/window.cc
index 2ba97048..82088435 100644
--- a/src/window.cc
+++ b/src/window.cc
@@ -1,6 +1,7 @@
#include "window.hh"
#include "assert.hh"
+#include "filters.hh"
#include <algorithm>
@@ -106,26 +107,6 @@ private:
const Window& m_window;
};
-static void blink_void(DisplayBuffer& display_buffer)
-{
- for (auto atom_it = display_buffer.begin();
- atom_it != display_buffer.end();)
- {
- size_t pos = atom_it->content.find("void");
- if (pos != std::string::npos)
- {
- if (pos != 0)
- atom_it = display_buffer.split(atom_it, pos) + 1;
-
- atom_it = display_buffer.split(atom_it, 4);
- atom_it->attribute |= Attributes::Blink;
- ++atom_it;
- }
- else
- ++atom_it;
- }
-}
-
Window::Window(Buffer& buffer)
: m_buffer(buffer),
m_position(0, 0),
@@ -134,7 +115,17 @@ 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(std::bind(colorize_regex, std::placeholders::_1,
+ boost::regex("\\<(void|int|float|size_t)\\>"), Color::Yellow));
+ m_filters.push_back(std::bind(colorize_regex, std::placeholders::_1,
+ boost::regex("\\<(while|for|if|else|do|switch|case|default|goto|return|using|namespace|try|catch|throw|class|struct|enum|union)\\>"), Color::Blue));
+ m_filters.push_back(std::bind(colorize_regex, std::placeholders::_1,
+ boost::regex("\\<(const|auto|static|volatile)\\>"), Color::Green));
+ m_filters.push_back(std::bind(colorize_regex, std::placeholders::_1,
+ boost::regex("\\<(true|false|NULL|nullptr|\\d+[fdiu]?)\\>"), Color::Red));
+ m_filters.push_back(std::bind(colorize_regex, std::placeholders::_1,
+ boost::regex("//.*$"), Color::Cyan));
+ //m_filters.push_back(std::bind(colorize_regex, std::placeholders::_1, boost::regex("^\\h*.\\w+"), Color::Yellow));
m_filters.push_back(HighlightSelections(*this));
}