HOME

TheInfoList



OR:

curses is a terminal control
library A library is a collection of Book, books, and possibly other Document, materials and Media (communication), media, that is accessible for use by its members and members of allied institutions. Libraries provide physical (hard copies) or electron ...
for
Unix-like A Unix-like (sometimes referred to as UN*X, *nix or *NIX) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Uni ...
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). ncurses is the approved replacement for 4.4BSD classic curses.


Overview

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 curses
API An application programming interface (API) is a connection between computers or between computer programs. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how to build ...
is described in several places. 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 Termcap ("terminal capability") is a legacy software library (computing), library and database used on Unix-like computers that enables programs to use display computer terminals in a terminal-independent manner, which greatly simplifies the proc ...
. 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.


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''. 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. However, those are not widely used. The name "curses" is a pun on ''cursor optimization''. Sometimes it is incorrectly stated that curses was used by the vi editor. In fact the code in curses that optimizes moving the cursor was borrowed from vi, which predated curses. According to Goodheart, Ken Arnold's original implementation of curses started by reusing functions from the
termcap Termcap ("terminal capability") is a legacy software library (computing), library and database used on Unix-like computers that enables programs to use display computer terminals in a terminal-independent manner, which greatly simplifies the proc ...
library, and adding to that. A few years later, Mary Ann Horton, who had maintained the vi and
termcap Termcap ("terminal capability") is a legacy software library (computing), library and database used on Unix-like computers that enables programs to use display computer terminals in a terminal-independent manner, which greatly simplifies the proc ...
sources at Berkeley, went to AT&T Corporation 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 supported in the BSD version. AT&T curses development appears to have halted in the mid-1990s when X/Open Curses was defined. In 1995, BSD maintainer, Keith Bostic, officially deprecated the curses library in favor of ncurses. Development of ncurses and PDCurses continues. A version of BSD curses continues to be maintained in the
NetBSD NetBSD is a free and open-source Unix-like operating system based on the Berkeley Software Distribution (BSD). It was the first open-source BSD descendant officially released after 386BSD was fork (software development), forked. It continues to ...
operating system (wide character support, termcap to terminfo migration, etc.).


pcurses and PDCurses

Different lines of development started by imitating the AT&T curses, from at least three implementations: pcurses by Pavel Curtis (started in 1982), PDCurses (Public Domain curses) by Mark Hessling to support his editor
THE ''The'' is a grammatical article in English, denoting nouns that are already or about to be mentioned, under discussion, implied or otherwise presumed familiar to listeners, readers, or speakers. It is the definite article in English. ''The ...
(started in 1987) as well as
Rexx Rexx (restructured extended executor) is a high-level programming language developed at IBM by Mike Cowlishaw. Both proprietary and open-source software, open source Rexx interpreter (computing), interpreters exist for a wide range of comput ...
/Curses, and PC curses (version 1.4 and earlier by Björn Larsson-based inspired by Pavel Curtis' library before 1990).


ncurses

ncurses (new curses) "originated as pcurses... and was re-issued as ncurses 1.8.1 in late 1993". ncurses is the most widely known implementation of curses, and has motivated further development of other variations, such as BSD curses in the
NetBSD NetBSD is a free and open-source Unix-like operating system based on the Berkeley Software Distribution (BSD). It was the first open-source BSD descendant officially released after 386BSD was fork (software development), forked. It continues to ...
project.


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 OS/2 is a Proprietary software, proprietary computer operating system for x86 and PowerPC based personal computers. It was created and initially developed jointly by IBM and Microsoft, under the leadership of IBM software designer Ed Iacobucci, ...
, 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.


Screenshots

Image:Tin_console.png, Color newsreader interface for tin Image:Jack-curses-screen.gif, Curses used in Jack


Applications

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 software is software whose
user interface In the industrial design field of human–computer interaction, a user interface (UI) is the space where interactions between humans and machines occur. The goal of this interaction is to allow effective operation and control of the machine fro ...
is implemented through the curses library, or a compatible library (such as ncurses). 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 is most commonly associated with
Unix-like A Unix-like (sometimes referred to as UN*X, *nix or *NIX) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Uni ...
operating systems, although implementations for
Microsoft Windows Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
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 OpenVMS, often referred to as just VMS, is a multi-user, multiprocessing and virtual memory-based operating system. It is designed to support time-sharing, batch processing, transaction processing and workstation applications. Customers using Op ...
*
Newt A newt is a salamander in the subfamily Pleurodelinae. The terrestrial juvenile phase is called an eft. Unlike other members of the family Salamandridae, newts are semiaquatic, alternating between aquatic and terrestrial habitats. Not all aqua ...
- a similar text UI library based on the slang library


References


External links


NCURSES - Manual Pages

Curses tutorial
(
PDF Portable document format (PDF), standardized as ISO 32000, is a file format developed by Adobe Inc., Adobe in 1992 to present documents, including text formatting and images, in a manner independent of application software, computer hardware, ...
format)
Public Domain Curses

Interface for Rexx programmers

Tcl Toolkit





NetBSD Curses main manual page

X/Open Curses, Issue 4, Version 2
1996, opengroup.org
X/Open Curses, Issue 7
2009, opengroup.org {{DEFAULTSORT:Curses (Programming Library) Unix software