patch-1.3.71 linux/scripts/lxdialog/yesno.c

Next file: linux/CREDITS
Previous file: linux/scripts/lxdialog/menubox.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.70/linux/scripts/lxdialog/yesno.c linux/scripts/lxdialog/yesno.c
@@ -25,14 +25,15 @@
  * Display termination buttons
  */
 static void
-print_buttons(WINDOW *dialog, int height, int width, int okval, int cancelval)
+print_buttons(WINDOW *dialog, int height, int width, int selected)
 {
     int x = width / 2 - 10;
     int y = height - 2;
 
-    print_button (dialog, " Yes ", y, x, okval);
-    print_button (dialog, "  No  ", y, x + 13, cancelval);
+    print_button (dialog, " Yes ", y, x, selected == 0);
+    print_button (dialog, "  No  ", y, x + 13, selected == 1);
 
+    wmove(dialog, y, x+1 + 13*selected );
     wrefresh (dialog);
 }
 
@@ -72,7 +73,7 @@
     wattrset (dialog, dialog_attr);
     print_autowrap (dialog, prompt, width - 2, 1, 3);
 
-    print_buttons(dialog, height, width, TRUE, FALSE);
+    print_buttons(dialog, height, width, 0);
 
     while (key != ESC) {
 	key = wgetch (dialog);
@@ -87,17 +88,12 @@
 	    return 1;
 
 	case TAB:
-	case KEY_UP:
-	case KEY_DOWN:
 	case KEY_LEFT:
 	case KEY_RIGHT:
-	    if (!button) {
-		button = 1;	/* "No" button selected */
-    		print_buttons(dialog, height, width, FALSE, TRUE);
-	    } else {
-		button = 0;	/* "Yes" button selected */
-    		print_buttons(dialog, height, width, TRUE, FALSE);
-	    }
+	    button = ((key == KEY_LEFT ? --button : ++button) < 0)
+			? 1 : (button > 1 ? 0 : button);
+
+	    print_buttons(dialog, height, width, button);
 	    wrefresh (dialog);
 	    break;
 	case ' ':


FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this