Filters: add a colorize_cplusplus filter and use it by default in Window
This commit is contained in:
parent
d99bcd7f2e
commit
6a0b570e50
|
@ -25,4 +25,28 @@ void colorize_regex(DisplayBuffer& display_buffer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void colorize_cplusplus(DisplayBuffer& display_buffer)
|
||||||
|
{
|
||||||
|
static boost::regex preprocessor("(?<=\\n)\\h*#\\h*[^\\n]*(?=\\n)");
|
||||||
|
colorize_regex(display_buffer, preprocessor, Color::Magenta);
|
||||||
|
|
||||||
|
static boost::regex strings("\"(\\\\\"|[^\"])*\"");
|
||||||
|
colorize_regex(display_buffer, strings, Color::Magenta);
|
||||||
|
|
||||||
|
static boost::regex values("\\<(true|false|NULL|nullptr)\\>|-?\\d+[fdiu]?|'[^']*'");
|
||||||
|
colorize_regex(display_buffer, values, Color::Red);
|
||||||
|
|
||||||
|
static boost::regex builtin_types("\\<(void|int|float|bool|size_t)\\>");
|
||||||
|
colorize_regex(display_buffer, builtin_types, Color::Yellow);
|
||||||
|
|
||||||
|
static boost::regex control_keywords("\\<(while|for|if|else|do|switch|case|default|goto|return|using|try|catch|throw)\\>");
|
||||||
|
colorize_regex(display_buffer, control_keywords, Color::Blue);
|
||||||
|
|
||||||
|
static boost::regex types_keywords("\\<(const|auto|namespace|static|volatile|class|struct|enum|union|public|protected|private)\\>");
|
||||||
|
colorize_regex(display_buffer, types_keywords, Color::Green);
|
||||||
|
|
||||||
|
static boost::regex comments("//[^\\n]*\\n");
|
||||||
|
colorize_regex(display_buffer, comments, Color::Cyan);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@ namespace Kakoune
|
||||||
void colorize_regex(DisplayBuffer& display_buffer,
|
void colorize_regex(DisplayBuffer& display_buffer,
|
||||||
const boost::regex& ex, Color color);
|
const boost::regex& ex, Color color);
|
||||||
|
|
||||||
|
void colorize_cplusplus(DisplayBuffer& display_buffer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // filters_hh_INCLUDED
|
#endif // filters_hh_INCLUDED
|
||||||
|
|
|
@ -115,17 +115,7 @@ Window::Window(Buffer& buffer)
|
||||||
m_current_inserter(nullptr)
|
m_current_inserter(nullptr)
|
||||||
{
|
{
|
||||||
m_selections.push_back(Selection(buffer.begin(), buffer.begin()));
|
m_selections.push_back(Selection(buffer.begin(), buffer.begin()));
|
||||||
m_filters.push_back(std::bind(colorize_regex, std::placeholders::_1,
|
m_filters.push_back(colorize_cplusplus);
|
||||||
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));
|
m_filters.push_back(HighlightSelections(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user