[comp.unix.questions] Termcap/terminfo

chris@mimsy.UUCP (Chris Torek) (11/11/87)

In article <3059@psuvax1.psu.edu> flee@gondor.psu.edu (Felix Lee) writes:
>Anyone want to know the semantics of xenl/xn?

Perhaps terminfo defines this better.  In termcap, unfortunately,
`xn' does not describe cursor positioning when a character is
printed at the end of a line.  Instead, it merely says that the
terminal is guaranteed to eat a newline that is printed immediately
after that character, and that once this is done, the cursor will
then be at the beginning of the next line.

Why does this matter?  Here is an example.  I once wrote a screen
management package (the Maryland Window Library, for those of you
with long memories).  I wanted to be able to write the last character
of each line, including the last line.  To do this I must know
whether the cursor will advance and the screen will scroll.  Termcap
does not tell me.

There exist terminals on which writing the last character of any
line immediately wraps the cursor to the beginning of the next
(possibly scrolling), after which the terminal consumes one newline
without action.  There are others on which writing the last character
of any line puts the cursor in a `virtual' position, such that the
*next* printing character (if any) prints in the first column of
the next line, moving the cursor to column 2 of that line.  On the
second kind of terminal, a newline printed while the cursor is in
its virtual column moves it to column 1 of the next line (possibly
scrolling).  `:am:xn:' describes both.

Alas!, `xn' is tied deeply to the implementation of the editor vi:
vi's response to `xn' is simply to print a newline, feeding the
terminals that consume one and scrolling those that do not.  This
is fine for vi; it wants the screen to scroll.  I do not.  I want
to distinguish between these two kinds of `am' terminals---the one
that scrolls immediately and the one where I can move the cursor
to prevent scrolling---but termcap does not tell.

(If anyone cares, my Window Library assumes that `xn' describes
the terminal with the virtual column.  The code *is* 5 years old:
I know better now, but have not the time to fix it.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris

gwyn@brl-smoke.UUCP (11/12/87)

In article <9290@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes:
>I wanted to be able to write the last character
>of each line, including the last line.  To do this I must know
>whether the cursor will advance and the screen will scroll.  Termcap
>does not tell me.

On terminals like the VT100, what happens in this case depends
strongly on what is output next.  The actual 8085 algorithm in
the VT100 has several quirks that are not feasible to describe
in a regular fashion (e.g. termcap).  On such a terminal it is
best to avoid displaying characters in the last column.  Sorry
about that but I didn't design the bloody terminal.