ncurses: Portable Screen-Handling for Linux
Much has changed in the last year, out of sight of the Linux community at large. We have fixed many bugs and filled out the API. We've written more complete documentation, including man pages. We've done extensive compatibility testing against SVR4, linking identical programs to both libraries and comparing behavior. We've audited the code carefully for cross-platform portability and replaced a rather clunky home-brewed configuration system with GNU autoconf. We've tested the code for memory leaks with Purify and improved argument validation in many critical functions. The overall quality of the code has been dramatically improved.
We've also added several Bell Labs-like utilities missing from older ncurses versions, including:
infocmp(1) a terminfo entry lister and comparator.
captoinfo(1) a termcap to terminfo translator.
clear(1) a trivial screen clearer.
tput(1) a terminfo capability access for shell scripts.
The captoinfo, clear, and tput utilities are based on code from Ross Ridge's mytinfo package (which we've effectively subsumed).
We chose System V Release 4.0 curses as our emulation target, and now support all of its very extensive features. We also include a clone of the SVR4 panels library, a curses extension that makes it easy to program stacks of windows with backing store.
The new ncurses package also includes a full and up-to-date set of man pages organized similarly to SVR4's.
In a few areas, we go beyond SVR4 curses, for example:
The new cursor-movement optimizer and incremental-screen-update algorithms are smarter than the Bell Labs versions (and much smarter than the BSD versions) leading to significant update-speed gains for slow terminals.
Unlike previous curses versions, ncurses can write the lower right hand corner cell of a terminal with automargin wrap (provided it has an insert-character capability).
On Intel boxes, curses permits you to display not just the IBM high-half characters but also the ROM graphics in characters 0-31.
Our terminfo tools recognize all the terminfo and termcap extensions found in GNU termcap, mytinfo, and the University of Waterloo libraries.
We feature a C++ class derived from the libg++ CursesWindow class, but enhanced for ncurses.
The ncurses suite now includes an ncurses program which allows you explicitly test most of ncurses's capabilities on any new platform.
We've souped up the tracing feature. It is now possible to pick one of several levels of output tracing, and the trace log has been made easier to interpret (with symbolic dumping of screen attributes, colors, and so forth).
Automatic fallback to the /etc/termcap file can be compiled in for systems without a terminfo tree. This feature is neither fast nor cheap, so you don't want to use it unless you have to.
Along with ncurses, you get a very complete terminfo file. I accepted the maintainer's baton for the 4.4BSD master termcap file from John Kunze in January 1995; I've since translated it to terminfo and added a lot of information from vendors like SCO, Digital Equipment Corporation, and Wyse. (The terminfo file is available separately from my WWW home page, www.ccil.org/~esr/home.html.)
Listing 1 gives a program skeleton that illustrates how to set up to use some of the new features.
Note the way we arrange for endwin() to get called by the signal catcher. This is necessary, otherwise a stray signal might leave the tty modes in a less than useful state.
Our next program fragment illustrates the use of the keypad mapping feature. This code, from an actual test program distributed with ncurses, is shown is Listing 2.
The example code illustrates how you can get function key tokens as single values outside the ASCII range from getch(). The call keypad(stdscr, TRUE) sets this up.
The ncurses distribution contains a more detailed tutorial in HTML form and also has several code examples in the test directory.
The ncurses library seems to have achieved a stable plateau, suitable for production use, in the 1.9.1 and 1.9.2 releases. We're looking ahead to some interesting possibilities—most notably at supporting XPG4 Curses extended-level features for wide and multi-byte character sets. We're also thinking about MS-DOS and MS-Windows ports.
With the features we already have in a freeware library, you may be wondering whether there are good reasons for BSD curses to continue to exist. The answer is “probably not”.
Keith Bostic, maintainer of BSD curses, has agreed that if ncurses 1.9 proves stable and usable with nvi (new vi), he will switch to ncurses for the nvi distribution and pronounce BSD curses officially dead. The ncurses library has already been used to successfully support nvi for production, so it's a good bet that by the time you read this, Keith will have finished his testing—and BSD curses will be history.
This, in turn, means the Unix world will finally get a common freeware API that supports color, multiple highlights, and all the other capabilities common to PC consoles and today's character-cell terminals.
|Red Hat Enterprise Linux 7.1 beta available on IBM Power Platform||Jan 23, 2015|
|Designing with Linux||Jan 22, 2015|
|Wondershaper—QOS in a Pinch||Jan 21, 2015|
|Ideal Backups with zbackup||Jan 19, 2015|
|Non-Linux FOSS: Animation Made Easy||Jan 14, 2015|
|Internet of Things Blows Away CES, and it May Be Hunting for YOU Next||Jan 12, 2015|
- Designing with Linux
- Wondershaper—QOS in a Pinch
- Red Hat Enterprise Linux 7.1 beta available on IBM Power Platform
- Internet of Things Blows Away CES, and it May Be Hunting for YOU Next
- Ideal Backups with zbackup
- Slow System? iotop Is Your Friend
- New Products
- Hats Off to Mozilla
- 2014 Book Roundup
- January 2015 Issue of Linux Journal: Security
Editorial Advisory Panel
Thank you to our 2014 Editorial Advisors!
- Jeff Parent
- Brad Baillio
- Nick Baronian
- Steve Case
- Chadalavada Kalyana
- Caleb Cullen
- Keir Davis
- Michael Eager
- Nick Faltys
- Dennis Frey
- Philip Jacob
- Jay Kruizenga
- Steve Marquez
- Dave McAllister
- Craig Oda
- Mike Roberts
- Chris Stark
- Patrick Swartz
- David Lynch
- Alicia Gibb
- Thomas Quinlan
- Carson McDonald
- Kristen Shoemaker
- Charnell Luchich
- James Walker
- Victor Gregorio
- Hari Boukis
- Brian Conner
- David Lane