116 Terminal Insanity one place, by a device driver. Not every program or programmer is letter- perfect: operations like reading or writing to the disk should be done only in one place within the operating system, where they can be written once, debugged, and left alone. Why should terminals be treated any differently? Forcing programmers to be aware of how their programs talk to terminals is medieval, to say the least. Johnny Zweig put it rather bluntly: Date: 2 May 90 17:23:34 GMT From: zweig@casca.cs.uiuc.edu (Johnny Zweig) Subject: /etc/termcap Newsgroups: alt.peeves2 In my opinion as a scientist as well as a software engineer, there is no reason in the world anyone should have to know /etc/termcap even EXISTS, let alone have to muck around with setting the right envi- ronment variables so that it is possible to vi a file. Some airhead has further messed up my life by seeing to it that most termcaps have the idea that “xterm” is an 80x65 line display. For those of us who use the X WINDOWS system to display WINDOWS on our worksta- tions, 80x65 makes as much sense as reclining bucket seats on a bicycle—they are too goddamn big to fit enough of them on the screen. This idiot should be killed twice. It seems like figuring out what the hell kind of terminal I am using is not as hard as, say, launching nuclear missiles to within 10 yards of their targets, landing men on the moon or, say, Tetris. Why the hell hasn’t this bull been straightened out after 30 goddamn years of sweat, blood, and tears on the part of people trying to write software that doesn’t give its users the heebie-jeebies? And the first person who says “all you have to do is type ‘eval resize’ gets a big sock in the nose for being a clueless geek who missed the point. This stuff ought to be handled 11 levels of software below the level at which a user types a command—the goddamned HARDWARE ought to be able to figure out what kind of terminal it is, and if it can’t it should put a message on my console saying, “You are using piss-poor hardware and are a loser give up and get a real job.” —Johnny Terminal 2Forwarded to UNIX-HATERS by Olin Siebert.
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.
Previous Page Next Page