[net.emacs] Termcap insert mode

chris@umcp-cs.UUCP (Chris Torek) (10/13/85)

>< From the list of capabilities from Termcap(5) BSD4.2 (it is the same on
>< Sun Version 2, also):
>< 
><      ei     str         End insert mode; give ":ei=:" if ic
><      im     str         Insert mode (enter); give ":im=:" if ic
><     

> Actually, in this case I've always considered the termcap manual
> page to be plain wrong. Current usage of both termcap and terminfo,
> in curses, for example, assumes that ei and im are only defined if
> they really have some meaning. The same statement can be made for
> all string variables.
>					Tony Hansen

You are, I believe, speaking of System V; so this may not apply
there.  Under 4BSD, however, the manual entry is correct, if cryptic.
The code in `vi' runs approximately like this:

	imstr = tgetstr("im", &p);
	eistr = tgetstr("ei", &p);
	icstr = tgetstr("ic", &p);
	ipstr = tgetstr("ip", &p);
	.
	.
	.
	/* enter insert/append mode */
	if (imstr != NULL && eistr != NULL) {
		/*
		 * Terminal has insert capability, use it.
		 */
		tputs(imstr, ...);
		while ((c = getchar()) != ESCAPE) {
			if (icstr != NULL)
				tputs(icstr, ...);
			putchar(c);
			if (ipstr != NULL)
				tputs(ipstr, ...);
		}
		tputs(eistr, ...);
	} else {
		/*
		 * No insert mode, fake it if redraw set.
		 */
		.
		.
		.
	}

The `im' and `ei' capabilities *must be set*, even if they are set
to the null string.  If they are not set, vi will not send the `ic'
and `ip' strings, though your terminal may need only those.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@mimsy.umd.edu