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.

Curses is a on the term "cursor optimization". It is a library of functions that manage an application's display on character-cell terminals (e.g., VT100). [cite web |url=http://invisible-island.net/ncurses/ncurses.faq.html|title=NCURSES - Frequently Asked Questions|author=Thomas E. Dickey]

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". [cite web|url=http://www.byte.com/art/9410/sec8/art3.htm
author=Peter H. Salus
title=The history of Unix is as much about collaboration as it is about technology
publisher=Byte
month=October | year=1994
] citation |last=Arnold|first=K. C. R. C.
title=Screen Updating and Cursor Movement Optimization: A Library Package.
publisher=University of California, Berkeley
date=1977
] [cite web|url=http://www.mirbsd.org/cman/manPSD/19.curses.htm
author=Kenneth C. R. C. Arnold
coauthors=Elan Amir
title="Screen Updating and Cursor Movement Optimization: A Library Package
month=December | year=1992
]

The name "curses" is a pun on "cursor optimization". [cite web |url=http://invisible-island.net/ncurses/ncurses.faq.html#what_is_it|title=NCURSES - Frequently Asked Questions|author=Thomas E. Dickey] 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.

Curses was originally implemented using the termcap library.fact|date=August 2007 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. Due to licensing restrictions on the latter, the BSD and UNIX versions of the library were developed independently. In addition to the termcap/terminfo improvement, other improvements were made in the UNIX 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.

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.fact|date=August 2007 However, those are not widely used. Rather, a different line of development started by imitating the UNIX curses, from at least two implementations: pcurses by Pavel Curtis (started in 1982) and PDCurses by Mark Hessling to support his editor THE (started in 1987).

ncurses development started in 1991 or 1992 using pcurses and was first announced in 1993 [cite web
url=http://invisible-island.net/ncurses/
title=NCURSES - New Curses
author=Thomas E. Dickey
month=December | year=1996
] as noted on the ncurses homepage.An earlier article [cite web
url=http://www.linuxjournal.com/article/1124
title=ncurses: Portable Screen-Handling for Linux
author=Eric S. Raymond
publisher=Linux Journal
month=September | year=1995
] refers to 1991 (second-hand information) but contains several flaws, e.g., asserting that pcurses was little known (it was distributed in the first volume of the comp.sources.unix newsgroup as noted in the terminfo article) and obscuring the connection between BSD and UNIX curses via Mark Horton. The README file in ncurses 1.8.1 states "v0.1 July 31, 1992" and "v1.8.1 Nov 5, 1993", which agrees with the current NEWS file.The ncurses NEWS file gives detailed development information. [cite web
url=http://invisible-island.net/ncurses/NEWS.gz
title=ncurses NEWS (changelog)
author=Thomas E. Dickey
]

While development of ncurses and PDCurses continues, UNIX curses development appears to have halted in the mid-1990s when X/Open Curses was defined. [cite web
url=http://www.opengroup.org/onlinepubs/007908799/cursesix.html X/Open Curses
title=X/Open Curses, Issue 4 Version 2, Reference Pages
publisher=The Open Group
year=1997
] 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. [cite web
url=http://www.daemon-systems.org/man/curses_screen.3.html
title=CURSES_SCREEN(3), NetBSD Library Functions Manual
author=NetBSD project
month=February | year=2004
] [cite web
url=http://netbsd-soc.sourceforge.net/projects/wcurses/
title=NetBSD-SoC: Wide Character Support in NetBSD curses Library
author=Ruibiao Qiu
month=September | year=2005
]

Overview

The curses API is described in several places. [John Strang, "Programming with curses", O'Reilly, ISBN 0-937175-02-1] 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.

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. [cite web
url=http://www.adom.de/adom/past.php3
title=ADOM - The Past
author=Thomas Biskup
date=1994-2007
accessdate=2007-11-16
] [cite newsgroup
url=http://groups.google.com/group/rec.games.roguelike.announce/browse_frm/thread/db2cae355715f608/bb2d17e5701ff977?lnk=st&q=adom+group%3Arec.games.roguelike.announce#bb2d17e5701ff977
title=New Game: ADOM (MS-DOS, MS-Windows, and Linux only)
author=Thomas Biskup
date=March 15, 1996
newsgroup=rec.games.roguelike.announce
accessdate=2007-11-16
]

ee also

*conio – a similar idea, for DOS
*ncurses - New version of curses
*termcap – a database
*terminfo – a terminal database
*S-Lang – an interpreted language with some related features
*SMG$ – a similar idea, for OpenVMS
*Shell curses - Shell code function library similar to Curses

References

External links

* [http://invisible-island.net/ncurses/man/ NCURSES - Manual Pages]
* [http://heather.cs.ucdavis.edu/~matloff/UnixAndC/CLanguage/Curses.pdf Curses tutorial] (PDF format)
* [http://pdcurses.sourceforge.net/ Public Domain Curses]
* [http://rexxcurses.sourceforge.net/ Interface for Rexx programmers]
* [http://www.ch-werner.de/ck/ Tcl Toolkit]
* [http://www.opengroup.org/onlinepubs/007908799/cursesix.html X/Open Curses]


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. The name is a pun on the term “cursor optimization”. It is a library of functions that manage an application s… …   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”