From nobody@FreeBSD.org  Wed Jul 14 23:52:55 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 96178106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 14 Jul 2010 23:52:55 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 6A45C8FC14
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 14 Jul 2010 23:52:55 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o6ENqtE7071262
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 14 Jul 2010 23:52:55 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o6ENqtM4071261;
	Wed, 14 Jul 2010 23:52:55 GMT
	(envelope-from nobody)
Message-Id: <201007142352.o6ENqtM4071261@www.freebsd.org>
Date: Wed, 14 Jul 2010 23:52:55 GMT
From: John Hixson <john@ixsystems.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: libdialog: printing to a checklist window on the first item from the selected callback prints behind the window.
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         148609
>Category:       gnu
>Synopsis:       [libdialog] [patch] 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:    imp
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 15 00:00:15 UTC 2010
>Closed-Date:    Thu Mar 13 22:22:01 MDT 2014
>Last-Modified:  Thu Mar 13 22:22:01 MDT 2014
>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:

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/148609: commit references a PR
Date: Tue, 24 Aug 2010 06:31:12 +0000 (UTC)

 Author: imp
 Date: Tue Aug 24 06:30:46 2010
 New Revision: 211731
 URL: http://svn.freebsd.org/changeset/base/211731
 
 Log:
   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.
   
   The fix, from the pr:
   	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 =).
   
   PR:		148609
   Submitted by:	John Hixson
 
 Modified:
   head/gnu/lib/libdialog/checklist.c
 
 Modified: head/gnu/lib/libdialog/checklist.c
 ==============================================================================
 --- head/gnu/lib/libdialog/checklist.c	Tue Aug 24 06:11:46 2010	(r211730)
 +++ head/gnu/lib/libdialog/checklist.c	Tue Aug 24 06:30:46 2010	(r211731)
 @@ -198,6 +198,24 @@ draw:
      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);
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: brucec 
State-Changed-When: Thu Feb 24 13:28:33 UTC 2011 
State-Changed-Why:  
MFC reminder. 


Responsible-Changed-From-To: freebsd-bugs->imp 
Responsible-Changed-By: brucec 
Responsible-Changed-When: Thu Feb 24 13:28:33 UTC 2011 
Responsible-Changed-Why:  
MFC reminder. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=148609 
State-Changed-From-To: patched->closed 
State-Changed-By: imp 
State-Changed-When: Thu Mar 13 22:21:50 MDT 2014 
State-Changed-Why:  
in 10, so can close. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=148609 
>Unformatted:
