Klemens Nanni wrote in <20200603124948.irvdnxrxa5g75pmi@eru>: |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.
I do not think that you en- or disable "am", it indicates whether the terminal has the capability or not. I have n_TERMCAP_QUERY_am, /* am/am, BOOL | auto_right_margin */ n_TERMCAP_QUERY_sam, /* sam/YE, BOOL | semi_auto_right_margin */ n_TERMCAP_QUERY_xenl, /* xenl/xn, BOOL | eat_newline_glitch */ ... ^^terminfo/termcap^^ names | terminfo variable eat_newline_glitch ensures that \n written after margin does not cause a line wrap. /* TODO We do not handle !n_TERMCAP_QUERY_sam in this software! */ if(!n_termcap_query(n_TERMCAP_QUERY_am, &tv) || n_termcap_query(n_TERMCAP_QUERY_xenl, &tv)) n_psonce |= n_PSO_TERMCAP_FULLWIDTH; ... /* Then search for right boundary. Dependent upon n_PSO_FULLWIDTH (termcap * am/xn) We leave the rightmost column empty because some terminals * [cw]ould wrap the line if we write into that, or not. * TODO We do not deal with !n_TERMCAP_QUERY_sam */ --End of <20200603124948.irvdnxrxa5g75pmi@eru> --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt)