[net.unix-wizards] Curses library for USG

gwyn@brl-vld.arpa (03/05/83)

From:      Doug Gwyn (VLD/VMB) <gwyn@brl-vld.arpa>

I have curses/termlib running under our System III emulation; the _doprnt
replacement is trivial (enclosed below), and the stty stuff works if you
#define	CBREAK RAW in curses.h .

_sprintw(win, fmt, args)
WINDOW	*win;
char	*fmt;
int	*args; {
	extern FILE	*_pfile;
	FILE	junk;
	char	buf[512];

	junk._flag = _IOWRT + _IOSTRG;
	junk._ptr = buf;
	junk._cnt = 32767;
	_pfile = &junk;
	_print(fmt, &args);
	*junk._ptr = '\0';
	return waddstr(win, buf);
}

guy (03/31/83)

1) Are you emulating System 3 under some other version of UNIX, or vice versa?
Does System 5 come with termcap, since Bell claims it comes with 'vi'?
Also, since Bell did 'terminfo', did they do it under 4.?BSD or USG, and did
they set it up to work under both?

2) A better way to turn on CBREAK mode is to turn off ICANON in the 'c_lflag'
word of the 'terminfo' structure (the trouble with RAW - I assume this is
using 'stty'/TIOCSETP USG 2.0 emulation - is that it turns off parity checking/
generation AND XON/XOFF handling (a subject near and dear to the hearts of
us VT100 users)), and turn off ISIG too if you don't want the interrupt and
quit characters coming through.  (For the benefit of screen editors, you
can turn on NOFLSH in the 'c_lflag' word too - beware, though, this means that
if you hit the interrupt character key the interrupt character will appear
on your input clist, at least in 3.0.  Flush the input (not output) queue
if you get an interrupt...)

Other Hints from Heloise (who hasn't actually worked much with the USG driver
but has read the manual pages and the code):

Remember to turn IXANY *OFF!* in the 'c_iflag' word if you're working on a
terminal that is fussy about XON/XOFF.  Running on a smooth-scrolling VT100
under a UNIX with an unmodified V7 TTY driver is an interesting experience,
especially if you hit a key while it's scrolling...that's probably why Bell
made IXANY a bit and why Berkeley put in LDECCTQ.

There is a bug in the no-delay read code in the distributed driver; somebody
at Bell found it and fixed it while bringing up EMACS on 3.0.  Unmodified, it
always says there are no characters in the input queue.

Note that you can control a lot of things you couldn't control under other
drivers; for example, you can tell it to ignore the carrier line (useful for
those of us who can't make null modem cables worth a d*mn), or to use 5 bits
per character (we *have* done applications - under V6 - where we connected
to Baudot lines), or disable the receiver, and several other things.  The
TANDEM mode (called IXOFF) transmits the XON/XOFF when the next transmitter
interrupt comes, rather than putting it on the output queue, so the response
is quicker.

					Guy Harris
					RLG Corporation
					{seismo,mcnc,we13}!rlgvax!guy