Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Jul 2010 23:52:55 GMT
From:      John Hixson <john@ixsystems.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/148609: libdialog: printing to a checklist window on the first item from the selected callback prints behind the window.
Message-ID:  <201007142352.o6ENqtM4071261@www.freebsd.org>
Resent-Message-ID: <201007150000.o6F00F7X069066@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         148609
>Category:       bin
>Synopsis:       libdialog: printing to a checklist window on the first item from the selected callback prints behind the window.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 15 00:00:15 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     John Hixson
>Release:        9.0-CURRENT
>Organization:
iXsystems, Inc
>Environment:
FreeBSD thinkbsd 9.0-CURRENT FreeBSD 9.0-CURRENT #0: Tue Jul 13 09:31:39 PDT 2010     john@thinkbsd:/usr/src/sys/amd64/compile/THINKBSD  amd64

>Description:
I'm writing a program using libdialog and would like to print to the checklist window from the selected() callback. This works fine for every item in the menu except the very first. I've determined that when printing from the selected() callback, the printed strings get printed behind the window on the main screen for the very first item when the dialog first pops up. Every item afterwards when the selected() callback is fired, prints correctly. When going back to the first item after going to another item, it prints correctly as well. This seems like a bug to me =).
>How-To-Repeat:
Create a checklist and call one of the *printw() functions from the selected() callback. When the dialog first appears, you will not see the printed statement on the dialog, if you move down one, you will, move up again and it now appears. I am assuming that you call a *printw() function on a line in the dialog box of course. 
>Fix:
This is a hack at best, I looked at the redraw code in dialog_checklist() and took the minimal amount of it out to do a simple "refresh" right after the items are drawn. This doesn't hurt anything and makes the library work like it should. There is probably a better way however =). 

Patch attached with submission follows:

diff -urN gnu/lib/libdialog.orig/checklist.c gnu/lib/libdialog/checklist.c
--- gnu/lib/libdialog.orig/checklist.c	2005-01-04 03:30:24.000000000 -0800
+++ gnu/lib/libdialog/checklist.c	2010-07-14 16:40:15.000000000 -0700
@@ -198,6 +198,23 @@
     wnoutrefresh(dialog);
     wmove(list, choice, check_x+1);
     wrefresh(list);
+
+	/*
+	 *	XXX Black magic voodoo that allows printing to the checklist
+	 *	window. For some reason, if this "refresh" code is not in place,
+	 *	printing to the window from the selected callback prints "behind"
+	 *	the checklist window. There is probably a better way to do this.
+	 */
+    draw_box(dialog, box_y, box_x, list_height + 2, list_width + 2, menubox_border_attr, menubox_attr);
+
+    for (i = 0; i < max_choice; i++)
+	print_item(list, items[i * 3], items[i * 3 + 1], status[i], i, i == choice, DREF(ditems, i), list_width, item_x, check_x);
+    print_arrows(dialog, scroll, list_height, item_no, box_x, box_y, check_x + 4, cur_x, cur_y);
+
+	wmove(list, choice, check_x+1);
+	wnoutrefresh(dialog);
+    wrefresh(list);
+	/* XXX Black magic XXX */
     
     while (key != ESC) {
 	key = wgetch(dialog);


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201007142352.o6ENqtM4071261>