Using "am" or "xn" in programs considered harmful

Tony L. Hansen hansen at pegasus.UUCP
Sat Aug 23 14:15:40 AEST 1986


< Aha!  The problem is coming out!
< 
< Some people (Doug Gwyn for example) think "am" means this:
< 
< ...
< 
< On the other hand, Barry Margolin points out that "Applications need to
< know whether they can safely output to [column 80 of the last line]
< without causing the screen to scroll."  The above definitions provide
< no guidance about this; so some software appears to be assuming:
< 
< 	am@	terminal stays in col 80 after printing char there
< 
< This is the problem I've been facing.
< 
< So, let me modify my suggestion.  If "am" is set, you can assume that
< the cursor will move to the next line.  If "am" is not set, **you must
< not assume anything**.  In either case, you can't safely write to column
< 80 of the last line.
< 
< This would mean that removing "am" from a termcap entry would never
< cause it to fail.  That is what I am after.

I think it would be instructive to look at how the curses library assumes
that the am/xn interaction is supposed to work.  Taking a 24x80 terminal as
an example, after writing a character into the 80th column:

System Vr2 curses library:

am@, xn@	it assumes that the cursor has remained in the 80th column.
am, xn@		it assumes that the cursor has wrapped to the beginning
am, xn		it assumes that one of two things has happened:
		(vt100 like)
		the cursor is still in column 80 (or a mythical column 81)
		and would go to the beginning of the next one on the next
		character output
	or
		(concept like)
		if the next characters output are <CR> or <NL>, they will
		be ignored

		To handle both of these cases, it outputs <CR><NL> to force
		the cursor to go to the beginning of the next line.

The 4.2BSD curses library doesn't check xn at all, even though it does pull
in the flag from the termcap entry. If am@, it outputs <CR><NL> to force the
cursor to the beginning of the next line; otherwise it seems to assume that
the cursor has gone to the beginning of the next line on its own. (I can't
really check this out on a real 4.2 system because all of the 4.2 systems
that I have access to have converted to the System Vr2 terminfo-based
curses.

By the way, regarding placing a character into the last column (call it the
80th column) of the last line, the way that the System Vr3 curses library
handles this problem is to place the character that belongs in the 80th
column into the 79th column. It then moves back to the 79th column and
INSERTS the character that belongs in the 79th column, forcing the correct
character into the 80th column without causing the screen to scroll. If the
terminal can't do insert, it leaves the 80th column blank.

					Tony Hansen
					ihnp4!pegasus!hansen



More information about the Comp.bugs.4bsd.ucb-fixes mailing list