| curses | |
|---|---|
Live Upgrade (lu) command, built upon FMLI[discuss] which uses Curses | |
| Developer | Ken Arnold |
| Initial release | 1978[1] |
| Written in | C |
| Type | Widget toolkit |
curses is aterminal controllibrary forUnix-like systems, enabling the construction oftext user interface (TUI) applications.
The name is a pun on the term "cursor optimization". It is a library of functions that manage an application's display on character-cell terminals (e.g.,VT100).[2]
ncurses is the approved replacement for4.4BSD classic curses.[citation needed]
Using curses, programmers are able to write text-based applications without writing directly for any specific terminal type. The curses library on the executing system sends the correct control characters based on the terminal type. It provides an abstraction of one or more windows that maps onto the terminal screen. Each window is represented by a character matrix. The programmer sets up the desired appearance of each window, then tells the curses package to update the screen. The library determines a minimal set of changes that are needed to update the display and then executes these using the terminal's specific capabilities and control sequences.
In short, this means that the programmer creates a character matrix of how the screen should look and lets curses handle the work.
The cursesAPI is described in several places.[3] Most implementations of curses use a database that can describe the capabilities of thousands of different terminals. There are a few implementations, such as PDCurses, which use specialized device drivers rather than a terminal database. Most implementations useterminfo; some usetermcap. Curses has the advantage of back-portability to character-cell terminals and simplicity. For an application that does not require bit-mapped graphics or multiple fonts, an interface implementation using curses will usually be much simpler and faster than one using anX toolkit.
The first curses library was written byKen Arnold and originally released withBSD UNIX, where it was used for several games, most notablyRogue.[4][5][6] Some improvements were made to the BSD library in the 1990s as "4.4BSD" curses, e.g., to provide more than one type of video highlighting.[citation needed] However, those are not widely used.
The name "curses" is a pun oncursor optimization.[7] Sometimes it is incorrectly stated that curses was used by thevi editor. In fact the code in curses that optimizes moving the cursor was borrowed from vi, which predated curses.[5]
According to Goodheart, Ken Arnold's original implementation of curses started by reusing functions from thetermcap library, and adding to that.[8] A few years later,Mary Ann Horton, who had maintained thevi andtermcap sources atBerkeley, went toAT&T Corporation and made a different version usingterminfo, which became part ofUNIX System III andUNIX System V. Due to licensing restrictions on the latter, the BSD and AT&T versions of the library were developed independently. In addition to the termcap/terminfo improvement, other improvements were made in the AT&T version:
AT&T curses development appears to have halted in the mid-1990s when X/Open Curses was defined.[9] In 1995, BSD maintainer,Keith Bostic, officially deprecated the curses library in favor ofncurses.[10][dubious –discuss] Development of ncurses and PDCurses continues. A version of BSD curses continues to be maintained in theNetBSD operating system (wide character support, termcap to terminfo migration, etc.).
Different lines of development started by imitating the AT&T curses, from at least three implementations:pcurses byPavel Curtis (started in 1982),PDCurses (Public Domain curses) by Mark Hessling to support his editorTHE (started in 1987) as well asRexx/Curses,[11] andPC curses (version 1.4 and earlier by Björn Larsson-based inspired by Pavel Curtis' library before 1990).[12][13][discuss]
ncurses (new curses) "originated aspcurses ... and was re-issued as ncurses 1.8.1 in late 1993".[14] ncurses is the most widely known implementation of curses, and has motivated further development of other variations, such as BSD curses in theNetBSD project.[15][16]
Although the ncurses library was initially developed under Linux, OpenBSD, FreeBSD, and NetBSD, it has been ported to many other ANSI/POSIX UNIX systems, mainly by Thomas Dickey. PDCurses, while not identical to ncurses, uses the same function calls and operates the same way as ncurses does except that PDCurses targets different devices, e.g., console windows forDOS,Win32,OS/2, as well asX11. Porting between the two is not difficult. For example, theroguelike gameADOM was written for Linux and ncurses, later ported to DOS and PDCurses.[17][18]
Curses is designed to facilitate GUI-like functionality on a text-only device, such as a PC running in console mode, a hardware ANSI terminal, aTelnet orSSH client, or similar. Curses-based software is software whoseuser interface is implemented through the curses library, or a compatible library (such asncurses).
Curses-based programs often have a user interface that resembles a traditional graphical user interface, including 'widgets' such as text boxes and scrollable lists, rather than thecommand line interface (CLI) most commonly found on text-only devices. This can make them more user-friendly than a CLI-based program, while still being able to run on text-only devices. Curses-based software can also have a lighter resource footprint and operate on a wider range of systems (both in terms of hardware and software) than their GUI-based counterparts. This includes old pre-1990 machines along with modern embedded systems using text-only displays.
Curses is most commonly associated withUnix-like operating systems, although implementations forMicrosoft Windows also exist.
{{cite journal}}:Cite journal requires|journal= (help)based on PC curses (version 1.4) written by Björn Larsson[permanent dead link]
PCcurses is a port/rewrite of Pavel Curtis' [package]