curses (programming library)

curses (programming library)

curses is a terminal control library for Unix-like systems, enabling the construction of text 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).[1]

Contents

Overview

The curses API is described in several places.[2] 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 use terminfo; some use termcap. 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 an X toolkit.

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 each window to look as they want the display to look, and then tells the curses package to update the screen. The library determines a minimal set of changes 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 simply creates a character matrix of how the screen should look and lets curses handle the work.

History

The first curses library was written by Ken Arnold and originally released with BSD UNIX, where it was used for several games, most notably Rogue. [3] [4] [5]

The name "curses" is a pun on cursor optimization.[6] Sometimes it is incorrectly stated that curses was used by the vi editor. In fact the code in curses that optimizes moving the cursor from one place on the screen to another was borrowed from vi, which predated curses.[4]

Curses was originally implemented using the termcap library.[citation needed] A few years later, Mark Horton, who had made improvements to the vi and termcap sources at Berkeley, went to AT&T and made a different version using terminfo, which became part of UNIX System III and UNIX 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:

video highlighting (bold, underline)
The BSD version supported only standout.
line-drawing
The BSD version gave little support here.
colors
This was not anticipated in the BSD version.

AT&T curses development appears to have halted in the mid-1990s when X/Open Curses was defined. [7] However, development of ncurses and PDCurses continues. A version of BSD curses continues to be maintained in the NetBSD operating system (wide character support, termcap to terminfo migration, etc).

pcurses and PDcurses

Some improvements were made to the BSD library in the 1990s as "BSD 4.4" curses, e.g., to provide more than one type of video highlighting.[citation needed] However, those are not widely used. Rather, a different line of development started by imitating the AT&T curses, from at least two implementations: pcurses by Pavel Curtis (started in 1982) and PDCurses (Public Domain curses) by Mark Hessling to support his editor THE (started in 1987).

ncurses

ncurses (new curses) "originated as pcurses ... and was re-issued as ncurses 1.8.1 in late 1993".[8] ncurses is the most widely known implementation of curses, and has motivated further development of other variations, such as BSD curses in the NetBSD project. [9] [10]

Portability

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 for DOS, Win32, OS/2, as well as X11. Porting between the two is not difficult. For example, the roguelike game ADOM was written for Linux and ncurses, later ported to DOS and PDCurses.[11][12]

Screen shot

Below are some typical examples of curses (in a terminal window which supports colour) - used for the tin and a CD processing product.

Curses-based software

Live Upgrade (lu) command, built upon FMLI which uses Curses

Curses-based software is software whose user interface is implemented through the Curses library, or a compatible library (such as Ncurses).

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, a Telnet or SSH client, or similar.

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 the command 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 was used in the implementation of a language called FMLI, which was used to present a user friendly textual interface called FACE in SVR4 systems, to provide basic systems administration functionality.[citation needed] FMLI based upon Curses was later also used in Solaris, to provide an interface for higher level functionality, for commands surrounding Live Upgrade.[citation needed]

However, not all Curses-based software employs a text user interface which resembles a graphical user interface. One counterexample would be the popular vi text editor, which while not being CLI-based, uses memorized keyboard commands almost exclusively, rather than the prompting TUI/GUI style, which relies more on recognition than recall.

Curses is most commonly associated with Unix-like operating systems, although implementations for Microsoft Windows also exist.

See also

  • conio – a similar idea, for DOS
  • S-Lang – an interpreted language with some related features
  • SMG$ – a similar idea, for OpenVMS

