Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Curses (programming library)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Terminal control library enabling construction of text user interfaces}} {{lowercase|title=curses (programming library)}} {{Infobox software | name = curses | logo = Termapi.svg | screenshot = Fmli lu.PNG | caption = Live Upgrade (lu) command, built upon FMLI{{discuss|FMLI example}} which uses Curses | developer = [[Ken Arnold]] | released = 1978<ref>{{cite web |url=https://episodiccontentmag.com/2016/06/17/rogue_chapter3 |title=Procedural Dungeons of Doom: The Making of Rogue – Chapter 3 |author=Craddock, David L. |date=June 17, 2016 |access-date=May 18, 2023}}</ref> | latest release version = | latest release date = 1995 | programming language = [[C (programming language)|C]] | genre = [[Widget toolkit]] | license = }} '''curses''' is a [[Computer terminal|terminal]] control [[Library (computer science)|library]] for [[Unix-like]] systems, enabling the construction of [[text user interface]] (TUI) applications. The name is a pun on the term "[[cursor (computers)|cursor]] optimization". It is a library of functions that manage an application's display on character-cell terminals (e.g., [[VT100]]).<ref>{{cite web |url=http://invisible-island.net/ncurses/ncurses.faq.html|title=NCURSES - Frequently Asked Questions|author=Thomas E. Dickey}}</ref> [[ncurses]] is the approved replacement for [[4.4BSD]] classic curses.{{cn|date=November 2024}} == 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 [[Application programming interface|API]] is described in several places.<ref>John Strang, ''Programming with curses'', O'Reilly, {{ISBN|0-937175-02-1}}</ref> 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 Window System|X]] toolkit. == History == The first curses library was written by [[Ken Arnold]] and originally released with [[Berkeley Software Distribution|BSD]] UNIX, where it was used for several games, most notably ''[[Rogue (computer game)|Rogue]]''.<ref>{{cite web|url=http://landley.net/history/mirror/unix/art3.htm |author=Peter H. Salus |title=The history of Unix is as much about collaboration as it is about technology |publisher=Byte |date=October 1994}}</ref><ref name="Arnold1977">{{Cite journal |last=Arnold|first=K. C. R. C. |title=Screen Updating and Cursor Movement Optimization: A Library Package. |publisher=University of California, Berkeley |year=1977}}</ref><ref>{{cite web|url=http://www.mirbsd.org/cman/manPSD/19.curses.htm |author=Kenneth C. R. C. Arnold |author2=Elan Amir |title=Screen Updating and Cursor Movement Optimization: A Library Package |date=December 1992}}</ref> 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|date=August 2007}} However, those are not widely used. The name "curses" is a pun on ''cursor optimization''.<ref>{{cite web |url=http://invisible-island.net/ncurses/ncurses.faq.html#what_is_it|title=NCURSES - Frequently Asked Questions|author=Thomas E. Dickey}}</ref> Sometimes it is incorrectly stated that curses was used by the [[Vi (text editor)|vi]] editor. In fact the code in curses that optimizes moving the cursor was borrowed from vi, which predated curses.<ref name="Arnold1977"/> According to Goodheart, Ken Arnold's original implementation of curses started by reusing functions from the [[termcap]] library, and adding to that.<ref>{{cite book |last1=Goodheart |first1=Berny |title=UNIX Curses Explained |year=1991 |publisher=Prentice Hall |isbn=0-13-931957-3 |page=xi}}</ref> A few years later, [[Mary Ann Horton]], who had maintained the [[Vi (text editor)|vi]] and [[termcap]] sources at [[University of California, Berkeley|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.<ref>{{cite web |url=http://www.opengroup.org/onlinepubs/007908799/cursesix.html |title=X/Open Curses, Issue 4 Version 2, Reference Pages |publisher=The Open Group |year=1997 }}</ref> In 1995, BSD maintainer, [[Keith Bostic (software engineer)|Keith Bostic]], officially deprecated the curses library in favor of [[ncurses]].<ref>{{cite web |url=https://www.linuxjournal.com/article/1124 |title=ncurses: Portable Screen-Handling for Linux |author=[[Eric S. Raymond]] |publisher=[[Linux Journal]] |date=September 1, 1995 |access-date=May 18, 2023}}</ref>{{dubious|misleading history comment|date=May 2023}} 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 === {{main article|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 Hessling Editor|THE]] (started in 1987) as well as [[Rexx]]/Curses,<ref>{{cite web|url=http://rexxcurses.sourceforge.net/index.html|title=Rexx/Curses|author=Mark Hessling|year=2008|publisher=[[SourceForge]] project rexxcurses|access-date=2014-02-10}}</ref> and '''PC curses''' (version 1.4 and earlier by Björn Larsson-based inspired by Pavel Curtis' library before 1990).<ref>{{cite web|url=http://purl.net/xyzzy/dos/pccurses.zip|title=CURSES.NEW in pccurses.zip|author=F. Ellermann|date=1993-07-26|quote=based on PC curses (version 1.4) written by Björn Larsson|access-date=2014-02-10}}{{Dead link|date=July 2019 |bot=InternetArchiveBot |fix-attempted=yes }}</ref><ref>{{cite web|url=http://read.pudn.com/downloads88/sourcecode/windows/339526/PCCUR/README.NOW__.htm|title=README.NOW in pccurs14.zip|quote=PCcurses is a port/rewrite of Pavel Curtis' <nowiki>[package]</nowiki>|author=Björn Larsson|date=1990-01-14|access-date=2014-02-10|url-status=dead|archive-url=https://web.archive.org/web/20140223040754/http://read.pudn.com/downloads88/sourcecode/windows/339526/PCCUR/README.NOW__.htm|archive-date=2014-02-23}}</ref>{{discuss|PC Curses}} === ncurses === {{main article|ncurses}} '''ncurses''' (new curses) "originated as '''pcurses'''{{nbsp}}... and was re-issued as ncurses 1.8.1 in late 1993".<ref>{{cite web |url=http://invisible-island.net/ncurses/ |title=NCURSES - New Curses |author=Thomas E. Dickey |date=December 1996}}</ref> 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.<ref>{{cite web |url=http://www.daemon-systems.org/man/curses_screen.3.html |title=CURSES_SCREEN(3), NetBSD Library Functions Manual |author=NetBSD project |date=February 2004 }}</ref><ref>{{cite web |url=http://netbsd-soc.sourceforge.net/projects/wcurses/ |title=NetBSD-SoC: Wide Character Support in NetBSD curses Library |author=Ruibiao Qiu |date=September 2005 }} </ref> == 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 ''[[Ancient Domains of Mystery|ADOM]]'' was written for Linux and ncurses, later ported to DOS and PDCurses.<ref>{{cite web |url=http://www.adom.de/adom/past.php3 |title=ADOM - The Past |author=Thomas Biskup |date=1994–2007 |access-date=2007-11-16 |archive-url=https://web.archive.org/web/20071010020739/http://www.adom.de/adom/past.php3 |archive-date=2007-10-10 |url-status=dead }}</ref><ref>{{cite newsgroup |url=https://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 }}</ref> == Screenshots == <gallery> Image:Tin_console.png|Color newsreader interface for [[Tin (newsreader)|tin]] Image:Jack-curses-screen.gif|Curses used in [[Jack (software)|Jack]] </gallery> ==Applications== {{Main|Text-based user interface}} 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 [[Secure Shell|SSH]] client, or similar. Curses-based software is software whose [[user interface]] 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 '[[Widget (computing)|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]] operating systems, although implementations for [[Microsoft Windows]] also exist. == See also == * [[conio.h|conio]] – a similar idea, for [[DOS]] * [[S-Lang]] – an interpreted language with some related features * [[SMG$]] – a similar idea, for [[OpenVMS]] * [[Newt (programming library)|Newt]] - a similar text UI library based on the [[S-Lang|slang library]] == References == {{reflist}} == External links == * [http://invisible-island.net/ncurses/man/ NCURSES - Manual Pages] * [http://heather.cs.ucdavis.edu/~matloff/UnixAndC/CLanguage/Curses.pdf Curses tutorial] {{Webarchive|url=https://web.archive.org/web/20050528211809/http://heather.cs.ucdavis.edu/~matloff/UnixAndC/CLanguage/Curses.pdf |date=2005-05-28 }} ([[Portable Document Format|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] * [https://docs.python.org/library/curses.html Curses for Python] * [http://netbsd.gw.com/cgi-bin/man-cgi?curses+3+NetBSD-current NetBSD Curses main manual page] {{Webarchive|url=https://web.archive.org/web/20140808043722/http://netbsd.gw.com/cgi-bin/man-cgi?curses+3+NetBSD-current |date=2014-08-08 }} * [https://pubs.opengroup.org/onlinepubs/009638999/toc.pdf X/Open Curses, Issue 4, Version 2], 1996, opengroup.org * [https://pubs.opengroup.org/onlinepubs/9699909599/toc.pdf X/Open Curses, Issue 7], 2009, opengroup.org {{DEFAULTSORT:Curses (Programming Library)}} [[Category:Curses (programming library)| ]] [[Category:Unix software]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Citation needed
(
edit
)
Template:Cite book
(
edit
)
Template:Cite journal
(
edit
)
Template:Cite newsgroup
(
edit
)
Template:Cite web
(
edit
)
Template:Cn
(
edit
)
Template:Dead link
(
edit
)
Template:Discuss
(
edit
)
Template:Dubious
(
edit
)
Template:Fix
(
edit
)
Template:ISBN
(
edit
)
Template:Infobox
(
edit
)
Template:Infobox software
(
edit
)
Template:Lowercase
(
edit
)
Template:Main
(
edit
)
Template:Main article
(
edit
)
Template:Main other
(
edit
)
Template:Nbsp
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Template other
(
edit
)
Template:Webarchive
(
edit
)