diff options
| author | Jordan K. Hubbard <jkh@FreeBSD.org> | 2001-02-24 18:52:56 +0000 |
|---|---|---|
| committer | Jordan K. Hubbard <jkh@FreeBSD.org> | 2001-02-24 18:52:56 +0000 |
| commit | 5c0ebacbcddf4bbde8e4d2cc37d6aca3724d218b (patch) | |
| tree | 63147f28629a5ef1c6a5bae4eb93d04ba22867d2 /gnu/lib/libdialog | |
| parent | 7182d6578d7b4cc94f94f1d4cfd8252419f16e30 (diff) | |
Notes
Diffstat (limited to 'gnu/lib/libdialog')
| -rw-r--r-- | gnu/lib/libdialog/yesno.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/gnu/lib/libdialog/yesno.c b/gnu/lib/libdialog/yesno.c index 3b7447fb197f..90244703346d 100644 --- a/gnu/lib/libdialog/yesno.c +++ b/gnu/lib/libdialog/yesno.c @@ -50,7 +50,7 @@ dialog_noyes(unsigned char *title, unsigned char *prompt, int height, int width) static int dialog_yesno_proc(unsigned char *title, unsigned char *prompt, int height, int width, int yesdefault) { - int i, j, x, y, key = 0, button = 0; + int i, j, x, y, key, button; WINDOW *dialog; char *tmphlp; @@ -114,11 +114,15 @@ dialog_yesno_proc(unsigned char *title, unsigned char *prompt, int height, int w x = width/2-10; y = height-2; - print_button(dialog, yesdefault ? " No " : " Yes ", y, x+13, FALSE); - print_button(dialog, yesdefault ? " Yes " : " No ", y, x, TRUE); - wrefresh(dialog); + /* preset button 0 or 1 for YES or NO as the default */ + key = 0; + button = !yesdefault; while (key != ESC) { + print_button(dialog, " No ", y, x+13, button); + print_button(dialog, " Yes " , y, x, !button); + wrefresh(dialog); + key = wgetch(dialog); switch (key) { case 'Y': @@ -137,27 +141,15 @@ dialog_yesno_proc(unsigned char *title, unsigned char *prompt, int height, int w case KEY_DOWN: case KEY_LEFT: case KEY_RIGHT: - if (!button) { - button = 1; /* Indicates "No" button is selected */ - print_button(dialog, yesdefault ? " Yes " : " No ", y, x, FALSE); - print_button(dialog, yesdefault ? " No " : " Yes ", y, x+13, TRUE); - } - else { - button = 0; /* Indicates "Yes" button is selected */ - print_button(dialog, yesdefault ? " No " : " Yes ", y, x+13, FALSE); - print_button(dialog, yesdefault ? " Yes " : " No ", y, x, TRUE); - } - wrefresh(dialog); + button = !button; + /* redrawn at the loop's entry */ break; case ' ': case '\r': case '\n': delwin(dialog); restore_helpline(tmphlp); - if (yesdefault) - return button; - else - return !button; + return button; case ESC: break; case KEY_F(1): |