References

  1. ^ Thomas E. Dickey. "NCURSES - Frequently Asked Questions". http://invisible-island.net/ncurses/ncurses.faq.html. 
  2. ^ John Strang, Programming with curses, O'Reilly, ISBN 0-937175-02-1
  3. ^ Peter H. Salus (October 1994). "The history of Unix is as much about collaboration as it is about technology". Byte. http://landley.net/history/mirror/unix/art3.htm. 
  4. ^ a b Arnold, K. C. R. C. (1977). Screen Updating and Cursor Movement Optimization: A Library Package.. University of California, Berkeley. 
  5. ^ Kenneth C. R. C. Arnold; Elan Amir (December 1992). "Screen Updating and Cursor Movement Optimization: A Library Package". http://www.mirbsd.org/cman/manPSD/19.curses.htm. 
  6. ^ Thomas E. Dickey. "NCURSES - Frequently Asked Questions". http://invisible-island.net/ncurses/ncurses.faq.html#what_is_it. 
  7. ^ "X/Open Curses, Issue 4 Version 2, Reference Pages". The Open Group. 1997. http://www.opengroup.org/onlinepubs/007908799/cursesix.html. 
  8. ^ Thomas E. Dickey (December 1996). "NCURSES - New Curses". http://invisible-island.net/ncurses/. 
  9. ^ NetBSD project (February 2004). "CURSES_SCREEN(3), NetBSD Library Functions Manual". http://www.daemon-systems.org/man/curses_screen.3.html. 
  10. ^ Ruibiao Qiu (September 2005). "NetBSD-SoC: Wide Character Support in NetBSD curses Library". http://netbsd-soc.sourceforge.net/projects/wcurses/. 
  11. ^ Thomas Biskup (1994-2007). "ADOM - The Past". http://www.adom.de/adom/past.php3. Retrieved 2007-11-16. 
  12. ^ Thomas Biskup (March 15, 1996). "New Game: ADOM (MS-DOS, MS-Windows, and Linux only)". rec.games.roguelike.announce. (Web link). Retrieved 2007-11-16. 

External links


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • Curses (programming library) — curses is a terminal control library for Unix like systems, enabling the construction of text user interface (TUI) applications.Curses is a on the term cursor optimization . It is a library of functions that manage an application s display on… …   Wikipedia

  • CDK (programming library) — CDK Original author(s) Mike Glover Developer(s) Thomas E. Dickey Stable release 5.0.20090215 / February 15, 2009; 2 years ago (2009 02 15) …   Wikipedia

  • curses — ist der Name verschiedener Programmbibliotheken zur Darstellung zeichenorientierter Benutzerschnittstellen (Text User Interface, TUI) unabhängig vom darstellenden Textterminal bzw. Terminalemulator. Zunächst gab es eine Implementierung der… …   Deutsch Wikipedia

  • Curses — ncurses Entwickler: Free Software Foundation Aktuelle Version: 5.7 (2. November 2008) Betriebssystem: Unix Derivate, GNU/Li …   Deutsch Wikipedia

  • library — /luy brer ee, breuh ree, bree/, n., pl. libraries. 1. a place set apart to contain books, periodicals, and other material for reading, viewing, listening, study, or reference, as a room, set of rooms, or building where books may be read or… …   Universalium

  • Shell curses — is a terminal control library for Unix like systems, enabling the construction of text user interface (TUI) applications. The purpose of the function library is to provide the shell programmer with the ability to move the cursor to specific… …   Wikipedia

  • ncurses — based menuconfig Developer(s) GNU Project Stable release 5.9 / 4 April 2011; 7 months ago ( …   Wikipedia

  • PDCurses — is a public domain curses programming library for DOS, Windows, X11 and SDL. While development of the original curses library halted in the mid 1990s, the development of ncurses and PDcurses continued. PDcurses implements most of the functions… …   Wikipedia

  • Curse (disambiguation) — Curse, the opposite of a blessing or charm may also refer to: The curse , a euphemism for menstruation The Curse, an informal term for the Biblical expulsion of Adam and Eve from the Garden of Eden due to their original sin, and the consequent… …   Wikipedia

  • Terminfo — is a library and database that enables programs to use display terminals in a device independent manner. The origins of this library are from the UNIX System III operating system. Mark Horton implemented the first terminfo library in 1981 1982 as …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”