From 7d2b26de6843f58c0b752192aacdaf5e76fe383d Mon Sep 17 00:00:00 2001 From: Michael Ochmann Date: Thu, 9 Mar 2017 19:14:02 +0100 Subject: [PATCH] fixed colors to true monokai --- src/Editor.cpp | 6 +++--- src/Highlighter.cpp | 5 ++--- src/ncurses/ncurses.hpp | 41 ++++++++++++++++++++++++++++++----------- 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/Editor.cpp b/src/Editor.cpp index 54b6c54..a9be452 100644 --- a/src/Editor.cpp +++ b/src/Editor.cpp @@ -88,10 +88,10 @@ namespace groove { std::string label = std::string(x - Editor::Digits(ln) - 1, ' '); label += std::to_string(ln) + ' '; if (linenumber != this->y) - attron(A_REVERSE); + attron(COLOR_PAIR(ncurses::Colors::LINENUMBERS)); mvprintw(i - offset, 0, label.c_str()); if (linenumber != this->y) - attroff(A_REVERSE); + attroff(COLOR_PAIR(ncurses::Colors::LINENUMBERS)); } for (auto& car : line) { @@ -113,7 +113,7 @@ namespace groove { } } if (inComment) - attron(COLOR_PAIR(ncurses::Colors::ORANGE)); + attron(COLOR_PAIR(ncurses::Colors::COMMENTS)); mvaddch(i - this->offset, x , car); attron(COLOR_PAIR(ncurses::Colors::MAIN)); this->lastChar = car; diff --git a/src/Highlighter.cpp b/src/Highlighter.cpp index b44c99d..1e0c921 100644 --- a/src/Highlighter.cpp +++ b/src/Highlighter.cpp @@ -5,7 +5,6 @@ namespace groove { std::vector> Highlighter::list = { - make_pair("(#[a-z]+ ?)(.*)", ncurses::Colors::ORANGE), make_pair("([+-.<>,;=!:&*])", ncurses::Colors::CYAN), make_pair("([\\{\\}\\[\\]\\(\\)])", ncurses::Colors::GREEN), 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), @@ -14,7 +13,7 @@ namespace groove { 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::COMMENTS), make_pair("(//.*)", ncurses::Colors::ORANGE) }; @@ -22,7 +21,7 @@ namespace groove { std::unordered_map> list; if (this->line.size() > 0 && this->line.at(0) == '#') { - list.emplace(0, std::make_pair(this->line.size(), ncurses::Colors::ORANGE)); + list.emplace(0, std::make_pair(this->line.size(), ncurses::Colors::COMMENTS)); return list; } diff --git a/src/ncurses/ncurses.hpp b/src/ncurses/ncurses.hpp index 4c4145d..589b2aa 100644 --- a/src/ncurses/ncurses.hpp +++ b/src/ncurses/ncurses.hpp @@ -1,6 +1,9 @@ #pragma once #include +#include + +#define CURSES_MAX_COLOR 1000.0f namespace groove { namespace ncurses { @@ -8,9 +11,9 @@ namespace groove { struct Color { short r, g, b; Color(short r, short g, short b) : - r(static_cast(r * 0.255)), - g(static_cast(g * 0.255)), - b(static_cast(b * 0.255)) {} + r(static_cast(r / 255.0f * CURSES_MAX_COLOR)), + g(static_cast(g / 255.0f * CURSES_MAX_COLOR)), + b(static_cast(b / 255.0f * CURSES_MAX_COLOR)) {} }; enum Colors { @@ -21,7 +24,9 @@ namespace groove { PURPLE, ORANGE, CYAN, - GREY + GREY, + LINENUMBERS, + COMMENTS }; class ncurses { @@ -35,21 +40,35 @@ namespace groove { keypad(stdscr, true); // Enable special keys to be recorde start_color(); - init_pair(Colors::MAIN, COLOR_WHITE, COLOR_BLACK); - init_pair(Colors::STATUSBAR, COLOR_WHITE, COLOR_MAGENTA); - init_pair(Colors::MAGENTA, COLOR_MAGENTA, COLOR_BLACK); - init_pair(Colors::GREEN, COLOR_GREEN, COLOR_BLACK); - init_pair(Colors::GREY, COLOR_YELLOW, COLOR_BLACK); - init_pair(Colors::CYAN, COLOR_CYAN, COLOR_BLACK); - init_pair(Colors::ORANGE, COLOR_YELLOW, COLOR_BLACK); if (can_change_color()) { Color grey(39, 40, 34); Color pink(255, 0, 103); + Color cyan(102 , 217, 239); + Color green(162, 217, 43); + Color lightgray(60, 61, 55); + Color lighterGray(144, 144, 138); + Color yellow(230, 219, 116); init_color(COLOR_BLACK, grey.r, grey.g, grey.b); init_color(COLOR_MAGENTA, pink.r, pink.g, pink.b); + init_color(COLOR_CYAN, cyan.r, cyan.g, cyan.b); + init_color(COLOR_BLUE, lightgray.r, lightgray.g, lightgray.b); + init_color(COLOR_YELLOW, yellow.r, yellow.g, yellow.b); + init_color(COLOR_GREEN, green.r, green.g, green.b); + init_color(COLOR_RED, lighterGray.r, lighterGray.g, lighterGray.b); } + + init_pair(Colors::LINENUMBERS, COLOR_WHITE, COLOR_BLUE); + init_pair(Colors::COMMENTS, COLOR_RED, COLOR_BLACK); + init_pair(Colors::MAIN, COLOR_WHITE, COLOR_BLACK); + init_pair(Colors::STATUSBAR, COLOR_WHITE, COLOR_MAGENTA); + init_pair(Colors::MAGENTA, COLOR_MAGENTA, COLOR_BLACK); + init_pair(Colors::GREEN, COLOR_GREEN, COLOR_BLACK); + init_pair(Colors::GREY, COLOR_YELLOW, COLOR_BLACK); + init_pair(Colors::CYAN, COLOR_CYAN, COLOR_BLACK); + init_pair(Colors::ORANGE, COLOR_YELLOW, COLOR_BLACK); + attron(COLOR_PAIR(1)); }