The Magic of Curses 117
This state of affairs, like institutionalized bureaucracies, would be livable
(though still not acceptable) if there were a workaround. Unix offers no
workaround, indeed, it gets in the way by randomly permuting control
commands that are sent to the VDT. A program that wants to manipulate
the cursor directly must go through more gyrations than an Olympic gym-
nast.
For example, suppose that a program places a cursor at location (x, y) by
sending an escape sequence followed by the binary encodings of x and y.
Unix won’t allow arbitrary binary values to be sent unscathed to the termi-
nal. The GNU Termcap documentation describes the problem and the
workaround:
Parameters encoded with ‘%.’ encoding can generate null charac-
ters, tabs or newlines. These might cause trouble: the null character
because tputs would think that was the end of the string, the tab
because the kernel or other software might expand it into spaces, and
the newline because the kernel might add a carriage-return, or pad-
ding characters normally used for a newline. To prevent such prob-
lems, tgoto is careful to avoid these characters. Here is how this
works: if the target cursor position value is such as to cause a prob-
lem (that is to say, zero, nine or ten), tgoto increments it by one, then
compensates by appending a string to move the cursor back or up
one position.