On 2020/06/03 14:49, Klemens Nanni wrote:
> On Wed, Jun 03, 2020 at 12:45:35PM +0100, Stuart Henderson wrote:
> > It should check terminal capabilities for this, see termcap(5).
> > If 'am' (auto-margin) is set then it shouldn't write to the final column.
> > If 'xn' is set then it's OK in some circumstances (it's probably easier to
> > skip writing to the final column if this is set too).
> Thanks mark and Stuart, I did not know about auto-margin (or autoWrap as
> xterm(1) seems to call it).
> 
> What I understand is that writing to the screen's last terminal should
> be avoided in terminal without the "am" capability, presumably because
> it would cause a line wrap - is that correct?
> 
> Preliminary testing however indicates to me that at least xterm(1)
> behaves the same in top's interactive screen with my patch, regardless
> of the auto-margin capablility.
> 
> According to termcap(5) I did the following to disable "am", with
> tput(1) I verify that it gets indeed disabled:
> 
>       $  echo $TERM ; tput am ; echo $?
>       xterm
>       0
>       $ TERM=vt100-nam ; tput am ; echo $?
>       1
> 
> But in both cases, starting ./obj/top in the very same terminal/shell
> behaves the same, that is to say the last column is written properly and
> I see no line wrap or any change of behaviour.
> 

termcap/TERM isn't an instruction to the terminal to behave in a
certain way, it describes characteristics of the actual terminal (or
terminal emulator). Most of the common X-based emulators don't have the
same characteristic. Even when they have something that looks similar
e.g. xterm in "autowraparound" mode, it isn't quite the same thing as
automargin as it only wraps when you've printed a char in the right-hand
column and then print an additional char.

It's quite possible you will need to find certain types of older real
hardware terminal to see the behaviour that requires 'am' handling.

(You *can* still print to the RH column of most lines with an auto-margin
terminal, as long as you don't send an extra linefeed. However you can't
write to the RH column of the bottom line of the screen without shifting
chars into place. The easy way out is to just not print to RH column on
am terminals).

Reply via email to