Termcap, IC, and IM

Chris Torek chris at mimsy.UUCP
Tue Aug 29 05:18:38 AEST 1989


In article <1989Aug28.151908.24779 at agate.uucp> jym at anableps.berkeley.edu
(Jym Dyer) writes:
>... Richard Stallman's excellent Termcap manual ... tells me that if
>just inserting a character in insert mode (IM) is sufficient, there's
>no need to define insert character (IC).

This is correct.

>A DEC manual says that if you do define IC, IM should be defined in the
>termcap file as ":im=:".

This is almost correct.

(But then, I suppose that should not be surprising, given the authors :-) )

Programs using termcap that want to insert characters are required to:

 0. Enter insert mode.  This could be the same as delete mode.  (There
    are terminals that make `backspace' delete characters when in
    `edit' mode.)
 1. Send each character surrounded by `ic' and `ip' sequences.

That is, if we had `im=X', `ic=Y', and `ip=Z', the sequence to insert
four characters (presuming the terminal is not already in insert mode)
`abcd' is:

	XYaZYbZYcZYdZ

There is an exception to rule 1 (sort of): if `IC' is defined, it
should be sent (with its numeric parameter expanded) before all of the
characters to be inserted; the parameter is the number of characters to
be inserted.  4BSD vi actually sends IC and ic and ip, I think.

If a terminal or terminal emulator has an escape sequence both for
`create space for one character' and for `enter insert mode', where the
former can be used without the latter, and vice versa, the latter is
generally better since long insert sequences will take less text.  Vi
and emacs both generally believe that insertion is `free', if it can be
done at all, so it is best to make it so.

After inserting, and before sending normal characters, if insert
mode is the same as delete mode, applications must exist insert mode.
(Insert mode and delete mode are the same if `im' and `dm' contain
the same strings.)  Before using cursor motion, if `mi' is not set,
the application must exit insert mode.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.questions mailing list