Created
August 18, 2026 03:24
-
-
Save tqbf/064b87a76ce000bcdd4b366ed141d9bc to your computer and use it in GitHub Desktop.
curses.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <curses.h> | |
| int main(void) | |
| { | |
| initscr(); | |
| cbreak(); /* keys immediately, but ^C etc. still work */ | |
| noecho(); /* don't let getch() print them */ | |
| keypad(stdscr, TRUE); /* decode arrows/F-keys into KEY_* */ | |
| /* curs_set(0); */ /* optionally hide hardware cursor */ | |
| for (;;) { | |
| erase(); | |
| mvaddstr(0, 0, "hello"); | |
| attron(A_REVERSE); | |
| mvaddstr(LINES - 2, 0, " ^X Exit ^O Write Out "); | |
| attroff(A_REVERSE); | |
| move(0, 5); /* where physical cursor should end up */ | |
| refresh(); | |
| int c = getch(); | |
| if (c == 24) /* ^X */ | |
| break; | |
| switch (c) { | |
| case KEY_UP: | |
| break; | |
| case KEY_DOWN: | |
| break; | |
| case KEY_LEFT: | |
| break; | |
| case KEY_RIGHT: | |
| break; | |
| } | |
| } | |
| endwin(); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment