From a55c25d3196337274629803456be948b91d073f1 Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Wed, 10 Sep 2025 22:54:20 +1000 Subject: [PATCH] separate initscr(3x) wrapper to new function --- cli/curse.c | 20 +++++++++++++------- cli/curse.h | 1 + 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/cli/curse.c b/cli/curse.c index bc5a1c9..f2eda88 100644 --- a/cli/curse.c +++ b/cli/curse.c @@ -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)); diff --git a/cli/curse.h b/cli/curse.h index 8234a9a..67d599f 100644 --- a/cli/curse.h +++ b/cli/curse.h @@ -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 */