diff options
| author | Baptiste Daroussin <bapt@FreeBSD.org> | 2026-01-14 13:37:49 +0100 |
|---|---|---|
| committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2026-01-14 13:37:49 +0100 |
| commit | c5a1e08b52b2f6c05e0116d46277904b711b6bdb (patch) | |
| tree | a6ad7350d1b1100356ca59616d22c51dd29743eb /man/ncurses.3x | |
| parent | 24fa7a5107c5b75d1c197accf0305be64bc72882 (diff) | |
Vendor import ncurses 6.6vendor/ncurses/6.6vendor/ncurses
Diffstat (limited to 'man/ncurses.3x')
| -rw-r--r-- | man/ncurses.3x | 896 |
1 files changed, 568 insertions, 328 deletions
diff --git a/man/ncurses.3x b/man/ncurses.3x index 9aaa7adf54bf..21799fdd2296 100644 --- a/man/ncurses.3x +++ b/man/ncurses.3x @@ -1,6 +1,6 @@ '\" t .\"*************************************************************************** -.\" Copyright 2018-2023,2024 Thomas E. Dickey * +.\" Copyright 2018-2024,2025 Thomas E. Dickey * .\" Copyright 1998-2015,2017 Free Software Foundation, Inc. * .\" * .\" Permission is hereby granted, free of charge, to any person obtaining a * @@ -28,8 +28,8 @@ .\" authorization. * .\"*************************************************************************** .\" -.\" $Id: ncurses.3x,v 1.214 2024/04/27 17:55:43 tom Exp $ -.TH ncurses 3X 2024-04-27 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls" +.\" $Id: ncurses.3x,v 1.289 2025/11/12 01:01:34 tom Exp $ +.TH ncurses 3X 2025-11-11 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls" .ie \n(.g \{\ .ds `` \(lq .ds '' \(rq @@ -54,7 +54,6 @@ . TP .. . -.ds d @TERMINFO@ .SH NAME \fB\%ncurses\fP \- character-cell terminal interface with optimized output @@ -65,7 +64,7 @@ character-cell terminal interface with optimized output .SH DESCRIPTION The \*(``new curses\*('' library offers the programmer a terminal-independent means of reading keyboard and mouse input and -updating character-cell terminals with output optimized to minimize +writing to character-cell displays with output optimized to minimize screen updates. .I \%ncurses replaces the @@ -86,15 +85,15 @@ abstraction and subdivision thereof with .I windows and .IR pads ; -the reading of terminal input; -control of terminal input and output options; -environment query routines; -color manipulation; +acquisition of keyboard and mouse events; +selection of color and rendering attributes +(such as bold or underline); the definition and use of .I "soft label" keys; +access to the .I \%term\%info -capability access; +terminal capability database; a .I termcap compatibility interface; @@ -102,8 +101,7 @@ and an abstraction of the system's API for manipulating the terminal (such as \fI\%termios\fP(3)). .PP .I \%ncurses -implements the standard interface described by -X/Open Curses Issue\ 7. +implements the interface described by X/Open Curses Issue\ 7. In many behavioral details not standardized by X/Open, .I \%ncurses emulates the @@ -122,8 +120,8 @@ API should be aware, such as limitations on the size of an underlying integral type or the availability of a preprocessor macro exclusive of a function definition (which prevents its address from being taken). -This section also describes implementation details that will be -significant to the programmer but which are not standardized. +This section also describes implementation details +of significance to the programmer but which are not standardized. .bP \*(``EXTENSIONS\*('' presents .I \%ncurses @@ -162,22 +160,21 @@ option to your compiler or linker. A debugging version of the library may be available; if so, link with it using -.BR \-lncurses_g . +.BR \-lncurses_g "." (Your system integrator may have installed these libraries such that you can use the options .B \-lcurses and -.BR \-lcurses_g , +.BR \-lcurses_g "," respectively.) The .I \%ncurses_g -library generates trace logs -(in a file called -.I \%trace -in the current directory) -that describe +library logs events describing .I \%ncurses -actions. +actions +to a file called +.I \%trace +in the application's working directory at startup. See section \*(``ALTERNATE CONFIGURATIONS\*('' below. .SS "Application Structure" A @@ -203,10 +200,13 @@ not been set up. \fB\%initscr\fP(3X) or \fB\%newterm\fP(3X) must be called to initialize .I curses -before use of any functions that deal with windows and screens. +before use of any functions +that access or manipulate windows or screens. .PP -To get character-at-a-time input without echoing\(emmost interactive, -screen-oriented programs want this\(emuse the following sequence. +To get character-at-a-time input without echoing \(em +most interactive, +screen-oriented programs want this \(em +use the following sequence. .PP .RS 4 .EX @@ -214,36 +214,55 @@ initscr(); cbreak(); noecho(); .EE .RE .PP -Most applications perform further setup as follows. +Most applications would perform further setup as follows. .PP .RS 4 .EX -intrflush(stdscr, FALSE); +.nf +noqiflush(); keypad(stdscr, TRUE); +.fi .EE .RE .PP A .I curses -program then often enters an event loop of some sort. +program then often enters an event-handling loop. Call \fB\%endwin\fP(3X) before exiting. .SS Overview A .I curses -library abstracts the terminal screen by representing all or part of it -as a +library abstracts the terminal with a +.I \%SCREEN +data structure, +and represents all or part of its display +with .I \%WINDOW -data structure. +structures. +Distinct properties apply to each; +for example, +the +.I "line discipline" +of a typical Unix terminal driver +is in one of three modes: +raw, +\%cbreak, +or canonical (\*(``cooked\*(''). +In +.IR curses "," +the line discipline is a property of the screen, +applying identically to all windows associated with it. +.PP A .I window is a rectangular grid of character cells, -addressed by row and column coordinates -.RI ( y , +addressed by line and column coordinates +.RI ( y "," .IR x ), with the upper left corner as (0, 0). A window called -.BR \%stdscr , -the same size as the terminal screen, +.BR \%stdscr "," +by default the same size as the terminal screen, is always available. Create others with \fB\%newwin\fP(3X). .PP @@ -262,17 +281,16 @@ effects. .PP Functions permit manipulation of a window and the .I cursor -identifying the cell within it at which the next output operation will -occur. +identifying the cell within it at which the next operation will occur. Among those, the most basic are \fB\%move\fP(3X) and \fB\%addch\fP(3X): -these place the cursor and write a character to -.BR \%stdscr , +these place the cursor within and write a character to +.BR \%stdscr "," respectively. .PP Frequent changes to the terminal screen can cause unpleasant flicker or inefficient use of the communication channel to the device, -so the library does not generally update it automatically. +so as a rule the library does not update it automatically. Therefore, after using .I curses @@ -284,7 +302,7 @@ The library .\" X/Open Curses Issue 7 assumes some optimization will be done, but .\" does not mandate it in any way. .I optimizes -its output by computing a minimal number of operations to mutate the +its output by computing a minimal volume of operations to mutate the screen from its state at the previous refresh to the new one. Effective optimization demands accurate information about the terminal device: @@ -297,48 +315,54 @@ implementation. Special windows called .I pads may also be manipulated. -These are windows that are not constrained to the size of the terminal -screen and whose contents need not be completely displayed. +These are not constrained to the size of the terminal screen and their +contents need not be completely displayed. See \fB\%curs_pad\fP(3X). .PP -In addition to drawing characters on the screen, -rendering attributes and colors may be supported, -causing the characters to show up in such modes as underlined, -in reverse video, -or in color on terminals that support such display enhancements. -See \fB\%curs_attr\fP(3X). +Many terminals support configuration of character cell foreground and +background colors as well as +.IR attributes "," +which cause characters to render in such modes as +boldfaced, +underlined, +or in reverse video. +See \fB\%curs_color\fP(3X) and \fB\%curs_attr\fP(3X). .PP .I curses -predefines constants for a small set of forms-drawing graphics +defines constants to simplify access +to a small set of forms-drawing graphics corresponding to the DEC Alternate Character Set (ACS), a feature of VT100 and other terminals. -See \fB\%waddch\fP(3X). +See \fB\%addch\fP(3X). .PP .I curses is implemented using the operating system's terminal driver; -keystroke events are received not as scan codes but as byte sequences. -Graphical keycaps +key events are received not as scan codes but as byte sequences. +The driver reports graphical keycaps (alphanumeric and punctuation keys, and the space) -appear as-is. +as-is. Everything else, including the tab, enter/return, keypad, arrow, and function keys, -appears as a control character or a multibyte +appears to +.I curses +as a control character or a multibyte .I "escape sequence." .I curses -translates these into unique +can translate the latter into unique .I "key codes." -See \fB\%getch\fP(3X). +See \fB\%keypad\fP(3X) and \fB\%getch\fP(3X). .PP .I \%ncurses provides reimplementations of the SVr4 \fBpanel\fP(3X), \fBform\fP(3X), -and \fBmenu\fP(3X) libraries to ease construction of user interfaces +and \fBmenu\fP(3X) libraries; +they permit overlapping windows and ease construction of user interfaces with -.IR curses . +.IR curses "." .SS "Initialization" The selection of an appropriate value of .I TERM @@ -352,10 +376,9 @@ A well-configured system selects a correct value automatically; \fB\%tset\fP(1) may assist with troubleshooting exotic situations. .PP -If you change the terminal type, -export the -.I TERM -environment variable in the shell, +If you change the terminal type from a shell, +export +.IR TERM "," then run \fB\%tset\fP(1) or the .RB \*(`` "@TPUT@ init" \*('' command. @@ -370,10 +393,10 @@ or if the .I curses program is executing in a graphical windowing environment, the information obtained thence overrides that obtained by -.IR \%term\%info . +.IR \%term\%info "." An .I \%ncurses -extension supports resizable terminals; +extension supports resizable terminal displays; see \fB\%wresize\fP(3X). .PP If the environment variable @@ -384,9 +407,8 @@ a program checks first for a terminal type description in the location it identifies. .I \%TERMINFO -is useful for developing experimental type descriptions or when write -permission to -.I \%\*d +is useful for developing type descriptions or when write permission to +.I \%@TERMINFO@ is not available. .PP See section \*(``ENVIRONMENT\*('' below. @@ -402,41 +424,61 @@ those with a \*(``mv\*('' prefix first perform cursor movement using a \*(``mvw\*('' prefix indicates both. The \*(``w\*('' function is typically the elemental one; the removal of this prefix usually indicates operation on -.BR \%stdscr . +.BR \%stdscr "." .PP -Four functions prefixed with \*(``p\*('' require a pad argument. +Four functions prefixed with \*(``p\*('' require a +.I pad +argument; +see below. .PP In function synopses, .I \%ncurses man pages apply the following names to parameters. +We introduce the character types in the next subsection. .PP .TS center; Li L. -bf \fIbool\fP (\fBTRUE\fP or \fBFALSE\fP) +bf a \fIbool\fP (\fBTRUE\fP or \fBFALSE\fP) c a \fIchar\fP or \fIint\fP ch a \fIchtype\fP wc a \fIwchar_t\fP or \fIwint_t\fP wch a \fIcchar_t\fP win pointer to a \fIWINDOW\fP pad pointer to a \fIWINDOW\fP that is a pad +pair a foreground/background color pair identifier .TE .SS "Wide and Non-wide Character Configurations" -This manual page describes functions that appear in any configuration -of the library. +This man page primarily surveys functions that appear in any +configuration of the library. There are two common configurations; +for others, see section \*(``ALTERNATE CONFIGURATIONS\*('' below. .TP 10 \" "ncursesw" + 2n .I \%ncurses is the library in its \*(``non-wide\*('' configuration, handling only eight-bit characters. -It stores a character combined with attributes in a +It stores a character combined with attributes +and a color pair identifier +in a .I \%chtype datum, which is often an alias of -.IR int . +.IR int "." +A string of +.I curses +characters is similar to a C +.I char +string; +a +.I chtype +string ends with an integral +.BR 0 "," +the null +.I curses +character. .IP -Attributes alone +Attributes and a color pair identifier (with no corresponding character) can be stored in variables of .I \%chtype @@ -444,12 +486,24 @@ or .I \%attr_t type. In either case, -they are represented as an integral bit mask. +they are accessed via an integral bit mask. .IP -Each cell of a +.I \%ncurses +stores each cell of a .I \%WINDOW -is stored as a -.IR \%chtype . +as a +.IR \%chtype "." +X/Open Curses does not specify the sizes of the character code or +color pair identifier, +nor the quantity of attribute bits, +in +.IR chtype ";" +these are implementation-dependent. +.I \%ncurses +uses eight bits for the character code. +An application requiring a wider character type, +for instance to represent Unicode, +should use the wide-character API. .TP 10 .I \%ncursesw is the library in its \*(``wide\*('' configuration, @@ -457,19 +511,49 @@ which handles character encodings requiring a larger data type than .I \%char (a byte-sized type) can represent. -It adds about one third more calls using additional data types that -can store such -.I multibyte -characters. +It provides additional functions that complement those in +the non-wide library where the size of the underlying character type is +significant. +A somewhat regular naming convention relates many of the wide variants +to their non-wide counterparts; +where a non-wide function name contains \*(``ch\*('' or \*(``str\*('', +prefix it with \*(``_w\*('' to obtain the wide counterpart. +For example, +\fB\%waddch\fP becomes \fB\%wadd_wch\fP. +An exception is +.B \%ins_nwstr +(and its variants), +spelled thus instead of \*(``insn_wstr\*(''. +(Exceptions that add only \*(``w\*('' comprise +.BR \%addwstr "," +.BR \%inwstr "," +and their variants.) +.\" This is because they operate on "plain" wide-character strings +.\" (`wchar_t*`) and not curses complex character strings (`cchar_t*`). +.\" SVID 4 did specify functions like `addwch()` and `inswch()` that +.\" operated on `chtype`s assuming that they were wide enough for a +.\" `wchar_t` plus attribute and color pair bits; X/Open Curses did not +.\" standardize these. +.IP +This convention is inapplicable to some non-wide function names, +so other transformations are used for the wide configuration: +the window background management function \*(``bkgd\*('' becomes +\*(``bkgrnd\*(''; +the window border-drawing and -clearing functions are suffixed with +\*(``_set\*(''; +and character attribute manipulation functions like +\*(``attron\*('' become \*(``attr_on\*(''. .RS 10 \" same as foregoing tag width .TP 9 \" "cchar_t" + 2n .I \%cchar_t -corresponds to the non-wide configuration's -.IR \%chtype . -It always a structure type, -because it stores more data than fit into a standard scalar type. +is a +.I "curses complex character" +and corresponds to the non-wide-character configuration's +.IR \%chtype "." +It is a structure type +because it requires more storage than a standard scalar type offers. A character code may not be representable as a -.IR \%char , +.IR \%char "," and moreover more than one character may occupy a cell (as with accent marks and other diacritics). Each character is of type @@ -477,20 +561,26 @@ Each character is of type a complex character contains one spacing character and zero or more non-spacing characters (see below). -Attributes and color data are stored in separate fields of the -structure, -not combined as in -.IR \%chtype . +A string of complex characters ends with a +.I \%cchar_t +whose +.I \%wchar_t +member is the null wide character. +Attributes and a color pair identifier are stored in separate fields of +the structure, +not combined into an integer as in +.IR \%chtype "." .PP -Each cell of a +.I \%ncurses +stores each cell of a .I \%WINDOW -is stored as a -.IR \%cchar_t . -.PP +as a +.IR \%cchar_t "." \fB\%setcchar\fP(3X) and \fB\%getcchar\fP(3X) store and retrieve .I \%cchar_t data. +.PP The wide library API of .I \%ncurses depends on two data types standardized by ISO C95. @@ -498,16 +588,16 @@ depends on two data types standardized by ISO C95. .I \%wchar_t stores a wide character. Like -.IR \%chtype , +.IR \%chtype "," it may be an alias of -.IR int . +.IR int "." Depending on the character encoding, a wide character may be -.IR spacing , +.IR spacing "," meaning that it occupies a character cell by itself and typically accompanies cursor advancement, or -.IR non-spacing , +.IR non-spacing "," meaning that it occupies the same cell as a spacing character, is often regarded as a \*(``modifier\*('' of the base glyph with which it combines, @@ -517,35 +607,12 @@ and typically does not advance the cursor. can store a .I \%wchar_t or the constant -.BR \%WEOF , +.IR \%WEOF "," analogously to the .IR int -sized character manipulation functions of ISO C and its constant -.BR \%EOF . +.IR \%EOF "." .RE -.IP -The wide library provides additional functions that complement those in -the non-wide library where the size of the underlying character type is -significant. -A somewhat regular naming convention relates many of the wide variants -to their non-wide counterparts; -where a non-wide function name contains \*(``ch\*('' or \*(``str\*('', -prefix it with \*(``_w\*('' to obtain the wide counterpart. -For example, -\fB\%waddch\fP becomes \fB\%wadd_wch\fP. -(Exceptions that add only \*(``w\*('' comprise -.BR \%addwstr , -.BR \%inwstr , -and their variants.) -.IP -This convention is inapplicable to some non-wide function names, -so other transformations are used for the wide configuration: -the window background management function \*(``bkgd\*('' becomes -\*(``bkgrnd\*(''; -the window border-drawing and -clearing functions are suffixed with -\*(``_set\*(''; -and character attribute manipulation functions like -\*(``attron\*('' become \*(``attr_on\*(''. .\" .SS "Function Name Index" The following table lists the @@ -559,8 +626,8 @@ neither described by X/Open Curses nor present in SVr4. .PP .TS center tab(/); -l l . -\f(BIcurses\fP Function Name/Man Page +L L. +\fIcurses\fP Function Name/Man Page _ COLOR_PAIR/\fBcurs_color\fP(3X) PAIR_NUMBER/\fBcurs_color\fP(3X) @@ -743,7 +810,7 @@ mvaddnwstr/\fBcurs_addwstr\fP(3X) mvaddstr/\fBcurs_addstr\fP(3X) mvaddwstr/\fBcurs_addwstr\fP(3X) mvchgat/\fBcurs_attr\fP(3X) -mvcur/\fBcurs_terminfo\fP(3X) +mvcur/\fBcurs_kernel\fP(3X) mvdelch/\fBcurs_delch\fP(3X) mvderwin/\fBcurs_window\fP(3X) mvget_wch/\fBcurs_get_wch\fP(3X) @@ -1033,20 +1100,19 @@ see sections \*(``ALTERNATE CONFIGURATIONS\*('' and \*(``EXTENSIONS\*('' below. .SH RETURN VALUE Unless otherwise noted, -functions that return an integer return +functions that return integers return the constants .B OK on success and .B ERR -on failure. -Functions that return pointers return -.B NULL -on failure. +on failure; +see \fB\%curs_variables\fP(3X). +Functions that return pointers return a null pointer on failure. Typically, .I \%ncurses treats a null pointer passed as a function parameter as a failure. Functions prefixed with \*(``mv\*('' first perform cursor movement and fail if the position -.RI ( y , +.RI ( y "," .IR x ) is outside the window boundaries. .SH ENVIRONMENT @@ -1055,27 +1121,30 @@ runtime behavior of .I \%ncurses applications. The library may be configured to disregard the variables -.IR \%TERMINFO , -.IR \%TERMINFO_DIRS , -.IR \%TERMPATH , +.IR \%TERMINFO "," +.IR \%TERMINFO_DIRS "," +.IR \%TERMPATH "," and -.IR HOME , +.IR HOME "," if the user is the superuser (root), or the application uses \fI\%setuid\fP(2) or \fI\%setgid\fP(2). .SS "\fIBAUDRATE\fP" The debugging library checks this variable when the application has redirected output to a file. -Its integral value is used for the baud rate. +.I \%ncurses +interprets its integral value as the terminal's line speed +in bits per second. If that value is absent or invalid, .I \%ncurses uses 9600. -This feature allows testers to construct repeatable test cases -that take into account optimization decisions that depend on baud rate. +This feature allows developers to construct repeatable test cases +that take into account optimization decisions that depend +on the terminal's line speed. .SS "\fICC\fP (command character)" When set, the .B \%command_character -.RB ( \%cmdch ) +.RB \%( cmdch ) capability value of loaded .I \%term\%info entries changes to the value of this variable. @@ -1083,14 +1152,16 @@ Very few .I \%term\%info entries provide this feature. .PP -Because this name is also used in development environments to represent -the C compiler's name, +Because this name is also used in development environments to store the +C compiler's name, .I \%ncurses ignores its value if it is not one character in length. .SS "\fICOLUMNS\fP" -This variable specifies the width of the screen in characters. +This variable specifies the width of the screen in character cells. Applications running in a windowing environment usually are able to obtain the width of the window in which they are executing. +.I \%ncurses +enforces an upper limit of 512 when reading the value. If .I \%COLUMNS is not defined and the terminal's screen size is not available from the @@ -1098,7 +1169,7 @@ terminal driver, .I \%ncurses uses the size specified by the .B \%columns -.RB ( \%cols ) +.RB \%( cols ) capability of the terminal type's entry in the .I \%term\%info database, @@ -1156,7 +1227,11 @@ stores this interval in milliseconds. The default value of 1000 (one second) is adequate for most uses. -This environment variable overrides it. +This environment variable overrides it; +.I \%ncurses +enforces an upper limit of 30,000 +(30 seconds) +when reading the value. .PP The most common instance where you may wish to change this value is to work with a remote host over a slow communication channel. @@ -1165,6 +1240,10 @@ If the host running a application does not receive the characters of an escape sequence in a timely manner, the library can interpret them as multiple key stroke events. +Conversely, +a fast typist on a low-latency connection who happens to input an ESC +followed by characters that match an escape sequence may experience +confusing application behavior. .PP \fI\%xterm\fP(1) mouse events are a form of escape sequence; therefore, @@ -1181,7 +1260,9 @@ does not create problems when compiling an application. If \fB\%keypad\fP(3X) is disabled for the .I curses window receiving input, -a program must disambiguate escape sequences itself. +.B \%ESCDELAY +is irrelevant +and a program must disambiguate escape sequences itself. .SS "\fIHOME\fP" .I \%ncurses may read and write auxiliary terminal descriptions in @@ -1196,7 +1277,7 @@ specifies the height of the screen in characters. The corresponding .I \%term\%info capability and code is -.BR \%lines . +.BR \%lines "." See the description of the .I \%COLUMNS variable above. @@ -1228,21 +1309,22 @@ to tell .I \%ncurses not to assume anything about the colors, use a value of \*(``\-1,\-1\*(''. -To make the default color scheme green on black, +To make the default color scheme green on black on a terminal +that uses ANSI\ X3.64/ECMA-48/ISO\ 6429 color assignments, use \*(``2,0\*(''. .I \%ncurses accepts integral values from \-1 up to the value of the .I \%term\%info .B \%max_colors .RB ( colors ) -capability. +capability for the selected terminal type. .SS "\fINCURSES_CONSOLE2\fP" (MinGW port only) The .I \%Console2 .\" https://www.hanselman.com/blog/console2-a-better-windows-command-prompt program defectively handles the Microsoft Console API call -.IR \%Create\%Console\%Screen\%Buffer . +.IR \%Create\%Console\%Screen\%Buffer "." Applications that use it will hang. However, it is possible to simulate the action of this call by mapping @@ -1256,7 +1338,11 @@ has the same effect. When .I \%ncurses is configured to use the GPM interface, -this variable may list one or more terminal names +this variable may list one or more terminal type names, +delimited by vertical bars +.RB ( | ) +or colons +.RB ( : ), against which the .I TERM variable @@ -1265,7 +1351,7 @@ is matched. An empty value disables the GPM interface, using .IR \%ncurses 's -built-in support for \fIxterm\fP(1) mouse protocols instead. +built-in support for \fI\%xterm\fP(1) mouse protocols instead. If the variable is absent, .I \%ncurses attempts to open GPM if @@ -1279,18 +1365,20 @@ your terminal driver may not handle them properly. Set this environment variable to any value to disable the feature. You can also adjust your \fI\%stty\fP(1) settings to avoid the problem. .SS "\fINCURSES_NO_MAGIC_COOKIE\fP" -Many terminals store video attributes as a property of a character cell, +Many terminals store video attributes as properties of a character cell, as .I curses does. Historically, -some recorded changes in video attributes as data that logically -.I occupies +some recorded changes in video attributes as data +that logically +(but invisibly) +.I occupied character cells on the display, switching attributes on or off, -similarly to tags in a markup language; -these are termed \*(``magic cookies\*('', -and must be subsequently overprinted. +similarly to tags in a markup language, +which then had to be overprinted to depict the cells' desired contents; +these are termed \*(``magic cookies\*(''. If the .I \%term\%info entry for your terminal type does not adequately describe its handling @@ -1315,12 +1403,13 @@ that is, limiting the speed of communication to what the hardware could handle. Unless a hardware terminal is interfaced into a terminal concentrator (which does flow control), -an application must manage flow control itself to prevent overruns and -data loss. +an application must manage flow itself to prevent overruns and data +loss. .PP -A solution that comes at no hardware cost is for an application to pause -after directing a terminal to execute an operation that it performs -slowly, +A solution that comes at no hardware cost +is for an application to pause transmission +after directing a terminal to execute an operation +that it performs slowly, such as clearing the display. Many terminal type descriptions, including that for the VT100, @@ -1343,7 +1432,7 @@ the library used \fI\%setbuf\fP(3) to enable fully buffered output when initializing the terminal. This was done, as in SVr4 -.IR curses , +.IR curses "," to increase performance. For testing purposes, both of @@ -1359,8 +1448,7 @@ Nowadays, .I \%ncurses performs its own buffering and does not require this workaround; it does not modify the buffering of the standard output stream. -This approach makes signal handling, -as for interrupts, +This approach makes the library's handling of keyboard-initiated signals more robust. A drawback is that certain unconventional programs mixed \fI\%stdio\fP(3) calls with @@ -1421,6 +1509,7 @@ Examples follow. .PP .RS 3 .EX +.nf # linux console, if patched to provide working # VT100 shift\-in/shift\-out, with corresponding font. linux\-vt100|linux console with VT100 line\-graphics, @@ -1429,6 +1518,7 @@ linux\-vt100|linux console with VT100 line\-graphics, # uxterm with vt100Graphics resource set to false xterm\-utf8|xterm relying on UTF\-8 line\-graphics, U8#1, use=xterm, +.fi .EE .RE .PP @@ -1507,8 +1597,8 @@ This variable overrides the default location. Descriptions in .I \%term\%info format are normally stored in a directory tree using subdirectories -named by the common first letters of the terminal types named therein. -This is the scheme used in System\ V. +named for the common first letters of the terminal types named therein. +System\ V used this scheme. .bP If .I \%ncurses @@ -1517,16 +1607,16 @@ then .I \%TERM\%INFO may name its location, such as -.IR \%/usr/share/terminfo.db , +.IR \%/usr/share/terminfo.db "," rather than -.IR \%/usr/share/terminfo/ . +.IR \%/usr/share/terminfo/ "." .PP The hashed database uses less disk space and is a little faster than the directory tree. However, -some applications assume the existence of the directory tree, -and read it directly -rather than using the +some applications assume the existence of the directory tree +and read it directly, +ignoring the .I \%term\%info API. .bP @@ -1550,14 +1640,17 @@ You might produce the base64 format using \fB\%infocmp\fP(1M). .RS 4 .IP .EX +.nf TERMINFO=$(infocmp \-0 \-Q2 \-q) export TERMINFO +.fi .EE .RE .IP -The compiled description is used only if it corresponds to the terminal -type identified by -.IR TERM . +.I \%ncurses +uses the compiled description only if it corresponds +to the terminal type identified by +.IR TERM "." .PP Setting .I \%TERM\%INFO @@ -1588,7 +1681,7 @@ environment variable .bP location(s) configured and compiled into .I \%ncurses -.RS 3 +.RS .if !'\*(td'' \{\ .bP .I \%@TERMINFO_DIRS@ @@ -1602,7 +1695,7 @@ location(s) configured and compiled into .SS "\fITERMINFO_DIRS\fP" This variable specifies a list of locations, akin to -.IR PATH , +.IR PATH "," in which .I \%ncurses searches for the terminal type descriptions described by @@ -1624,10 +1717,10 @@ does not hold a terminal type description or file name, then .I \%ncurses checks the contents of -.IR \%TERMPATH , +.IR \%TERMPATH "," a list of locations, akin to -.IR PATH , +.IR PATH "," in which it searches for .I termcap terminal type descriptions. @@ -1641,10 +1734,10 @@ and are unset or invalid, .I \%ncurses searches for the files -.IR \%/etc/termcap , -.IR \%/usr/share/misc/termcap , +.IR \%/etc/termcap "," +.IR \%/usr/share/misc/termcap "," and -.IR \%$HOME/.termcap , +.IR \%$HOME/.termcap "," in that order. .SH "ALTERNATE CONFIGURATIONS" Many different @@ -1654,102 +1747,204 @@ determined by the options given to the .I \%configure script when building the library. Run the script with the -.B \-\-help +.B \%\-\-help option to peruse them all. A few are of particular significance to the application developer employing -.IR \%ncurses . +.IR \%ncurses "." .TP 5 .B \-\-disable\-overwrite -The standard include for \fI\%ncurses\fP is as noted in \fBSYNOPSIS\fP: +Avoid file name conflicts between +.I \%ncurses +and an existing +.I curses +installation on the system. +The standard C preprocessor inclusion for the +.I curses +library is as follows. .RS 5 .PP .RS 4 .EX -\fB#include <curses.h>\fP +.nf +.\" The dummy character prevents undesired rewriting of the next line on +.\" installation of the man page. +\fB#\&include <curses.h>\fP +.fi .EE .RE .PP -This option is used to avoid filename conflicts when \fI\%ncurses\fP -is not the main implementation of curses of the computer. -If \fI\%ncurses\fP is installed disabling overwrite, -it puts its headers in a subdirectory, -e.g., +If +.I \%ncurses +is installed disabling overwrite, +it puts its header files in a subdirectory. +Here is an example. .PP .RS 4 .EX -\fB#include <ncurses/curses.h>\fP +.\" The dummy character prevents undesired rewriting of the next line on +.\" installation of the man page. +\fB#\&include <ncurses/curses.h>\fP .EE .RE .PP -It also omits a symbolic link which would allow you to use \fB\-lcurses\fP -to build executables. +With +.BR \%\-\-disable\-overwrite "," +installation also omits a symbolic link that would cause the compiler's +.B \%\-lcurses +option to link object files with +.I \%ncurses +instead of the system +.I curses +library. +.PP +The directory used by this configuration of +.I \%ncurses +is shown in section \*(``SYNOPSIS\*('' above. .RE .TP 5 .B \-\-enable\-widec -The configure script renames the library and -(if the \fB\-\-disable\-overwrite\fP option is used) -puts the header files in a different subdirectory. -All of the library names have a \*(``w\*('' appended to them, -i.e., instead of -.RS 5 -.PP -.RS 4 -.EX -\fB\-lncurses\fP -.EE -.RE -.PP -you link with -.PP -.RS 4 -.EX -\fB\-lncursesw\fP -.EE -.RE -.PP -You must also enable the wide-character features in the header file -when compiling for the wide-character library +(default for ABI\ 6+ since 2023-10-21) +Enable support for wide characters. +The +.I \%configure +script renames the +.I \%ncurses +library +(and the +.I tinfo +library, +if +.B \%\-\-with\-termlib +is also specified), +appending \*(``w\*(''. +An application desirous of wide-character support then uses +.B \%\-lncursesw +(or +.BR \%\-ltinfow ) +instead of +.B \%\-lncurses +(or +.BR \%\-ltinfo ) +as its linker option. +The +.IR ncurses++ "," +.IR panel "," +.IR form "," +and +.I menu +libraries are renamed similarly. +.IP +An application must also +define certain C preprocessor symbols +to enable wide-character features +in +.I curses +header files to use the extended (wide-character) functions. -The symbol which enables these features has changed -since X/Open Curses, Issue 4: +The symbol that enables these features has changed +since X/Open Curses Issue\ 4. +.RS 5 .bP -Originally, the wide-character feature required the symbol -\fB_XOPEN_SOURCE_EXTENDED\fP -but that was only valid for XPG4 (1996). +Originally, +the wide-character feature required the symbol +.IR \%_XOPEN_SOURCE_EXTENDED "," +but that was valid only for XPG4 (1996). .bP -Later, that was deemed conflicting with \fB_XOPEN_SOURCE\fP defined to 500. +Later, +that was deemed conflicting with an +.I \%_XOPEN_SOURCE +value of 500. .bP As of mid-2018, -none of the features in this implementation require a \fB_XOPEN_SOURCE\fP -feature greater than 600. -However, X/Open Curses, Issue 7 (2009) recommends defining it to 700. +no +.I \%ncurses +feature requires a +.I \%_XOPEN_SOURCE +value greater than 600. +However, +X/Open Curses Issue\ 7 (2009) recommends defining it to 700. .bP -Alternatively, you can enable the feature by defining \fBNCURSES_WIDECHAR\fP -with the caveat that some other header file than \fBcurses.h\fP -may require a specific value for \fB_XOPEN_SOURCE\fP +Alternatively, +you can enable the feature by defining +.B \%NCURSES_WIDECHAR +with the caveat that some header file other than +.I \%curses.h +may require a specific value for +.I \%_XOPEN_SOURCE (or a system-specific symbol). -.PP -The \fI\%curses.h\fP header file installed for the wide-character -library is designed to be compatible with the non-wide library's header. -Only the size of the \fI\%WINDOW\fP structure differs; -few applications require more than pointers to \fI\%WINDOW\fPs. -.PP -If the headers are installed allowing overwrite, -the wide-character library's headers should be installed last, +.RE +.IP +The +.I \%curses.h +header file installed +for the wide-character library +is designed to be compatible with the non-wide library's header. +Only the size of the +.I \%WINDOW +structure differs; +few applications require more than pointers to +.IR \%WINDOW "." +.\" XXX: What's different in term.h? +.IP +If +.IR \%ncurses 's +header files are installed allowing overwrite +(the default, +but see +.B \%\-\-disable\-overwrite +above), +the wide-character library's headers should be installed last +by packaging systems and similar, to allow applications to be built using either library from the same set of headers. -.RE .TP 5 .B \-\-with\-pthread -The configure script renames the library. -All of the library names have a \*(``t\*('' appended to them -(before any \*(``w\*('' added by \fB\-\-enable\-widec\fP). +Enable support for multi-threaded applications. +The +.I \%configure +script renames the +.I \%ncurses +library +(and the +.I tinfo +library, +if +.B \%\-\-with\-termlib +is also specified), +appending \*(``t\*('' +(before any \*(``w\*('' added by +.BR \%\-\-enable\-widec ). +An application desirous of support for multiple threads of execution +then uses, +for example, +.B \%\-lncursest +(or +.BR \%\-ltinfot ) +instead of +.B \%\-lncurses +(or +.BR \%\-ltinfo ) +as its linker option. +The +.IR ncurses++ "," +.IR panel "," +.IR form "," +and +.I menu +libraries are renamed similarly. .IP -The global variables such as \fBLINES\fP are replaced by macros to -allow read-only access. -At the same time, setter-functions are provided to set these values. -Some applications (very few) may require changes to work with this convention. +.I \%ncursest +and +.I \%ncursestw +replace global variables such as +.B \%LINES +with macros allowing read-only access. +At the same time, +they provide functions to set these values. +Very few applications require changes +to work with this convention. +.\" see definition of NCURSES_WRAPPED_VAR .TP 5 .B \-\-with\-shared .tQ @@ -1758,24 +1953,60 @@ Some applications (very few) may require changes to work with this convention. .B \-\-with\-debug .tQ .B \-\-with\-profile +Mandate compilation of the +.I \%ncurses +library +(and the +.I tinfo +library, +if +.B \%\-\-with\-termlib +is also specified) +in the specified forms. The shared and normal (static) library names differ by their suffixes, -e.g., \fBlibncurses.so\fP and \fBlibncurses.a\fP. -The debug and profiling libraries add a \*(``_g\*('' -and a \*(``_p\*('' to the root names respectively, -e.g., \fBlibncurses_g.a\fP and \fBlibncurses_p.a\fP. +as with +.I \%libncurses.so +and +.IR \%libncurses.a "." +The debugging and profiling libraries add a \*(``_g\*('' +and a \*(``_p\*('' to the roots of these respective names, +forming +.I \%libncurses_g.so +and +.IR \%libncurses_p.a "," +for example. +The +.IR ncurses++ "," +.IR panel "," +.IR form "," +and +.I menu +libraries are made available similarly. .TP 5 .B \-\-with\-termlib -Low-level functions which do not depend upon whether the library -supports wide-characters, are provided in the tinfo library. -.IP -By doing this, it is possible to share the tinfo library between -wide/normal configurations as well as reduce the size of the library -when only low-level functions are needed. +Provide +.IR \%ncurses 's +lower-level terminal interface functions +(those that do not depend +on the +.I \%SCREEN +and +.I \%WINDOW +abstractions) +in a library named +.IR \%tinfo "." +This arrangement reduces an application's linking and/or loading times +when it does not require +.IR curses 's +higher-level features. .IP -Those functions are described in these pages: +The following pages document +.I curses +functions provided by +.IR \%tinfo "." .RS .bP -\fB\%curs_extend\fP(3X) \- miscellaneous \fIcurses\fP extensions +\fB\%curs_extend\fP(3X) \- miscellaneous \fIncurses\fP extensions .bP \fB\%curs_inopts\fP(3X) \- \fIcurses\fP input options .bP @@ -1792,16 +2023,28 @@ database .RE .TP 5 .B \-\-with\-trace -The \fBtrace\fP function normally resides in the debug library, -but it is sometimes useful to configure this in the shared library. -Configure scripts should check for the function's existence rather -than assuming it is always in the debug library. +Expose the \fBcurses_trace\fP(3X) function +in the +.I ncurses(w) +shared and static libraries. +Normally, +it is available only in the debugging library. +(If +.B \-\-with\-termlib +is also specified, +.I tinfo(w) +rather than +.I ncurses(w) +supplies the deprecated \fBtrace\fP(3X) function.) +An application's configuration script should check +for the function's existence +rather than assuming its confinement to the debugging library. .SH FILES .TP .I @DATADIR@/tabset tab stop initialization database .TP -.I \*d +.I @TERMINFO@ compiled terminal capability database .SH NOTES X/Open Curses permits most functions it specifies to be made available @@ -1819,20 +2062,20 @@ to reuse functions those that move the cursor before another operation), and .bP -a few special cases. +in a few special cases. .PP If the standard output file descriptor of an .I \%ncurses program is redirected to something that is not a terminal device, the library writes screen updates to the standard error file descriptor. This was an undocumented feature of SVr3 -.IR curses . +.IR curses "." .PP See subsection \*(``Header Files\*('' below regarding symbols exposed by inclusion of \fI\%curses.h\fP. .SH EXTENSIONS .I \%ncurses -enables an application to capture mouse events on certain terminals, +enables an application to capture mouse events from certain terminals, including \fI\%xterm\fP(1); see \fB\%curs_mouse\fP(3X). .PP @@ -1872,14 +2115,17 @@ See \fB\%default_colors\fP(3X). An .I \%ncurses application can eschew knowledge of +.I \%SCREEN +and .I \%WINDOW structure internals, instead using accessor functions such as +\fB\%is_cbreak\fP(3X) and \fB\%is_scrollok\fP(3X). .PP .I \%ncurses -enables an application to direct application output to a printer -attached to the terminal device; +enables an application to direct its output to a printer attached to the +terminal device; see \fB\%curs_print\fP(3X). .PP .I \%ncurses @@ -1889,37 +2135,35 @@ and \fB\%extended_slk_color\fP(3X) as a form of \fB\%slk_color\fP(3X) that can gather color information from them when many colors are supported. .PP -Some extensions are available only if .I \%ncurses permits modification of \fB\%unctrl\fP(3X)'s behavior; see \fB\%use_legacy_coding\fP(3X). -.I \%ncurses -is compiled to support them; -section \*(``ALTERNATE CONFIGURATIONS\*('' describes how. -.bP +.PP Rudimentary support for multi-threaded applications may be available; see \fBcurs_threads\fP(3X). -.bP +.PP Functions that ease the management of multiple screens can be exposed; see \fBcurs_sp_funcs\fP(3X). -.bP +.PP To aid applications to debug their memory usage, -.I ncurses +.I \%ncurses optionally offers functions to more aggressively free memory it dynamically allocates itself; see \fBcurs_memleaks\fP(3X). -.bP +.PP The library facilitates auditing and troubleshooting of its behavior; see \fBcurs_trace\fP(3X). -.bP -The compiler option +.PP +Compiling +.I \%ncurses +with the option .B \%\-DUSE_GETCAP -causes the library to fall back to reading +causes it to fall back to reading .I \%/etc/termcap if the terminal setup code cannot find a .I \%term\%info entry corresponding to -.IR TERM . +.IR TERM "." Use of this feature is not recommended, as it essentially includes an entire .I termcap @@ -1943,7 +2187,9 @@ such as wide-character and color support. .I \%ncurses intends base-level conformance with X/Open Curses, and supports all features of its enhanced level -except the \fB\%untic\fP utility. +except the +.I \%untic +utility. .PP Differences between X/Open Curses and .I \%ncurses @@ -1963,11 +2209,10 @@ to ensure that they are not null. This is done primarily to guard against programmer error. The standard interface does not provide a way for the library to tell an application which of several possible errors occurred. -Relying on this -(or some other) -extension adversely affects the portability of -.I curses -applications. +An application that relies on +.I \%ncurses +to check its function parameters for validity limits its portability and +robustness. .SS "Padding Differences" In historical .I curses @@ -1998,7 +2243,7 @@ The header file itself includes the header files .I \%stdio.h and -.IR \%unctrl.h . +.IR \%unctrl.h "." .PP X/Open Curses has more to say, .RS 4 @@ -2006,20 +2251,20 @@ X/Open Curses has more to say, The inclusion of .I \%curses.h may make visible all symbols from the headers -.IR \%stdio.h , -.IR \%term.h , -.IR \%termios.h , +.IR \%stdio.h "," +.IR \%term.h "," +.IR \%termios.h "," and -.IR \%wchar.h . +.IR \%wchar.h "." .RE .PP but does not finish the story. A more complete account follows. .bP -Starting with 4BSD -.I curses -(1980) -all implementations have provided a +The first +.IR curses "," +in 4BSD, +provided a .I \%curses.h file. .IP @@ -2030,7 +2275,7 @@ code included and .I \%unctrl.h from an internal header file -.IR \%curses.ext , +.IR \%curses.ext "," where \*(``ext\*('' abbreviated \*(``externs\*(''. .IP @@ -2045,12 +2290,12 @@ and but nothing in .I \%curses.h itself relied upon -.IR \%stdio.h . +.IR \%stdio.h "." .bP SVr2 .I curses added -.IR \%newterm , +.IR \%newterm "," which relies upon .I \%stdio.h because its function prototype employs the @@ -2062,9 +2307,9 @@ SVr4 added .I \%putwin and -.IR \%getwin , +.IR \%getwin "," which also use -.IR \%stdio.h . +.IR \%stdio.h "." .IP X/Open Curses specifies all three of these functions. .IP @@ -2073,22 +2318,22 @@ SVr4 and X/Open Curses do not require the developer to include .I \%stdio.h before -.IR \%curses.h . +.IR \%curses.h "." Both document use of .I curses as requiring only -.IR \%curses.h . +.IR \%curses.h "." .IP As a result, standard .I \%curses.h always includes -.IR \%stdio.h . +.IR \%stdio.h "." .bP X/Open Curses and SVr4 .I curses are inconsistent with respect to -.IR \%unctrl.h . +.IR \%unctrl.h "." .IP As noted in \fBcurs_util\fP(3X), .I \%ncurses @@ -2113,7 +2358,7 @@ from to declare .I \%setupterm in -.IR \%curses.h , +.IR \%curses.h "," but .I \%ncurses and Solaris @@ -2125,7 +2370,7 @@ AIX includes .I \%term.h and -.IR \% termios.h . +.IR \%termios.h "." Again, .I \%ncurses and Solaris @@ -2136,20 +2381,15 @@ X/Open Curses says that .I \%curses.h .B may include -.IR \%term.h , +.IR \%term.h "," but does not require it to do so. .IP Some programs use functions declared in both .I \%curses.h and -.IR \%term.h , -and must include both header files in the same module. -Very old versions of AIX -.I curses -required inclusion of -.I \%curses.h -before -.IR \%term.h . +.IR \%term.h "," +and must include both header files in the same translation unit. +.\" Is that true in ncurses? Can we supply an example? --GBR .IP The header files supplied by .I \%ncurses @@ -2157,11 +2397,11 @@ include the standard library headers required for its declarations, so .IR \%ncurses 's own header files can be included in any order. -But for portability, -you should include +For portability even to old AIX systems, +include .I \%curses.h before -.IR \%term.h . +.IR \%term.h "." .bP X/Open Curses says \*(``may make visible\*('' because including a header file does not necessarily make visible all of the symbols in it @@ -2185,7 +2425,7 @@ is included, its symbols .B may \" bold for consistency in this paragraph be made visible depending on the value of the -.B _XOPEN_SOURCE +.I \%_XOPEN_SOURCE feature test macro. .bP X/Open Curses mandates an application's inclusion of one standard C @@ -2218,11 +2458,11 @@ SVr4 provided for the possibility that an application might include either .I \%varargs.h or -.IR \%stdarg.h . +.IR \%stdarg.h "." These represented contrasting approaches to handling variadic argument lists. The older interface, -.IR \%varargs.h , +.IR \%varargs.h "," used a pointer to .I char \" V7, 32V, System III, 3BSD for variadic functions' @@ -2230,9 +2470,9 @@ for variadic functions' parameter. Later, the list acquired its own standard data type, -.IR \%va_list , +.IR \%va_list "," defined in -.IR \%stdarg.h , +.IR \%stdarg.h "," empowering the compiler to check the types of a function call's actual parameters against the formal ones declared in its prototype. .IP @@ -2244,7 +2484,7 @@ before because they either have allowed for a special type, or, like -.IR \%ncurses , +.IR \%ncurses "," they include .I \%stdarg.h themselves to provide a portable interface. |
