nvramcui: don't init curses too early

Init curses as late as possible and tear them down early. There are possible
error outs after that and they don't look nice with curses initialized.

Change-Id: I9128ae8eee25940716b8d223cc7ec6c0abb6838e
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-on: http://review.coreboot.org/8528
Tested-by: build bot (Jenkins)
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
Lubomir Rintel 2015-02-24 20:33:35 +01:00 committed by Patrick Georgi
parent 18860d7a4f
commit 1ecc8af5ce
1 changed files with 19 additions and 18 deletions

View File

@ -76,21 +76,6 @@ int main()
halt(); halt();
} }
/* display initialization */
initscr();
keypad(stdscr, TRUE);
cbreak();
noecho();
start_color();
leaveok(stdscr, TRUE);
curs_set(1);
erase();
box(stdscr, 0, 0);
mvaddstr(0, 2, "coreboot configuration utility");
refresh();
/* prep CMOS layout into libcurses data structures */ /* prep CMOS layout into libcurses data structures */
/* determine number of options, and maximum option name length */ /* determine number of options, and maximum option name length */
@ -178,6 +163,23 @@ int main()
} }
fields[2*numopts]=NULL; fields[2*numopts]=NULL;
/* display initialization */
initscr();
keypad(stdscr, TRUE);
cbreak();
noecho();
if (start_color()) {
assume_default_colors (COLOR_BLUE, COLOR_CYAN);
}
leaveok(stdscr, TRUE);
curs_set(1);
erase();
box(stdscr, 0, 0);
mvaddstr(0, 2, "coreboot configuration utility");
refresh();
FORM *form = new_form(fields); FORM *form = new_form(fields);
int numlines = min(numopts*2, 16); int numlines = min(numopts*2, 16);
WINDOW *w = newwin(numlines+2, 70, 2, 1); WINDOW *w = newwin(numlines+2, 70, 2, 1);
@ -230,6 +232,8 @@ int main()
} }
} }
endwin();
for (i = 0; i < numopts; i++) { for (i = 0; i < numopts; i++) {
char *name = field_buffer(fields[2*i], 0); char *name = field_buffer(fields[2*i], 0);
char *value = field_buffer(fields[2*i+1], 0); char *value = field_buffer(fields[2*i+1], 0);
@ -242,10 +246,7 @@ int main()
unpost_form(form); unpost_form(form);
free_form(form); free_form(form);
touchwin(stdscr);
refresh();
endwin();
/* TODO: reboot */ /* TODO: reboot */
halt(); halt();
} }