Subject: Re: bin/10116: vi somewhat easily confused by suspension
To: None <gnats-bugs@gnats.netbsd.org, tech-userlevel@netbsd.org>
From: ITOH Yasufumi <itohy@netbsd.org>
List: tech-userlevel
Date: 05/22/2000 14:22:23
J.D.Coleman@newcastle.ac.uk writes:

> That's true.  However, that is the way the specification is written - if you
> call wgetch(win) after keypad(win, FALSE), you will not get the application
> keypad sequence; if you call wgetch(win) after keypad(win, TRUE), you will
> get the keycode, not the sequence.

The specification says
<http://www.opengroup.org/onlinepubs/007908799/xcurses/keypad.html>:

|	If the terminal in use requires a command to enable it to transmit
|	distinctive codes when a function key is pressed, then after keypad
|	translation is first enabled, the implementation transmits this
|	command to the terminal before an affected input function tries to
|	read any characters from that terminal.

the keypad is enabled when translation is first enabled,
it does NOT say the keypad is disabled when translation is disabled.

I think the "first" imply that the "keypad enable" sequence is not
sent on the second time and later.
If the keypad is disabled when translation is disabled, the "first"
was not necessary (enable keypad every time).

>                                     I admit that this doesn't happen under
> Solaris (all SysV curses?) because it doesn't comform to the specification.

So, I don't think Solaris curses breaks the spec.

> However, ncurses does what our curses now does, so such a program won't work
> there either.

Solaris curses is the better reference implementation compared to ncurses
for SUSv2 compliant, from my experience.
One of the reasons we don't adopt ncurses is that it is buggy, isn't it? :-)

Thoughts?


For audience:)
Terminology
    "keypad"
	`Function (F1, F2, ...) keys' `Arrow keys' `Page Up' `Help' etc.

    "enable keypad"
	Some terminals need sending initialization string to enable
	the "keypad" keys.  If the keypad is enabled, the sequence
	sent by a keypad key can be known by an application program
	from termcap.

    "disable keypad"
	Sending a string to a terminal which cancels "enable keypad".
	The sequence sent by a keypad key becomes unknown (but may be
	useful for programs which doesn't recognize keypad keys).

    "translation"
	Conversion of the sequence of the "keypad" keys to unique
	integer (keycode).

    "enable translation"
	Set a flag in curses to enable "translation".
	The application receives a keycode for a keypad key.

    "disable translation"
	Clear a flag in curses to disable "translation".
	The sequence of a keypad key is sent directly to the application.

Summary

sample code:
	initscr();
	/* (1) */
	keypad(win, TRUE);	refresh();
	/* (2) */
	keypad(win, FALSE);	refresh();
	/* (3) */
	keypad(win, TRUE);	refresh();
	/* (4) */
	endwin();
	/* (5) */

A. ncurses and current our curses
		keypad		translation
	(1)	disabled	disabled
	(2)	enabled 	enabled	
	(3)	disabled	disabled
	(4)	enabled 	enabled
	(5)	disabled	?

B. Solaris
		keypad		translation
	(1)	disabled	disabled
	(2)	enabled 	enabled	
	(3)	enabled 	disabled
	(4)	enabled 	enabled
	(5)	disabled	?

Julian supports A; I support B.
-- 
ITOH, Yasufumi