|
|
|
@ -6,12 +6,13 @@ namespace groove { |
|
|
|
|
|
|
|
|
|
std::vector<std::pair<std::regex, ncurses::Colors>> Highlighter::list = { |
|
|
|
|
make_pair("(#[a-z]+ ?)(.*)", ncurses::Colors::ORANGE), |
|
|
|
|
make_pair("([+-.<>,;=!:])", ncurses::Colors::CYAN), |
|
|
|
|
make_pair("([+-.<>,;=!:&*])", ncurses::Colors::CYAN), |
|
|
|
|
make_pair("([\\{\\}\\[\\]\\(\\)])", ncurses::Colors::GREEN), |
|
|
|
|
make_pair("(while|if|try|catch|void|this|else|namespace|private|public|protected|class|char|bool|unsigned|long|short|int|return)\\*?", ncurses::Colors::MAGENTA), |
|
|
|
|
make_pair("(^|\\s)(while|if|try|catch|void|this|else|using|namespace|private|public|protected|friend|class|char|bool|unsigned|long|short|int|return)\\*?", ncurses::Colors::MAGENTA), |
|
|
|
|
make_pair("([a-zA-Z_][a-zA-Z_0-9]+)::", ncurses::Colors::GREEN), |
|
|
|
|
make_pair("::([a-zA-Z_][a-zA-Z_0-9]+)", ncurses::Colors::CYAN), |
|
|
|
|
make_pair("\\.([a-zA-Z_][a-zA-Z_0-9]+)", ncurses::Colors::CYAN), |
|
|
|
|
make_pair("([_a-zA-Z][a-zA-Z0-9_-]+)\\(", ncurses::Colors::CYAN), |
|
|
|
|
make_pair("\\\".*\\\"", ncurses::Colors::ORANGE), |
|
|
|
|
make_pair("/\\*.*\\*//*", ncurses::Colors::ORANGE), |
|
|
|
|
make_pair("(//.*)", ncurses::Colors::ORANGE) |
|
|
|
@ -20,6 +21,12 @@ namespace groove { |
|
|
|
|
std::unordered_map<long, std::pair<long, ncurses::Colors>> groove::Highlighter::get() { |
|
|
|
|
std::unordered_map<long, std::pair<long, ncurses::Colors>> list; |
|
|
|
|
|
|
|
|
|
if (this->line.size() > 0 && this->line.at(0) == '#') { |
|
|
|
|
list.emplace(0, std::make_pair(this->line.size(), ncurses::Colors::ORANGE)); |
|
|
|
|
|
|
|
|
|
return list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (auto& keyword : Highlighter::list) { |
|
|
|
|
try { |
|
|
|
|
std::sregex_iterator next(this->line.begin(), this->line.end(), keyword.first); |
|
|
|
|