X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=ui%2Fncurses%2Fnc-scr.c;h=e95c0ea361e893dae68b14fb2d0fcb4e8d04e208;hp=9a3f3dfc77d0dd1b45dfdbdfff40256ba0e36899;hb=7e0b9da2ae2f96d24c711c0ad4d12bb193ec49c0;hpb=47bc66a0c744f68a84147b0bd616ab25a242fb70 diff --git a/ui/ncurses/nc-scr.c b/ui/ncurses/nc-scr.c index 9a3f3df..e95c0ea 100644 --- a/ui/ncurses/nc-scr.c +++ b/ui/ncurses/nc-scr.c @@ -16,9 +16,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#if defined(HAVE_CONFIG_H) #include "config.h" - -#define _GNU_SOURCE +#endif #include #include @@ -29,49 +29,34 @@ #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(); + mvwaddnstr(scr->main_ncw, LINES - nc_scr_pos_status, 1, + scr->frame.status, COLS); } -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) { - int ltitle_len, rtitle_len; + int ltitle_len, rtitle_len, help_len; DBGS("ltitle '%s'\n", scr->frame.ltitle); DBGS("rtitle '%s'\n", scr->frame.rtitle); @@ -92,6 +77,10 @@ void nc_scr_frame_draw(struct nc_scr *scr) mvwhline(scr->main_ncw, LINES - nc_scr_pos_help_sep, 1, ACS_HLINE, COLS - 2); + help_len = 1 + strlen(scr->frame.help); + if (help_len < COLS) + mvwhline(scr->main_ncw, LINES - nc_scr_pos_help, help_len, ' ', + COLS - help_len); mvwaddstr(scr->main_ncw, LINES - nc_scr_pos_help, 1, scr->frame.help); nc_scr_status_draw(scr); } @@ -143,7 +132,7 @@ int nc_scr_init(struct nc_scr *scr, enum pb_nc_sig sig, int begin_x, scr->sub_ncw = derwin(scr->main_ncw, LINES - nc_scr_frame_lines, - COLS - 1 - begin_x, + COLS - nc_scr_frame_cols - begin_x, nc_scr_pos_sub, begin_x);