From: Daniel Liu Date: Wed, 9 Dec 2020 05:53:52 +0000 (-0500) Subject: moved to c X-Git-Url: https://git.danieliu.xyz/?a=commitdiff_plain;h=12a770aa60e7d8647187edcd38fa7d3e876558c7;p=taskasaur.git moved to c --- diff --git a/main.c b/main.c new file mode 100644 index 0000000..e4ef06b --- /dev/null +++ b/main.c @@ -0,0 +1,71 @@ +#include +#include +#include +#include + +int main(int argc, char** argv) { + + // start ncurses + initscr(); + cbreak(); + /* raw(); */ + noecho(); + start_color(); + + init_pair(1, COLOR_CYAN, COLOR_BLACK); + init_pair(2, COLOR_BLACK, COLOR_CYAN); + + int height, width; + getmaxyx(stdscr, height, width); + + WINDOW * win = newwin(10,20,5,10); + WINDOW * todo_win = newwin(20,20,5,35); + WINDOW * bottombar = newwin(1,width,height-1,0); + refresh(); + + int x, y; + x = y = 0; + + while (true) { + int ch = getch(); + + //ofc the first thing we need is vim keys + switch (ch) { + case 104: // h + x -= 1; + break; + case 106: // j + y += 1; + break; + case 107: // k + y -= 1; + break; + case 108: // l + x += 1; + break; + } + if (ch == 113) break; // q for quit + + box(win, 0, 0); + wattron(win,COLOR_PAIR(1)); + wattron(win, A_BOLD); + mvwprintw(win, 0, 1, "lmao"); + wattroff(win, A_BOLD); + wattroff(win,COLOR_PAIR(1)); + mvwprintw(win, 1, 2, "poopoopeepee"); + wrefresh(win); + + wrefresh(todo_win); + + wbkgd(bottombar, COLOR_PAIR(2)); + mvwprintw(bottombar, 0, 2, "BOTTOM TEXT"); + wrefresh(bottombar); + + move(y,x); + refresh(); + /* clear(); */ + } + + endwin(); + return 0; +} diff --git a/main.cpp b/main.cpp index bb33673..44f0278 100644 --- a/main.cpp +++ b/main.cpp @@ -3,6 +3,7 @@ #include #include #include +#include using namespace std; bool file_exists(const char* file_name) { @@ -10,8 +11,14 @@ bool file_exists(const char* file_name) { return (bool)test_file; } +void winch_handler(int signum) { // handle terminal resize + refresh(); +} + int main(int argc, char** argv) { - + + signal(SIGWINCH, winch_handler); + // read command line args if (argc < 2) { cout << "Taskasaur options\n-o [board_name]\n-n [new_board+name]"; @@ -48,7 +55,7 @@ int main(int argc, char** argv) { } } - return 0; + /* return 0; */ // start ncurses diff --git a/makefile b/makefile index 81646c7..af84c6b 100644 --- a/makefile +++ b/makefile @@ -1,9 +1,11 @@ -CC=g++ +CPPC=g++ +CC=gcc make: main main: - $(CC) -lncurses main.cpp -o main + #$(CPPC) -lncurses main.cpp -o main + $(CC) -lncurses main.c -o main clean: rm main