diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index ea94d55..282accb 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -15,28 +15,38 @@ Engine::~Engine() { delete this->calendar; } -void Engine::draw(WINDOW *win) { +void Engine::ui_draw(WINDOW *win) { this->cells_table.clear(); box(win, 0, 0); - calendar_information date_info = this->calendar->get_info(); - - switch (this->view_mode) { case MONTH_VIEW: - for (int i = 1; i <= date_info.current_month_days; i++) - mvwprintw(win, i, 3, "D%d", i); + this->ui_month_draw(win); break; case MONTHS_VIEW: - for (int i = 1; i <= 12; i++) - wprintw(win, "M%d", i); + this->ui_months_draw(win); break; } - wprintw(win, "\n"); - - mvwprintw(win, LINES-1, 0, "Year: %d, Month: %d, Day: %d", date_info.current_year, date_info.current_month, date_info.current_day); + this->ui_bottom_draw(win); wrefresh(win); } + +void Engine::ui_month_draw(WINDOW *win) { + +} + +void Engine::ui_months_draw(WINDOW *win) { + +} + +void Engine::ui_bottom_draw(WINDOW *win) { + if (VIS_COLORING) wattron(win, COLOR_PAIR(1)); + + calendar_information date_info = this->calendar->get_info(); + mvwprintw(win, LINES-2, 1, "Year: %d, Month: %d, Day: %d", date_info.current_year, date_info.current_month, date_info.current_day); + + if (VIS_COLORING) wattroff(win, COLOR_PAIR(1)); +} diff --git a/src/engine/engine.hpp b/src/engine/engine.hpp index c16f0ee..c758519 100644 --- a/src/engine/engine.hpp +++ b/src/engine/engine.hpp @@ -4,6 +4,7 @@ #include #include #include "../calendar/calendar.hpp" +#include "../global/global.hpp" struct engine_child { int x; @@ -22,7 +23,10 @@ class Engine { Engine(int padding = 10, calendar_view_mode view_mode = MONTH_VIEW); ~Engine(); - void draw(WINDOW *win); + void ui_draw(WINDOW *win); + void ui_month_draw(WINDOW *win); + void ui_months_draw(WINDOW *win); + void ui_bottom_draw(WINDOW *win); Calendar *calendar; diff --git a/src/global/global.hpp b/src/global/global.hpp new file mode 100644 index 0000000..5dfc357 --- /dev/null +++ b/src/global/global.hpp @@ -0,0 +1,8 @@ +#ifndef VIS_GLOBAL +#define VIS_GLOBAL + +#include + +#define VIS_COLORING has_colors() && can_change_color() + +#endif diff --git a/src/main.cpp b/src/main.cpp index e482c6f..8544f58 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,6 +4,7 @@ #include #include "calendar/calendar.hpp" #include "engine/engine.hpp" +#include "global/global.hpp" Engine engine = Engine(10, MONTH_VIEW); WINDOW *main_win; @@ -17,7 +18,7 @@ void sig_winch(int sig) { wresize(main_win, LINES, COLS); // redraw the TUI after the resize signal - engine.draw(main_win); + engine.ui_draw(main_win); flushinp(); } @@ -31,15 +32,29 @@ int main() { refresh(); noecho(); + curs_set(0); // invisible cursor + refresh(); + main_win = newwin(LINES, COLS, 0, 0); + if (VIS_COLORING) { + start_color(); + use_default_colors(); + + init_color(COLOR_BLACK, 0, 0, 0); + init_color(COLOR_WHITE, 1000, 1000, 1000); + + init_pair(0, COLOR_WHITE, COLOR_BLACK); + init_pair(1, COLOR_BLACK, COLOR_WHITE); + } + // handle required signals signals(); for (;;) { wclear(main_win); wrefresh(main_win); - engine.draw(main_win); + engine.ui_draw(main_win); char ch = getch(); int month; @@ -65,7 +80,6 @@ int main() { } } - endwin(); return 0;