Date: Sat, 20 Jan 2001 18:48:40 +0100 From: Gerhard Sittig <Gerhard.Sittig@gmx.net> To: FreeBSD-gnats-submit@freebsd.org Subject: gnu/24487: [PATCH] libdialog's no/yes box jumps buttons around Message-ID: <20010120184840.M253@speedy.gsinet>
next in thread | raw e-mail | index | archive | help
>Number: 24487 >Category: gnu >Synopsis: [PATCH] libdialog's no/yes box jumps buttons around >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Jan 20 10:00:00 PST 2001 >Closed-Date: >Last-Modified: >Originator: Gerhard Sittig >Release: FreeBSD 5.0-CURRENT i386 >Organization: System Defenestrators Inc. >Environment: mostly sysinstall(8), but could be any application making use of the newly introduced no/yes question box in libdialog I'm not certain of the above classification: It's a FreeBSD customization in GNU derived code, and it's sysinstall annoying users thus leaving an impression at first encounter we don't want to ... :> >Description: In mid December libdialog was extended to not only have a Yes/No question box, but to have another box with No as the default answer (called No/Yes box). This was done so sysinstall(8) could suggest better suited answers when asking security related questions (the reasoning I understand for this feature, but I could be wrong). While I welcome being offered more appropriate defaults when questions arise at installation time, I'm really annoyed by the need to look twice which button has what meaning in this very moment. I would *always* expect the left one to be the "yes" button while the right one is labeled "no". Any other arrangement will dazzle users, and when these arrangements differ between different questions it's really easy to provide the wrong answer and regretting right afterwards (I've been bitten myself, that's when I decided the current state is not acceptable:). >How-To-Repeat: just use sysinstall (maybe from recent install floppies) or use the below test sequence without applying the patch >Fix: Apply the patch cited below. It is written quite aggressivly concerning the TRUE/FALSE vs 0/1 thingy. I understand that the button 0 and 1 numbering is not meant to read boolean but more of an index. But I was ready to misuse the fact that it could be used this way (keeping in mind the "reversed" boolean meaning with YES being 0 and NO being 1). Feel free to tell me when you want a more conservative patch (but the libdialog code is already guilty of "hardcoding" TRUE to 1 and FALSE to 0 which I feel to be at least dangerous if not wrong). I don't care very much that the dialog gets redrawn on every key press. They should happen quite rarely and this construction allows for elimination of the print_button code duplicates. Honestly I don't expect very much key presses apart from TAB, SPC, the Y and N shortcuts, and their equivalents. All of them need a (kind of) redraw. Any other keypress means that the user is misguided anyway. :> # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # aggressive.diff # echo x - aggressive.diff sed 's/^X//' >aggressive.diff << 'END-of-aggressive.diff' XIndex: yesno.c X=================================================================== XRCS file: /CVSREPO/fbsd/src/gnu/lib/libdialog/yesno.c,v Xretrieving revision 1.12 Xdiff -u -r1.12 yesno.c X--- yesno.c 2000/12/14 02:35:22 1.12 X+++ yesno.c 2001/01/20 17:45:08 X@@ -50,7 +50,7 @@ X static int X dialog_yesno_proc(unsigned char *title, unsigned char *prompt, int height, int width, int yesdefault) X { X- int i, j, x, y, key = 0, button = 0; X+ int i, j, x, y, key, button; X WINDOW *dialog; X char *tmphlp; X X@@ -114,11 +114,15 @@ X X x = width/2-10; X y = height-2; X- print_button(dialog, yesdefault ? " No " : " Yes ", y, x+13, FALSE); X- print_button(dialog, yesdefault ? " Yes " : " No ", y, x, TRUE); X- wrefresh(dialog); X X+ /* preset button 0 or 1 for YES or NO as the default */ X+ key = 0; X+ button = !yesdefault; X while (key != ESC) { X+ print_button(dialog, " No ", y, x+13, button); X+ print_button(dialog, " Yes " , y, x , !button); X+ wrefresh(dialog); X+ X key = wgetch(dialog); X switch (key) { X case 'Y': X@@ -137,27 +141,15 @@ X case KEY_DOWN: X case KEY_LEFT: X case KEY_RIGHT: X- if (!button) { X- button = 1; /* Indicates "No" button is selected */ X- print_button(dialog, yesdefault ? " Yes " : " No ", y, x, FALSE); X- print_button(dialog, yesdefault ? " No " : " Yes ", y, x+13, TRUE); X- } X- else { X- button = 0; /* Indicates "Yes" button is selected */ X- print_button(dialog, yesdefault ? " No " : " Yes ", y, x+13, FALSE); X- print_button(dialog, yesdefault ? " Yes " : " No ", y, x, TRUE); X- } X- wrefresh(dialog); X+ button = !button; X+ /* redrawn at the loop's entry */ X break; X case ' ': X case '\r': X case '\n': X delwin(dialog); X restore_helpline(tmphlp); X- if (yesdefault) X- return button; X- else X- return !button; X+ return button; X case ESC: X break; X case KEY_F(1): END-of-aggressive.diff exit The patch was tested the following way: cvs co libdialog cd libdialog patch yesno.c < /path/to/aggressive.diff make cd TESTS cc -O -pipe -Wall -Wstrict-prototypes -static -I.. -L.. yesno.c -ldialog -lncurses -o yesno ./yesno The static linking and not using TESTS/Makefile saved me from installing the -CURRENT libdialog stuff on the -STABLE machine I did this modification on. virtually yours 82D1 9B9C 01DC 4FB4 D7B4 61BE 3F49 4F77 72DE DA76 Gerhard Sittig true | mail -s "get gpg key" Gerhard.Sittig@gmx.net -- If you don't understand or are scared by any of the above ask your parents or an adult to help you. >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010120184840.M253>