I have been looking at terminfo and it has delays, e.g. $<5>
, in the capability strings. I was trying to see through running tput
under strace
how is the delay implemented, i.e., whether it is implemented by, say, nanosleep
or by inserting NUL
or other characters. This is the command I have tried to run and trace:
TERM=ansi77 strace -o log.txt tput dl1
I chose dl1
on ansi77
because it is defined as dl1=\E[M$<5*/>
. However, all I see in the trace is write of 3 bytes:
write(1, "\33[M", 3) = 3
tput
?Agreeing with @cliffordheath that padding is done by adding padding characters, reference to the available documentation can help.
Hardware terminals did not cease to exist, they are still supported by ncurses. Without padding, these old terminals would not work properly (dropping or mangling your output). The vt100
entry uses padding, that for xterm
does not.
The terminfo name for the padding character is pad
; pc
is a termcap name (see terminfo(5)):
pad_char pad pc padding char
(instead of null)
The terminfo manual page has a lengthy paragraph (in Types of Capabilities) dealing with padding. There are two types of padding supported in terminfo format (advisory and mandatory), distinguished by their format. termcap supports only the latter (using different syntax of course), and unlike terminfo all of the delays happen at one time (making escape sequences for "flash" generally not work).
The command-line tput
program does more than act as a wrapper for the function tputs
, but it uses that when outputting strings. The command-line program provides for outputting boolean, numeric and of course string capabilities.
The library call tputs
has a parameter for the number of affected lines which is taken into account (like baud rate) in computing delays.
In OP's question
dl1=\E[M$<5*/>
specifies a delay proportional to the number of lines affected (marked by the "*"
character). The number of lines affected for the command-line tput
utility is 1. It calls putp
to do this. However, that in turn calls delay_output, and that calls baudrate. The last function is initialized only when the terminal is initialized. The command-line tput
does not initialize the terminal, so delays will not work for that. You should see (given the right speed) delays using the library itself.
ncurses also provides time delays with napms
(milliseconds), which is different from padding.