separate initscr(3x) wrapper to new function

This commit is contained in:
Emile Clark-Boman 2025-09-10 22:54:20 +10:00
parent 79272e8421
commit a55c25d319
2 changed files with 14 additions and 7 deletions

View file

@ -31,25 +31,31 @@ inline void init_ncurses(void) {
setlocale(LC_ALL, CRS_LOCALE);
/* NCurses Init */
*stdscr = initscr();
start_color();
/* Screen Configuration */
termmode(WMODE_CBREAK);
noecho(); // manually echo <- getch(3x)
nodelay(*stdscr, TRUE); // getch(3x) nonblocking IO
keypad(*stdscr, TRUE); // allow function keys
// intrflush(3x) - flush terminal input buffer on interrupt key
intrflush(*stdscr, FALSE);
curs_set(0); // hide cursor
// init_pair(1, COLOR_BLACK, COLOR_CYAN);
}
WINDOW *init_window(int x, int y, int width, int height) {
WINDOW *win = newwin(height, width, y, x);
nodelay(win, TRUE); // getch(3x) nonblocking IO
keypad(win, TRUE); // allow function keys
// intrflush(3x) - flush terminal input buffer on interrupt key
intrflush(win, FALSE);
return win;
}
int main(int argc, char *argv[]) {
WINDOW *stdscr;
crs_init(&stdscr);
init_ncurses();
WINDOW *stdscr = init_window(0, 0, 0, 0);
// Set background
wbkgd(stdscr, COLOR_PAIR(1));

View file

@ -17,5 +17,6 @@ enum crs_mode {
int termmode(enum crs_mode mode);
void init_ncurses(void);
WINDOW *init_window(int x, int y, int width, int height);
#endif /* DORNE_CURSE_H */