#include "timer.hpp" #include "timeractions.hpp" #include #include #include #include #include #include #include #include #include #include /* todo figure out namespaces, using, and auto read about std function and std bind try to do with objects / classes instead centralize into event sender and subscriber */ void myupdatedisplay(const timer &timer_input) { int x_offset = COLS / 4; mvprintw(timer_input.triggercounter, timer_input.triggercounter + x_offset, "test: โ–ˆ"); } std::vector mynumbers = {1, 2, 3, 4, 5, 6, 7, 8, 9}; std::vector myothernumbers = {1, 4, 9, 8, 6, 2, 3, 5, 7}; void displaynumbers(int startx, int starty, std::vector &input_numbers, cchar_t &input_char) { for (size_t i = 0; i < input_numbers.size(); i++) { /** I make a horizontal line of i chars, which are supposed to represent mynumbers above that, I want a line of bars. _all_ bars stretch from LINES-1 to LINES-1-numbervalue **/ mvprintw(LINES -1 - starty, i + startx, "%d,", input_numbers[i]); mvwvline_set(stdscr, LINES-1-input_numbers[i]-starty, i+startx, &input_char, input_numbers[i]); } } void myinitialize() { setlocale(LC_ALL, ""); initscr(); nodelay(stdscr, FALSE); refresh(); start_color(); init_pair(1, COLOR_RED, COLOR_GREEN); attron(COLOR_PAIR(1)); printw("Hello World! ๐ŸŒ ใƒ†ใ‚นใƒˆ ๆต‹่ฏ•"); } int main() { myinitialize(); cchar_t my_c_char = {.attr= A_NORMAL, .chars={L'โ–ˆ'}, .ext_color = 0}; //create actions, then put them in timers, then put them into the timermanager auto myaction = std::make_unique(mynumbers); auto clocktimer = std::make_unique("secondsprinter", 1, 10, std::move(myaction)); auto myothersort = std::make_unique(myothernumbers); auto sorttimer = std::make_unique("sorttimer", 0.1, std::move(myothersort)); timermanager mytimermanager; mytimermanager.addtimer(std::move(clocktimer)); mytimermanager.addtimer(std::move(sorttimer)); while (true) { erase(); mytimermanager.updatetimers(); displaynumbers(0,0,mynumbers, my_c_char); displaynumbers(10, 10, myothernumbers, my_c_char); refresh(); std::this_thread::sleep_for(std::chrono::milliseconds(500)); } getch(); endwin(); return 0; }