The Boston Diaries

The ongoing saga of a programmer who doesn't live in Boston, nor does he even like Boston, but yet named his weblog/journal “The Boston Diaries.”

Go figure.

Sunday, June 28, 2015

It's rather simple, but you would never know it

Rob Landley is right—terminal control is obsolete. Precious few have actual terminals, and those of us who still use command line interfaces are using software programs that emulate physical devices talking to other software programs that emulate physical devices. Furthermore, all those software programs emulating physical devices have pretty much converged on using ANSI terminal control codes, so much of the reason for termcap has gone away.

So now it should be a simple matter to look up ANSI terminal control codes to see what to send to scroll the screen to the left, right?

Yeah

And lest you think that page on xterm control codes is intentionally incomprehensible, it's not. Well, it is incomprehensible, and it may be intentional, bit it's not alone. They are all pretty abysmal. And they're all pretty abysmal because the actual standard, ECMA-48, is pretty abysmal as standards go.

Here's a representative sample:

5.3 Elements of the C1 set

These control functions are represented

a) in a 7-bit code by 2-character escape sequences of the form ESC Fe, where ESC is represented by bit combination 01/11 and Fe is represented by a bit combination from 04/00 to 05/15;

b) in an 8-bit code by bit combinations from 08/00 to 09/15; however, when the announcer sequence ESC 02/00 04/06 according to Standard ECMA-35 is used, the control functions of the C1 set are represented by ESC Fe sequences as in a 7-bit code.

and here's a translation into more modern terminology:

5.3 Elements of the extended ASCII control set

These control functions are represented

a) in a 7-bit code by a 2-character escape sequence of the form <ESC> <Fe>, where <ESC> is ASCII character 0x1B and <Fe> is ASCII characters 0x40 ('@') through 0x5F ('_');

b) in an 8-bit code by byte values between 0x80 and 0x9F; however, when the sequence <ESC> ‘ ’ ‘F’ (0x1B 0x20 0x46) according to Standard ECMA-35 is used, the control functions of the C1 set are represented by <ESC> <Fe> sequences as in a 7-bit code.

Yes, the ECMA standards represent characters using a (to me) bizarre column-based format which are kind of hexadecimalesque (4/13 is column 4, row 13) without being actual hexadecimal (0x4D), which makes reading the standard a bit more difficult. It was only reading these old standards in conjunction with this page did is start making a bit of sense.

For instance, on the xterm reference page, there's the sequence “APC Pt ST” but it's never defined what APC or ST actually are, but Pt is defined to be `printable text.” It's only by reading the other documentation closely that you realize that the sequence will either be

0x9F <printable text> 0x9C

or

0x1B ‘_’ <printable text> 0x1B ‘\’

Which is beside the point, because xterm will ignore such sequences anyway.

Sigh.

The sequences themselves are pretty simple; it's just the presentation that universally sucks (and all the presentations except the ECMA-48 one assume you have read and understand the ECMA-48 standard).

Obligatory Picture

[It's the most wonderful time of the year!]

Obligatory Contact Info

Obligatory Feeds

Obligatory Links

Obligatory Miscellaneous

You have my permission to link freely to any entry here. Go ahead, I won't bite. I promise.

The dates are the permanent links to that day's entries (or entry, if there is only one entry). The titles are the permanent links to that entry only. The format for the links are simple: Start with the base link for this site: http://boston.conman.org/, then add the date you are interested in, say 2000/08/01, so that would make the final URL:

http://boston.conman.org/2000/08/01

You can also specify the entire month by leaving off the day portion. You can even select an arbitrary portion of time.

You may also note subtle shading of the links and that's intentional: the “closer” the link is (relative to the page) the “brighter” it appears. It's an experiment in using color shading to denote the distance a link is from here. If you don't notice it, don't worry; it's not all that important.

It is assumed that every brand name, slogan, corporate name, symbol, design element, et cetera mentioned in these pages is a protected and/or trademarked entity, the sole property of its owner(s), and acknowledgement of this status is implied.

Copyright © 1999-2021 by Sean Conner. All Rights Reserved.