1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-20 15:43:16 +00:00

Properly orient the buttons for yes/no and no/yes so that POLA is

observed.  This fixes the "no/yes box jumps buttons around" problem.

PR:		gnu/24487
Submitted by:	Gerhard Sittig <Gerhard.Sittig@gmx.net>
This commit is contained in:
Jordan K. Hubbard 2001-02-24 18:52:56 +00:00
parent 7182d6578d
commit 5c0ebacbcd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=72986

View File

@ -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):