From: Daniel Liu Date: Thu, 3 Dec 2020 01:51:11 +0000 (-0500) Subject: ncurses basics X-Git-Url: https://git.danieliu.xyz/?a=commitdiff_plain;h=4f6efe7c9dd49d0a6245616c0799dcaf8296c6be;p=taskasaur.git ncurses basics --- 4f6efe7c9dd49d0a6245616c0799dcaf8296c6be diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ba2906d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +main diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..7757262 --- /dev/null +++ b/main.cpp @@ -0,0 +1,53 @@ +#include +using namespace std; + +int main(int argc, char ** argv) { + + initscr(); + cbreak(); + /* raw(); */ + noecho(); + + WINDOW * win = newwin(10,20,10,10); + + 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 + + move(y,x); + + box(win, 0, 0); + mvwprintw(win, 0, 1, "lmao"); + wrefresh(win); + + refresh(); + /* clear(); */ + } + + endwin(); + + return 0; +} + + diff --git a/makefile b/makefile new file mode 100644 index 0000000..81646c7 --- /dev/null +++ b/makefile @@ -0,0 +1,9 @@ +CC=g++ + +make: main + +main: + $(CC) -lncurses main.cpp -o main + +clean: + rm main