From tim@X3000  Wed Jul 24 23:06:43 1996
Received: from X3000 (ppp1602.on.sympatico.ca [206.172.249.66])
          by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id XAA19620
          for <FreeBSD-gnats-submit@freebsd.org>; Wed, 24 Jul 1996 23:06:40 -0700 (PDT)
Received: (from tim@localhost) by X3000 (8.7.5/8.7.3) id FAA00927; Wed, 24 Jul 1996 05:51:40 -0400 (EDT)
Message-Id: <199607240951.FAA00927@X3000>
Date: Wed, 24 Jul 1996 05:51:40 -0400 (EDT)
From: Tim.Vanderhoek@X3000 (root@freebsd.org)
Reply-To: ac199@freenet.hamilton.on.ca
To: FreeBSD-gnats-submit@freebsd.org
Subject: ncurses doesn't always display ALTCHARSET correctly.
X-Send-Pr-Version: 3.2

>Number:         1428
>Category:       misc
>Synopsis:       ncurses doesn't always display ALTCHARSET correctly
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    hoek
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 24 23:10:04 PDT 1996
>Closed-Date:    Sat May 20 20:54:39 PDT 2000
>Last-Modified:  Sat May 20 21:00:07 PDT 2000
>Originator:     Tim Vanderhoek
>Release:        FreeBSD 2.2-960501-SNAP i386
>Organization:
Cluttered
>Environment:

	An aging -SNAP of 2.2 (960501).  Standard, otherwise.  Mach64ct,
in case that matters.  I am not running this from an Xterm, however X
is running on a different virtual terminal.  Problem tested and verified
under both standard `sh' and `bash'.

>Description:

	ncurses supports the display of IBM high-half and ROM characters
on PC-clones (ie. my computer).  This support is enabled via the
A_ALTCHARSET highlight.  The problem is that these characters are
not correctly displayed until refresh(curscr) (or some-such) is 
called, even though ncurses believes they are being correctly displayed
(which is proven by the fact that it allocates only one character's
space for the character).

	See the comments within the how-to-repeat C example for the 
same, but worded differently.

>How-To-Repeat:

/* The following features are present in this demo;
 *
 * Press any key and it will be echo'ed to the screen at the
 * beginning of a line.  An arrow will point to it.  The 
 * ascii base-10 value of the key will also be printed.
 *
 * Press the END key to terminate the program.
 *
 * Press Ctrl-Z to suspend.
 *
 * Press F10 to send the program a SIGSTOP (non-cathable suspend).
 * 
 * Press F1 to force a screen redraw using refresh(curscr).
 *
*You should observe the following behaviour;
 *
 * When you enter what should be printed as an IBM half-high or ROM 
 * character, it is not displayed as such.  Rather, you see only the
 * `^' character.  If you whatch closely, you will see that two
 * characters are printed, but space is only allocated to one.  This
 * is probably because ncurses (correctly) assumes that A_ALTCHARSET 
 * is on and thus allocates only one space.  However, since
 * A_ALTCHARSET isn't working, two characters are printed.
 * If you do not turn on A_ALTCHARSET you will see that two character
 * spaces are allocated and printed in.
 *
 * When you suspend the program and type `fg', all characters are
 * redisplayed correctly.  (Proceeding IBM characters are not).
 *
 * When you press F1 to force a screen refresh with refresh(curscr)
 * all characters are displayed correctly.  (Proceeding IBM characters
 * are not).
 */

#include <ncurses.h>
#include <signal.h>

main ()
{
	int c;

	initscr ();
	atexit (endwin);

	raw ();
	echo ();
	keypad (stdscr, 1); /* Lets us catch stuff like KEY_UP 
	                     * doesn't seem to affect problem */
	nodelay (stdscr, 1);

	attron (A_ALTCHARSET);

	while (1) {
		c = getch ();
		if (c == KEY_F(1)) {
			wrefresh (curscr); /* force full refresh */
			printw("<--echo'ed character.  %#0x  (Did a refresh)\n",
					c);
		} else if (c != ERR) printw ("<--echo'ed character.  %x\n", c);
		refresh ();
	/* Press the END key to exit. */
		if (c == KEY_END) exit (0);
	/* Press Ctrl-Z to suspend. */
		if (c == 26) kill (getpid(), SIGTSTP);
	/* Press F10 to do a non-catchable suspend. */
		if (c == KEY_F(10)) kill (getpid(), SIGSTOP);
	}
}

>Fix:
	
	I suspect this is a problem with the port of ncurses to FreeBSD.
The work-a-round demonstrated in the How-To-Repeat is to call 
refresh(curscr).
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: phk 
State-Changed-When: Tue Apr 14 12:09:48 PDT 1998 
State-Changed-Why:  
can this be closed ? 

From: Tim Vanderhoek <hoek@hwcn.org>
To: Poul-Henning Kamp <phk@FreeBSD.ORG>
Cc: ac199@freenet.hamilton.on.ca, freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: misc/1428
Date: Tue, 14 Apr 1998 18:47:49 -0400 (EDT)

 On Tue, 14 Apr 1998, Poul-Henning Kamp wrote:
 
 > Synopsis: ncurses doesn't always display ALTCHARSET correctly
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: phk
 > State-Changed-When: Tue Apr 14 12:09:48 PDT 1998
 > State-Changed-Why: 
 > can this be closed ?
 
 No.  The test program included still fails last time I tried it
 (~month ago).
 
 
State-Changed-From-To: feedback->open 
State-Changed-By: hoek 
State-Changed-When: Fri Jul 3 15:57:10 PDT 1998 
State-Changed-Why:  
Submitter responds: "No, this can't be closed." 
Responsible-Changed-From-To: freebsd-bugs->hoek 
Responsible-Changed-By: asmodai 
Responsible-Changed-When: Mon Jan 10 09:41:35 PST 2000 
Responsible-Changed-Why:  
Allow Tim to close his own pr's. 

Sidnote: CURRENT now has ncurses 5.0 (beta) and peter is preparing 
an import of the official released version of 5.0.  Is the problem 
still present? 
State-Changed-From-To: open->closed 
State-Changed-By: hoek 
State-Changed-When: Sat May 20 20:54:39 PDT 2000 
State-Changed-Why:  
The problem doesn't appear to duplicate as described in the PR.  I'm 
not entirely sure it's fixed; I'd need to examine ncurses more closely 
to determine the actual expected behaviour, but I think it's fixes. 
Regardless, I submitted the PR, and, as submitter, I'm going to stand 
on my copyright and refuse to allow FreeBSD permission to distribute 
this as an open bugreport anymore.  Jordan may speak to my lawyer if 
he doesn't like that. 

I know Thomas Dickey used to do kibozing for ncurses ncurses ncurses 
ncurses ncurses references.  If you still do that, I'd ncurses appreciate 
it if you'd tell me ncurses what's supposed to be displayed for characters 
say in range 0-31 when attron(A_ALTCHARSET) is active.  I'm getting 
stuff ncurses like "^D".  Is this correct? 
>Unformatted:
