In the beginning, there was the command line...

The command line was great and powerful, but unfulfilling for some tasks. Perhaps the most important of these tasks was editing text files, something UNIX was used for frequently in the early days. One of the original uses of the earliest UNIX systems was to author official AT&T publications, hence the Documenter's Workbench (see the Heirloom Documentation Tools page for more information).

The "standard" editor on UNIX was ed, an ancient, untamable beast; a line editor. For the longest time, ed was the only text editor that was guaranteed to be present on any given UNIX system, and almost certainly the only one available in single user mode, for fixing broken things.

read on for more...

Although a post and tutorial on ed might be fun and instructive, that's not what this one is about. This is more about the successors to ed, and the technology that made them possible.

What came after ed was ex, and vi. ex was an improvement to ed written by Bill Joy in 1976, and vi was (and still is!) its screen editing counterpart.

Line editor? Screen editor?

Today, most readers have experience with graphical editors and word processors: Notebook, gedit, MS Word, OpenOffice and the like. These editors run on graphical desktop displays like Windows of X, and have many advanced features, such as mouse control, cutting and pasting, and others. But before the advent of the graphical desktop in the early 1990s, there were only character-based interfaces like UNIX, MS-DOS, and others. No mice, no graphics, just text.

The earliest of these interfaces actually ran on typewriter-like terminals where everything one typed was printed on a printer with a big roll of paper, along with the computer's response. As one might imagine, this was not a great environment for editing files, and hence the line editor. In order to conserve paper, ink, and time, operations were performed on lines of text. Well, it worked for the technology at hand, but as the technology improved, so did text editing.

There have been many advances in text editing, to say nothing of word processing, over the years, but one of the first was the idea of the screen editor, which was developed in response to the character addressable video display terminal. Unlike "dumb terminals", these could change the position of the cursor on the screen and then place characters there under program control. This was a huge advance, because for the first time, it allowed for "full screen editing".

In full screen editing, instead of working on lines as in line editing, one works on screens. Because the terminal is much quicker and there is no waste of paper or ink, it is possible to move around in a large document very quickly, to see the structure of the document, and to make changes much more visually than was possible in a line editor. The improvement was so compelling, that the day of the line editor ended almost overnight.

There was, however, at least one challenge: as the number of video display terminals from different manufacturers grew, so did the character control sequences. Of course there was no standard, and pretty quickly there were hundreds of different terminals available. And also of course, it was impossible to code all the various control sequences into the editor so that it would work correctly with whatever terminal you were using. This is the challenge that Bill Joy solved in 1976 when he wrote the vi editor. Bill wrote vi and designed a terminal-independent library and database that was known as TERMCAP. Ken Arnold later improved the system, resulting in the curses library, which was distributed with the first versions of BSD UNIX and made it onto the AT&T code a bit later. Even later, the curses system was further refined into terminfo by Mark Horton at AT&T, providing more sophisticated and higher performance access to the growing list of terminals and their capabilities.

In the end, what all this gave us were a large number of full screen applications developed with the curses library: editors, email clients, USENET clients, full screen ftp clients, games, and a large variety of office automation applications. Curses was, and still is a marvelous system that is remains in use today by millions of hard-core UNIX people, from developers, to everyday folks.

As a modern example of a curses application, I submit calcurse, a full screen, character based calendar, todo, and appointment setting system written with curses by Frédéric Culot, an astrophysicist and programmer from Luxembourg.

calcurse.jpg

It is similar to some of the graphics programs with like functionality, but because of its curses interface, it is keyboard, not mouse controlled, and it is blindingly fast.

It is an Open Source program that I have uploaded into the Document repository for this group. It should prove instructional to those desiring to learn curses development or who are just interested in this technology.

Have fun!