]> git.ozlabs.org Git - petitboot/blobdiff - ui/ncurses/nc-scr.c
ui/ncurses: Add nc_scr_{un,}post()
[petitboot] / ui / ncurses / nc-scr.c
index 9a3f3dfc77d0dd1b45dfdbdfff40256ba0e36899..e8c5fcabc1b783b46ba051c1db45ec415a50b329 100644 (file)
 
 #include "nc-scr.h"
 
-void nc_start(void)
+static void nc_scr_status_clear(struct nc_scr *scr)
 {
-       initscr();                      /* Initialize ncurses. */
-       cbreak();                       /* Disable line buffering. */
-       noecho();                       /* Disable getch() echo. */
-       keypad(stdscr, TRUE);           /* Enable num keypad keys. */
-       nonl();                         /* Disable new-line translation. */
-       intrflush(stdscr, FALSE);       /* Disable interrupt flush. */
-       curs_set(0);                    /* Make cursor invisible */
-       nodelay(stdscr, TRUE);          /* Enable non-blocking getch() */
-
-       /* We may be operating with an incorrect $TERM type; in this case
-        * the keymappings will be slightly broken. We want at least
-        * backspace to work though, so we'll define both DEL and ^H to
-        * map to backspace */
-       define_key("\x7f", KEY_BACKSPACE);
-       define_key("\x08", KEY_BACKSPACE);
-
-       while (getch() != ERR)          /* flush stdin */
-               (void)0;
+       mvwhline(scr->main_ncw, LINES - nc_scr_pos_status, 0, ' ', COLS);
 }
 
-void nc_atexit(void)
+static void nc_scr_status_draw(struct nc_scr *scr)
 {
-       clear();
-       refresh();
-       endwin();
+       mvwaddstr(scr->main_ncw, LINES - nc_scr_pos_status, 1,
+               scr->frame.status);
 }
 
-static void nc_scr_status_clear(struct nc_scr *scr)
+int nc_scr_post(struct nc_scr *scr)
 {
-       mvwhline(scr->main_ncw, LINES - nc_scr_pos_status, 0, ' ', COLS);
+       if (scr->post)
+               return scr->post(scr);
+       return 0;
 }
 
-static void nc_scr_status_draw(struct nc_scr *scr)
+int nc_scr_unpost(struct nc_scr *scr)
 {
-       mvwaddstr(scr->main_ncw, LINES - nc_scr_pos_status, 1,
-               scr->frame.status);
+       if (scr->unpost)
+               return scr->unpost(scr);
+       return 0;
 }
 
 void nc_scr_frame_draw(struct nc_scr *scr)