ensure initscr(3x) & use newwin(3x) not stdscr(3x) for root node
This commit is contained in:
parent
8c4f288a97
commit
f73dbd7d8a
2 changed files with 13 additions and 12 deletions
22
cli/curse.c
22
cli/curse.c
|
|
@ -25,6 +25,15 @@ int termmode(const enum crs_termmode mode) {
|
|||
}
|
||||
}
|
||||
|
||||
/* Apply a default IO configuration for an ncurses WINDOW.
|
||||
*/
|
||||
static inline void __conf_window(WINDOW *const win) {
|
||||
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);
|
||||
}
|
||||
|
||||
/* Initialise ncurses for our usecase.
|
||||
* WARNING: This function should only be called once.
|
||||
*/
|
||||
|
|
@ -33,6 +42,8 @@ void init_ncurses(void) {
|
|||
setlocale(LC_ALL, CRS_LOCALE);
|
||||
|
||||
/* NCurses Init */
|
||||
initscr();
|
||||
__conf_window(stdscr);
|
||||
start_color();
|
||||
|
||||
/* Screen Configuration */
|
||||
|
|
@ -42,15 +53,6 @@ void init_ncurses(void) {
|
|||
curs_set(0); // hide cursor
|
||||
}
|
||||
|
||||
/* Apply a default IO configuration for an ncurses WINDOW.
|
||||
*/
|
||||
static inline void __conf_window(WINDOW *const win) {
|
||||
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);
|
||||
}
|
||||
|
||||
/* Initialise (with default IO configuration) a new ncurses WINDOW.
|
||||
*/
|
||||
WINDOW *new_window(const int x, const int y, const int width,
|
||||
|
|
@ -65,7 +67,7 @@ WINDOW *new_window(const int x, const int y, const int width,
|
|||
* NOTE: This is typically done via initscr(3x) and called "stdscr".
|
||||
*/
|
||||
WINDOW *root_window(void) {
|
||||
WINDOW *rootwin = new_window(0, 0, 0, 0);
|
||||
WINDOW *rootwin = new_window(0, 0, COLS, LINES);
|
||||
__conf_window(rootwin);
|
||||
return rootwin;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,7 @@ enum crs_termmode {
|
|||
int termmode(const enum crs_termmode mode);
|
||||
|
||||
void init_ncurses(void);
|
||||
WINDOW *init_window(const int x, const int y, const int width,
|
||||
const int height);
|
||||
WINDOW *new_window(const int x, const int y, const int width, const int height);
|
||||
WINDOW *root_window(void);
|
||||
|
||||
int resizemv_window(const int x, const int y, const int width, const int height,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue