ncurses(3NCURSES)

โœจ NAME โœจ

okay so welcome to ncurses(3NCURSES) โ€” Library calls, bestie ๐Ÿ’– โ€” which is literally the character-cell terminal interface with optimized output. that's the whole vibe: draw on a terminal, read keys, don't be slow about it ๐Ÿ’…


๐Ÿ“œ SYNOPSIS ๐Ÿ“œ

#include <curses.h>

that's it. that's the entry fee. slay ๐ŸŽ€


๐ŸŒˆ DESCRIPTION ๐ŸŒˆ

so the "new curses" library hands you โ€” yes you, the programmer โ€” a terminal-independent way of reading keyboard and mouse input and writing to character-cell displays, with output optimized so the screen updates stay as minimal as possible. no cap. ๐ŸŒธ

ncurses replaces the curses libraries from System V Release 4 Unix (โ€œSVr4โ€) and 4.4BSD Unix, and bestie, development on those ceased in the 1990s ๐Ÿ˜ญ. this document describes ncurses version 6.6 (patch 20260608). ๐Ÿ‘‘

so what can it even do? glad you asked:

  • control the terminal screen's contents ๐Ÿ–ฅ๏ธ
  • abstract and subdivide those contents with windows and pads ๐ŸชŸ
  • acquire keyboard and mouse events ๐Ÿญ
  • select color and rendering attributes (like bold or underline) โœจ
  • define and use soft label keys ๐Ÿท๏ธ
  • access the terminfo terminal capability database ๐Ÿ“š
  • a termcap compatibility interface ๐Ÿ”
  • an abstraction of the system's API for manipulating the terminal (like termios(3)) ๐Ÿงš

ncurses implements the interface described by X/Open Curses Issue 7. and in all those behavioral details that X/Open didn't standardize? ncurses emulates the curses library of SVr4 and throws in a whole bunch of useful extensions. periodt. ๐Ÿ’œ


๐Ÿ—‚๏ธ how these man pages are organized (the section lineup)

ncurses man pages use several sections to clear up matters of usage and interoperability with other curses implementations. let me put you on:

  • โ€œNOTESโ€ describes issues and caveats that any user of the ncurses API should be aware of โ€” like limitations on the size of an underlying integral type, or whether something exists as a preprocessor macro instead of a function definition (which means you can't take its address, rip ๐Ÿ˜”). this section also covers implementation details that matter to the programmer but that aren't standardized.
  • โ€œEXTENSIONSโ€ presents ncurses innovations beyond the X/Open Curses standard and/or the SVr4 curses implementation. they're called extensions to signal that you can't implement them purely with the library API โ€” they require access to the library's internal state. iykyk ๐Ÿ”ฅ
  • โ€œPORTABILITYโ€ discusses matters โ€” beyond just exercising extensions โ€” that you should think about when writing to a curses standard, or for multiple implementations. โœˆ๏ธ
  • โ€œHISTORYโ€ examines points of detail in ncurses and other curses implementations across the decades of their development, especially where precedent or inertia frustrated better design (and, in a few cases, where such inertia actually got overcome ๐ŸŽ‰).

๐Ÿ”— linking, because a curses app must be linked with the library

use the -lncurses option for your compiler or linker. ๐Ÿ› ๏ธ

a debugging version of the library may be available; if it is, link with it using -lncurses_g. (your system integrator may have installed these libraries so you can use the options -lcurses and -lcurses_g, respectively. so nice of them ๐Ÿซถ)

the ncurses_g library logs events describing ncurses actions to a file called trace in the application's working directory at startup. ๐Ÿ‘€ see section โ€œALTERNATE CONFIGURATIONSโ€ below.


๐Ÿ—๏ธ Application Structure

a curses application uses information from the system locale, so setlocale(3) prepares it for curses library calls:

setlocale(LC_ALL, "");

if the locale isn't initialized this way, the library assumes characters are printable as in ISO 8859-1, so that it works with certain legacy programs. but bestie, you should initialize the locale โ€” do not expect consistent behavior from the library when the locale hasn't been set up. that's not a vibe check you want to fail ๐Ÿ’€

initscr(3NCURSES) or newterm(3NCURSES) must be called to initialize curses before you use any functions that access or manipulate windows or screens. mandatory, fr fr.

to get character-at-a-time input without echoing โ€” and yes, most interactive, screen-oriented programs want exactly this โ€” use the following sequence:

initscr(); cbreak(); noecho();

most applications would do further setup like this:

noqiflush();
keypad(stdscr, TRUE);

a curses program then often enters an event-handling loop. ๐ŸŒ€ call endwin(3NCURSES) before exiting. don't just dip, say goodbye properly. ๐Ÿ‘‹


๐Ÿ‘€ Overview

a curses library abstracts the terminal with a SCREEN data structure, and represents all or part of its display with WINDOW structures. distinct properties apply to each โ€” for example, the line discipline of a typical Unix terminal driver is in one of three modes: raw, cbreak, or canonical (โ€œcookedโ€). in curses, the line discipline is a property of the screen, applying identically to all windows associated with it. ๐Ÿณ

a window is a rectangular grid of character cells, addressed by line and column coordinates (y, x), with the upper left corner as (0, 0). a window called stdscr, by default the same size as the terminal screen, is always available. create others with newwin(3NCURSES). โญ

a curses library does not manage overlapping windows (but see below ๐Ÿ‘‡). so you've got two paths:

  • use stdscr to manage one screen-filling window, or
  • tile the screen into non-overlapping windows and not use stdscr at all.
mixing the two approaches will result in unpredictable and undesired effects. โš ๏ธ pick a lane, bestie.

functions let you manipulate a window and the cursor identifying the cell within it where the next operation will occur. among those, the most basic are move(3NCURSES) and addch(3NCURSES): they place the cursor within stdscr and write a character to stdscr, respectively. iconic duo ๐Ÿ’…

frequent changes to the terminal screen can cause unpleasant flicker or inefficient use of the communication channel to the device, so as a rule the library does not update it automatically. therefore, after using curses functions to accumulate a set of desired updates that make sense to present together, call refresh(3NCURSES) to tell the library to make the user's screen look like stdscr. ๐Ÿช„

the library optimizes 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 โ€” and the management of that information is the province of the terminfo(3NCURSES) API, a feature of every standard curses implementation. ๐Ÿ“–

special windows called pads may also be manipulated. these are not constrained to the size of the terminal screen and their contents need not be completely displayed. see pad(3NCURSES). ๐Ÿ›‹๏ธ

many terminals support configuration of character cell foreground and background colors as well as attributes, which cause characters to render in such modes as boldfaced, underlined, or in reverse video. see color(3NCURSES) and attr(3NCURSES). ๐ŸŒˆ

curses 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 addch(3NCURSES). ๐Ÿ–ผ๏ธ

curses is implemented using the operating system's terminal driver; key events are received not as scan codes but as byte sequences. the driver reports graphical keycaps (alphanumeric and punctuation keys, and the space) as-is. everything else โ€” including the tab, enter/return, keypad, arrow, and function keys โ€” appears to curses as a control character or a multibyte escape sequence. curses can translate the latter into unique key codes. see keypad(3NCURSES) and getch(3NCURSES). โŒจ๏ธ

ncurses provides reimplementations of the SVr4 panel(3NCURSES), form(3FORM), and menu(3MENU) libraries; they permit overlapping windows and ease construction of user interfaces with curses. ๐Ÿงฉ


๐Ÿ”Œ Initialization

the selection of an appropriate value of TERM in the process environment is essential to correct curses and terminfo library operation. a well-configured system selects a correct TERM value automatically; tset(1) may assist with troubleshooting exotic situations. ๐Ÿ•ต๏ธ

if you change the terminal type from a shell, export TERM, then run tset(1) or the tput init command. see subsection โ€œTabs and Initializationโ€ of terminfo(5).

if the environment variables LINES and COLUMNS are set, or if the curses program is executing in a graphical windowing environment, the information obtained from there overrides that obtained by terminfo. ๐Ÿ‘‘ an ncurses extension supports resizable terminal displays; see wresize(3NCURSES).

if the environment variable TERMINFO is defined, a curses program checks first for a terminal type description in the location it identifies. TERMINFO is useful for developing type descriptions, or when write permission to /etc/terminfo is not available. ๐Ÿ™ˆ

see section โ€œENVIRONMENTโ€ below.


๐Ÿท๏ธ Naming Conventions

curses offers many functions in variant forms using a regular set of alternatives to the name of an elemental one. here's the decoder ring ๐Ÿ”ฎ:

  • prefixed with โ€œwโ€ โ†’ requires a WINDOW pointer argument
  • prefixed with โ€œmvโ€ โ†’ first performs cursor movement using wmove(3NCURSES)
  • prefixed with โ€œmvwโ€ โ†’ both of the above, together โœจ

the โ€œwโ€ function is typically the elemental one; removing that prefix usually means it operates on stdscr.

four functions prefixed with โ€œpโ€ require a pad argument; see below.

in function synopses, ncurses man pages apply the following names to parameters. (we introduce the character types in the next subsection ๐Ÿ‘‡)

  • bf โ€” a bool (TRUE or FALSE)
  • c โ€” a char or int
  • ch โ€” a chtype
  • wc โ€” a wchar_t or wint_t
  • wch โ€” a cchar_t
  • win โ€” pointer to a WINDOW
  • pad โ€” pointer to a WINDOW that is a pad
  • pair โ€” a foreground/background color pair identifier

๐Ÿฆ‹ Wide and Non-wide Character Configurations

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.

  • ncurses โ€” the library in its โ€œnon-wideโ€ configuration, handling only eight-bit characters. it stores a character combined with attributes and a color pair identifier in a chtype datum, which is often an alias of int. a string of curses characters is similar to a C char string; a chtype string ends with an integral 0, the null curses character. ๐ŸŽ€

attributes and a color pair identifier (with no corresponding character) can be stored in variables of chtype or attr_t type. in either case, they're accessed via an integral bit mask. ๐Ÿ”ข

ncurses stores each cell of a WINDOW as a chtype. X/Open Curses does not specify the sizes of the character code or color pair identifier, nor the quantity of attribute bits, in chtype; these are implementation-dependent. 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. ๐Ÿ’œ

ncursesw is the library in its โ€œwideโ€ configuration โ€” the one that handles character encodings too chonky for char (a byte-sized type) to represent. ๐Ÿ’– It brings extra functions that complement the ones in the non-wide library wherever the size of the underlying character type is actually a big deal.

Okay so the naming convention? Lowkey iconic. If a non-wide function name contains ch or str, you prefix it with _w to get its wide counterpart. So waddch becomes wadd_wch. โœจ And there's an exception, bestie: ins_nwstr (and its variants) is spelled exactly like that instead of insn_wstr. (The exceptions that only add a w are addwstr, inwstr, and their variants.) ๐Ÿ‘‘

No cap, that convention just doesn't apply to some non-wide function names, so the wide configuration does other transformations instead: the window background management function bkgd becomes bkgrnd; the window border-drawing and -clearing functions get _set tacked on the end; and character attribute manipulation functions like attron become attr_on. ๐Ÿ’…

  • cchar_t โ€” a curses complex character, and it's the wide config's answer to chtype from the non-wide-character configuration. It's a structure type because it needs way more storage than a standard scalar type can give it, fr fr. A character code might not even be representable as a char, and on top of that, more than one character can occupy a single cell (think accent marks and other diacritics). Each character is of type wchar_t; a complex character contains one spacing character and zero or more non-spacing characters (see below). A string of complex characters ends with a cchar_t whose wchar_t member is the null wide character. Attributes and a color pair identifier live in separate fields of the structure โ€” they are not combined into an integer the way they are in chtype. ๐Ÿซถ

ncurses stores each cell of a WINDOW as a cchar_t. setcchar(3NCURSES) and getcchar(3NCURSES) are the ones that store and retrieve cchar_t data. ๐ŸŽ€

The wide library API of ncurses depends on two data types standardized by ISO C95.

  • wchar_t โ€” stores a wide character. Like chtype, it may be an alias of int. Depending on the character encoding, a wide character can be:
    • spacing โ€” meaning it occupies a character cell by itself and typically comes with cursor advancement, or
    • non-spacing</se> โ€” meaning it occupies the same cell as a spacing character, is often regarded as a โ€œmodifierโ€ of the base glyph it combines with, and typically does not advance the cursor.
  • wint_t โ€” can store a wchar_t or the constant WEOF, analogously to the int-sized character manipulation functions of ISO C and its constant EOF. ๐ŸŒธ

โœจ Function Name Index โœจ

The table below lists all the curses functions provided in the non-wide and wide APIs, plus the corresponding man pages that describe them. ๐Ÿ‘‘ Any of them flagged with * are ncurses-specific โ€” neither described by X/Open Curses nor present in SVr4. ๐Ÿ’€

(the table itself is pulling up, bestie โ€” keep scrolling ๐Ÿฆ‹)

okay so here's the master roster ๐Ÿ’– every single function name in the whole curses universe, plus the exact page you gotta go bother for it. the ones with a * got the little sparkle marker. don't skip, bestie, i'm not writing this twice:

  • COLOR_PAIR โ†’ color(3NCURSES)
  • PAIR_NUMBER โ†’ color(3NCURSES)
  • add_wch โ†’ add_wch(3NCURSES)
  • add_wchnstr โ†’ add_wchstr(3NCURSES)
  • add_wchstr โ†’ add_wchstr(3NCURSES)
  • addch โ†’ addch(3NCURSES)
  • addchnstr โ†’ addchstr(3NCURSES)
  • addchstr โ†’ addchstr(3NCURSES)
  • addnstr โ†’ addstr(3NCURSES)
  • addnwstr โ†’ addwstr(3NCURSES)
  • addstr โ†’ addstr(3NCURSES)
  • addwstr โ†’ addwstr(3NCURSES)

that's the entire add family, we survived ๐Ÿซถ

  • alloc_pair โ†’ new_pair(3NCURSES)*
  • assume_default_colors โ†’ default_colors(3NCURSES)*
  • attr_get โ†’ attr(3NCURSES)
  • attr_off โ†’ attr(3NCURSES)
  • attr_on โ†’ attr(3NCURSES)
  • attr_set โ†’ attr(3NCURSES)
  • attroff โ†’ attr(3NCURSES)
  • attron โ†’ attr(3NCURSES)
  • attrset โ†’ attr(3NCURSES)
  • baudrate โ†’ termattrs(3NCURSES)
  • beep โ†’ beep(3NCURSES)
  • bkgd โ†’ bkgd(3NCURSES)
  • bkgdset โ†’ bkgd(3NCURSES)
  • bkgrnd โ†’ bkgrnd(3NCURSES)
  • bkgrndset โ†’ bkgrnd(3NCURSES)
  • border โ†’ border(3NCURSES)
  • border_set โ†’ border_set(3NCURSES)
  • box โ†’ border(3NCURSES)
  • box_set โ†’ border_set(3NCURSES)

borders and boxes, the aesthetic queens ๐Ÿ‘‘

  • can_change_color โ†’ color(3NCURSES)
  • cbreak โ†’ inopts(3NCURSES)
  • chgat โ†’ attr(3NCURSES)
  • clear โ†’ clear(3NCURSES)
  • clearok โ†’ outopts(3NCURSES)
  • clrtobot โ†’ clear(3NCURSES)
  • clrtoeol โ†’ clear(3NCURSES)
  • color_content โ†’ color(3NCURSES)
  • color_set โ†’ attr(3NCURSES)
  • copywin โ†’ overlay(3NCURSES)
  • curs_set โ†’ kernel(3NCURSES)
  • curses_trace โ†’ trace(3NCURSES)*
  • curses_version โ†’ extensions(3NCURSES)*
  • def_prog_mode โ†’ kernel(3NCURSES)
  • def_shell_mode โ†’ kernel(3NCURSES)
  • define_key โ†’ define_key(3NCURSES)*
  • del_curterm โ†’ terminfo(3NCURSES)
  • delay_output โ†’ util(3NCURSES)
  • delch โ†’ delch(3NCURSES)
  • deleteln โ†’ deleteln(3NCURSES)
  • delscreen โ†’ initscr(3NCURSES)
  • delwin โ†’ window(3NCURSES)
  • derwin โ†’ window(3NCURSES)
  • doupdate โ†’ refresh(3NCURSES)
  • dupwin โ†’ window(3NCURSES)
  • echo โ†’ inopts(3NCURSES)
  • echo_wchar โ†’ add_wch(3NCURSES)
  • echochar โ†’ addch(3NCURSES)
  • endwin โ†’ initscr(3NCURSES)
  • erase โ†’ clear(3NCURSES)
  • erasechar โ†’ termattrs(3NCURSES)
  • erasewchar โ†’ termattrs(3NCURSES)
  • exit_curses โ†’ memleaks(3NCURSES)*
  • exit_terminfo โ†’ memleaks(3NCURSES)*
  • extended_color_content โ†’ color(3NCURSES)*
  • extended_pair_content โ†’ color(3NCURSES)*
  • extended_slk_color โ†’ slk(3NCURSES)*
  • filter โ†’ util(3NCURSES)
  • find_pair โ†’ new_pair(3NCURSES)*
  • flash โ†’ beep(3NCURSES)
  • flushinp โ†’ util(3NCURSES)
  • free_pair โ†’ new_pair(3NCURSES)*
  • get_escdelay โ†’ threads(3NCURSES)*
  • get_wch โ†’ get_wch(3NCURSES)
  • get_wstr โ†’ get_wstr(3NCURSES)
  • getattrs โ†’ attr(3NCURSES)
  • getbegx โ†’ legacy(3NCURSES)*
  • getbegy โ†’ legacy(3NCURSES)*
  • getbegyx โ†’ getyx(3NCURSES)
  • getbkgd โ†’ bkgd(3NCURSES)
  • getbkgrnd โ†’ bkgrnd(3NCURSES)
  • getcchar โ†’ getcchar(3NCURSES)
  • getch โ†’ getch(3NCURSES)
  • getcurx โ†’ legacy(3NCURSES)*
  • getcury โ†’ legacy(3NCURSES)*
  • getmaxx โ†’ legacy(3NCURSES)*
  • getmaxy โ†’ legacy(3NCURSES)*
  • getmaxyx โ†’ getyx(3NCURSES)
  • getmouse โ†’ mouse(3NCURSES)*
  • getn_wstr โ†’ get_wstr(3NCURSES)
  • getnstr โ†’ getstr(3NCURSES)
  • getparx โ†’ legacy(3NCURSES)*
  • getpary โ†’ legacy(3NCURSES)*
  • getparyx โ†’ getyx(3NCURSES)
  • getstr โ†’ getstr(3NCURSES)
  • getsyx โ†’ kernel(3NCURSES)
  • getwin โ†’ util(3NCURSES)
  • getyx โ†’ getyx(3NCURSES)
  • halfdelay โ†’ inopts(3NCURSES)
  • has_colors โ†’ color(3NCURSES)
  • has_ic โ†’ termattrs(3NCURSES)
  • has_il โ†’ termattrs(3NCURSES)
  • has_key โ†’ getch(3NCURSES)*
  • has_mouse โ†’ mouse(3NCURSES)*
  • hline โ†’ border(3NCURSES)
  • hline_set โ†’ border_set(3NCURSES)
  • idcok โ†’ outopts(3NCURSES)
  • idlok โ†’ outopts(3NCURSES)
  • immedok โ†’ outopts(3NCURSES)
  • in_wch โ†’ in_wch(3NCURSES)
  • in_wchnstr โ†’ in_wchstr(3NCURSES)
  • in_wchstr โ†’ in_wchstr(3NCURSES)
  • inch โ†’ inch(3NCURSES)
  • inchnstr โ†’ inchstr(3NCURSES)
  • inchstr โ†’ inchstr(3NCURSES)
  • init_color โ†’ color(3NCURSES)
  • init_extended_color โ†’ color(3NCURSES)*
  • init_extended_pair โ†’ color(3NCURSES)*
  • init_pair โ†’ color(3NCURSES)
  • initscr โ†’ initscr(3NCURSES)

^ the main character, lowkey obsessed โœจ

  • innstr โ†’ instr(3NCURSES)
  • innwstr โ†’ inwstr(3NCURSES)
  • ins_nwstr โ†’ ins_wstr(3NCURSES)
  • ins_wch โ†’ ins_wch(3NCURSES)
  • ins_wstr โ†’ ins_wstr(3NCURSES)
  • insch โ†’ insch(3NCURSES)
  • insdelln โ†’ deleteln(3NCURSES)
  • insertln โ†’ deleteln(3NCURSES)
  • insnstr โ†’ insstr(3NCURSES)
  • insstr โ†’ insstr(3NCURSES)
  • instr โ†’ instr(3NCURSES)
  • intrflush โ†’ inopts(3NCURSES)
  • inwstr โ†’ inwstr(3NCURSES)
  • is_cbreak โ†’ inopts(3NCURSES)*
  • is_cleared โ†’ opaque(3NCURSES)*
  • is_echo โ†’ inopts(3NCURSES)*
  • is_idcok โ†’ opaque(3NCURSES)*
  • is_idlok โ†’ opaque(3NCURSES)*
  • is_immedok โ†’ opaque(3NCURSES)*
  • is_keypad โ†’ opaque(3NCURSES)*
  • is_leaveok โ†’ opaque(3NCURSES)*
  • is_linetouched โ†’ touch(3NCURSES)
  • is_nl โ†’ inopts(3NCURSES)*
  • is_nodelay โ†’ opaque(3NCURSES)*
  • is_notimeout โ†’ opaque(3NCURSES)*
  • is_pad โ†’ opaque(3NCURSES)*
  • is_raw โ†’ inopts(3NCURSES)*
  • is_scrollok โ†’ opaque(3NCURSES)*
  • is_subwin โ†’ opaque(3NCURSES)*
  • is_syncok โ†’ opaque(3NCURSES)*
  • is_term_resized โ†’ resizeterm(3NCURSES)*
  • is_wintouched โ†’ touch(3NCURSES)
  • isendwin โ†’ initscr(3NCURSES)

the whole is_ cinematic universe, truly a saga ๐Ÿฆ‹

  • key_defined โ†’ key_defined(3NCURSES)*
  • key_name โ†’ util(3NCURSES)
  • keybound โ†’ keybound(3NCURSES)*
  • keyname โ†’ util(3NCURSES)
  • keyok โ†’ keyok(3NCURSES)*
  • keypad โ†’ inopts(3NCURSES)
  • killchar โ†’ termattrs(3NCURSES)
  • killwchar โ†’ termattrs(3NCURSES)
  • leaveok โ†’ outopts(3NCURSES)
  • longname โ†’ termattrs(3NCURSES)
  • mcprint โ†’ print(3NCURSES)*
  • meta โ†’ inopts(3NCURSES)
  • mouse_trafo โ†’ mouse(3NCURSES)*
  • mouseinterval โ†’ mouse(3NCURSES)*
  • mousemask โ†’ mouse(3NCURSES)*
  • move โ†’ move(3NCURSES)
  • mvadd_wch โ†’ add_wch(3NCURSES)
  • mvadd_wchnstr โ†’ add_wchstr(3NCURSES)
  • mvadd_wchstr โ†’ add_wchstr(3NCURSES)
  • mvaddch โ†’ addch(3NCURSES)
  • mvaddchnstr โ†’ addchstr(3NCURSES)
  • mvaddchstr โ†’ addchstr(3NCURSES)
  • mvaddnstr โ†’ addstr(3NCURSES)
  • mvaddnwstr โ†’ addwstr(3NCURSES)
  • mvaddstr โ†’ addstr(3NCURSES)
  • mvaddwstr โ†’ addwstr(3NCURSES)
  • mvchgat โ†’ attr(3NCURSES)
  • mvcur โ†’ kernel(3NCURSES)
  • mvdelch โ†’ delch(3NCURSES)
  • mvderwin โ†’ window(3NCURSES)
  • mvget_wch โ†’ get_wch(3NCURSES)
  • mvget_wstr โ†’ get_wstr(3NCURSES)
  • mvgetch โ†’ getch(3NCURSES)
  • mvgetn_wstr โ†’ get_wstr(3NCURSES)
  • mvgetnstr โ†’ getstr(3NCURSES)
  • mvgetstr โ†’ getstr(3NCURSES)
  • mvhline โ†’ border(3NCURSES)
  • mvhline_set โ†’ border_set(3NCURSES)
  • mvin_wch โ†’ in_wch(3NCURSES)
  • mvin_wchnstr โ†’ in_wchstr(3NCURSES)

โ€ฆand the list just KEEPS going, bestie, because ncurses has more aliases than your fave has unreleased demos ๐Ÿ’…. Same deal as up top: the name on the left is what you actually type, the page on the right is where the real โœจloreโœจ lives, and a * means it's one of the special-edition girlies (you clocked that legend earlier ๐Ÿ‘€).

  • mvin_wchstr โ†’ in_wchstr(3NCURSES)
  • mvinch โ†’ inch(3NCURSES)
  • mvinchnstr โ†’ inchstr(3NCURSES)
  • mvinchstr โ†’ inchstr(3NCURSES)
  • mvinnstr โ†’ instr(3NCURSES)
  • mvinnwstr โ†’ inwstr(3NCURSES)
  • mvins_nwstr โ†’ ins_wstr(3NCURSES)
  • mvins_wch โ†’ ins_wch(3NCURSES)
  • mvins_wstr โ†’ ins_wstr(3NCURSES)
  • mvinsch โ†’ insch(3NCURSES)
  • mvinsnstr โ†’ insstr(3NCURSES)
  • mvinsstr โ†’ insstr(3NCURSES)
  • mvinstr โ†’ instr(3NCURSES)
  • mvinwstr โ†’ inwstr(3NCURSES)
  • mvprintw โ†’ printw(3NCURSES)
  • mvscanw โ†’ scanw(3NCURSES)
  • mvvline โ†’ border(3NCURSES)
  • mvvline_set โ†’ border_set(3NCURSES)

okay that whole mv-and-then-yank-a-line block is giving "move cursor, then do the thing" energy and honestly? consistent queen behavior ๐Ÿ‘‘.

  • mvwadd_wch โ†’ add_wch(3NCURSES)
  • mvwadd_wchnstr โ†’ add_wchstr(3NCURSES)
  • mvwadd_wchstr โ†’ add_wchstr(3NCURSES)
  • mvwaddch โ†’ addch(3NCURSES)
  • mvwaddchnstr โ†’ addchstr(3NCURSES)
  • mvwaddchstr โ†’ addchstr(3NCURSES)
  • mvwaddnstr โ†’ addstr(3NCURSES)
  • mvwaddnwstr โ†’ addwstr(3NCURSES)
  • mvwaddstr โ†’ addstr(3NCURSES)
  • mvwaddwstr โ†’ addwstr(3NCURSES)
  • mvwchgat โ†’ attr(3NCURSES)
  • mvwdelch โ†’ delch(3NCURSES)
  • mvwget_wch โ†’ get_wch(3NCURSES)
  • mvwget_wstr โ†’ get_wstr(3NCURSES)
  • mvwgetch โ†’ getch(3NCURSES)
  • mvwgetn_wstr โ†’ get_wstr(3NCURSES)
  • mvwgetnstr โ†’ getstr(3NCURSES)
  • mvwgetstr โ†’ getstr(3NCURSES)
  • mvwhline โ†’ border(3NCURSES)
  • mvwhline_set โ†’ border_set(3NCURSES)
  • mvwin โ†’ window(3NCURSES)
  • mvwin_wch โ†’ in_wch(3NCURSES)
  • mvwin_wchnstr โ†’ in_wchstr(3NCURSES)
  • mvwin_wchstr โ†’ in_wchstr(3NCURSES)
  • mvwinch โ†’ inch(3NCURSES)
  • mvwinchnstr โ†’ inchstr(3NCURSES)
  • mvwinchstr โ†’ inchstr(3NCURSES)
  • mvwinnstr โ†’ instr(3NCURSES)
  • mvwinnwstr โ†’ inwstr(3NCURSES)
  • mvwins_nwstr โ†’ ins_wstr(3NCURSES)
  • mvwins_wch โ†’ ins_wch(3NCURSES)
  • mvwins_wstr โ†’ ins_wstr(3NCURSES)
  • mvwinsch โ†’ insch(3NCURSES)
  • mvwinsnstr โ†’ insstr(3NCURSES)
  • mvwinsstr โ†’ insstr(3NCURSES)
  • mvwinstr โ†’ instr(3NCURSES)
  • mvwinwstr โ†’ inwstr(3NCURSES)
  • mvwprintw โ†’ printw(3NCURSES)
  • mvwscanw โ†’ scanw(3NCURSES)
  • mvwvline โ†’ border(3NCURSES)
  • mvwvline_set โ†’ border_set(3NCURSES)

not the mvw prefix showing up like it pays rent here ๐Ÿ˜ญ move + window + do-the-thing, the trio that ate and left no crumbs ๐Ÿ“.

  • napms โ†’ kernel(3NCURSES)
  • newpad โ†’ pad(3NCURSES)
  • newterm โ†’ initscr(3NCURSES)
  • newwin โ†’ window(3NCURSES)

the four new* girlies: making pads, terms and windows out of thin air, main character energy fr fr โœจ.

  • nl โ†’ inopts(3NCURSES)
  • nocbreak โ†’ inopts(3NCURSES)
  • nodelay โ†’ inopts(3NCURSES)
  • noecho โ†’ inopts(3NCURSES)
  • nofilter โ†’ util(3NCURSES) *
  • nonl โ†’ inopts(3NCURSES)
  • noqiflush โ†’ inopts(3NCURSES)
  • noraw โ†’ inopts(3NCURSES)
  • notimeout โ†’ inopts(3NCURSES)

the no-squad ๐Ÿ’€ literally the "turn that setting OFF bestie" clique, and almost all of them clocked in at inopts(3NCURSES) except nofilter, who went solo to util(3NCURSES) with a lil star, because she's built different ๐ŸŒŸ.

  • overlay โ†’ overlay(3NCURSES)
  • overwrite โ†’ overlay(3NCURSES)
  • pair_content โ†’ color(3NCURSES)
  • pecho_wchar โ†’ pad(3NCURSES)
  • pechochar โ†’ pad(3NCURSES)
  • pnoutrefresh โ†’ pad(3NCURSES)
  • prefresh โ†’ pad(3NCURSES)
  • printw โ†’ printw(3NCURSES)
  • putp โ†’ terminfo(3NCURSES)
  • putwin โ†’ util(3NCURSES)

printw documenting itself is so self-referential and honestly iconic of her ๐ŸŽ€. and the p* pad girlies (pecho_wchar, pechochar, pnoutrefresh, prefresh) all filed under pad(3NCURSES) โ€” obsessed with the consistency.

  • qiflush โ†’ inopts(3NCURSES)
  • raw โ†’ inopts(3NCURSES)
  • redrawwin โ†’ refresh(3NCURSES)
  • refresh โ†’ refresh(3NCURSES)
  • reset_color_pairs โ†’ color(3NCURSES) *
  • reset_prog_mode โ†’ kernel(3NCURSES)
  • reset_shell_mode โ†’ kernel(3NCURSES)
  • resetty โ†’ kernel(3NCURSES)
  • resize_term โ†’ resizeterm(3NCURSES) *
  • resizeterm โ†’ resizeterm(3NCURSES) *
  • restartterm โ†’ terminfo(3NCURSES)
  • ripoffline โ†’ kernel(3NCURSES)

qiflush is the un-no twin of noqiflush and they both live at inopts(3NCURSES) like the lil duo they are ๐Ÿซถ. meanwhile the reset* crew split up: kernel(3NCURSES) got three of them, color(3NCURSES) got one (starry โœจ), and the resize* besties both made it to resizeterm(3NCURSES) โญ.

  • savetty โ†’ kernel(3NCURSES)
  • scanw โ†’ scanw(3NCURSES)
  • scr_dump โ†’ scr_dump(3NCURSES)
  • scr_init โ†’ scr_dump(3NCURSES)
  • scr_restore โ†’ scr_dump(3NCURSES)
  • scr_set โ†’ scr_dump(3NCURSES)
  • scrl โ†’ scroll(3NCURSES)
  • scroll โ†’ scroll(3NCURSES)
  • scrollok โ†’ outopts(3NCURSES)
  • set_curterm โ†’ terminfo(3NCURSES)
  • set_escdelay โ†’ threads(3NCURSES) *
  • set_tabsize โ†’ threads(3NCURSES) *
  • set_term โ†’ initscr(3NCURSES)
  • setcchar โ†’ getcchar(3NCURSES)
  • setscrreg โ†’ outopts(3NCURSES)
  • setsyx โ†’ kernel(3NCURSES)
  • setupterm โ†’ terminfo(3NCURSES)

the whole scr_* family went to scr_dump(3NCURSES) together like a carpool, no cap ๐Ÿš—. and set_escdelay + set_tabsize are giving "why are you two in threads(3NCURSES)?" energy, but they're both starry so you know they're fancy ๐ŸŒˆ.

  • slk_attr โ†’ slk(3NCURSES) *
  • slk_attr_off โ†’ slk(3NCURSES)
  • slk_attr_on โ†’ slk(3NCURSES)
  • slk_attr_set โ†’ slk(3NCURSES)
  • slk_attroff โ†’ slk(3NCURSES)
  • slk_attron โ†’ slk(3NCURSES)
  • slk_attrset โ†’ slk(3NCURSES)
  • slk_clear โ†’ slk(3NCURSES)
  • slk_color โ†’ slk(3NCURSES)
  • slk_init โ†’ slk(3NCURSES)
  • slk_label โ†’ slk(3NCURSES)
  • slk_noutrefresh โ†’ slk(3NCURSES)
  • slk_refresh โ†’ slk(3NCURSES)
  • slk_restore โ†’ slk(3NCURSES)
  • slk_set โ†’ slk(3NCURSES)
  • slk_touch โ†’ slk(3NCURSES)
  • slk_wset โ†’ slk(3NCURSES)
  • standend โ†’ attr(3NCURSES)
  • standout โ†’ attr(3NCURSES)
  • start_color โ†’ color(3NCURSES)
  • subpad โ†’ pad(3NCURSES)
  • subwin โ†’ window(3NCURSES)
  • syncok โ†’ window(3NCURSES)

the ENTIRE slk_ roster pulling up to slk(3NCURSES) in matching outfits is the biggest slay of this whole list, periodt ๐Ÿ’– (only slk_attr brought her lil star โœจ).

  • term_attrs โ†’ termattrs(3NCURSES)
  • termattrs โ†’ termattrs(3NCURSES)
  • termname โ†’ termattrs(3NCURSES)
  • tgetent โ†’ termcap(3NCURSES)
  • tgetflag โ†’ termcap(3NCURSES)
  • tgetnum โ†’ termcap(3NCURSES)
  • tgetstr โ†’ termcap(3NCURSES)
  • tgoto โ†’ termcap(3NCURSES)
  • tigetflag โ†’ terminfo(3NCURSES)
  • tigetnum โ†’ terminfo(3NCURSES)
  • tigetstr โ†’ terminfo(3NCURSES)
  • timeout โ†’ inopts(3NCURSES)
  • tiparm โ†’ terminfo(3NCURSES)
  • tiparm_s โ†’ terminfo(3NCURSES) *
  • tiscan_s โ†’ terminfo(3NCURSES) *
  • touchline โ†’ touch(3NCURSES)
  • touchwin โ†’ touch(3NCURSES)
  • tparm โ†’ terminfo(3NCURSES)
  • tputs โ†’ termcap(3NCURSES)
  • tputs โ†’ terminfo(3NCURSES)
  • trace โ†’ trace(3NCURSES) *
  • typeahead โ†’ inopts(3NCURSES)

so the tget* and tiget* besties are literally the same energy in two different friend groups โ€” termcap(3NCURSES) vs terminfo(3NCURSES) โ€” and honestly? the way tputs is listed TWICE, once for each page, is such a poly icon move ๐Ÿฆ‹. and yes, trace documents trace, we love a self-titled era ๐ŸŽ€.

  • unctrl โ†’ util(3NCURSES)
  • unget_wch โ†’ get_wch(3NCURSES)
  • ungetch โ†’ getch(3NCURSES)
  • ungetmouse โ†’ mouse(3NCURSES) *
  • untouchwin โ†’ touch(3NCURSES)
  • use_default_colors โ†’ default_colors(3NCURSES) *
  • use_env โ†’ util(3NCURSES)
  • use_extended_names โ†’ extensions(3NCURSES) *
  • use_legacy_coding โ†’ legacy_coding(3NCURSES) *
  • use_screen โ†’ threads(3NCURSES) *
  • use_tioctl โ†’ util(3NCURSES) *
  • use_window โ†’ threads(3NCURSES) *

the un* squad undoing everything like the cleanup crew they are ๐Ÿ˜ญ and use_window + use_screen both ran off to threads(3NCURSES) together, starry and unbothered โญ.

  • vid_attr โ†’ terminfo(3NCURSES)
  • vid_puts โ†’ terminfo(3NCURSES)
  • vidattr โ†’ terminfo(3NCURSES)
  • vidputs โ†’ terminfo(3NCURSES)
  • vline โ†’ border(3NCURSES)
  • vline_set โ†’ border_set(3NCURSES)
  • vw_printw โ†’ printw(3NCURSES)
  • vw_scanw โ†’ scanw(3NCURSES)
  • vwprintw โ†’ printw(3NCURSES)
  • vwscanw โ†’ scanw(3NCURSES)

no notes, the vid* four went to terminfo(3NCURSES) as a unit ๐Ÿซถ and the vw_ vs vw naming duality is exactly the kind of chaos this library serves daily ๐Ÿ’€.

  • wadd_wch โ†’ add_wch(3NCURSES)
  • wadd_wchnstr โ†’ add_wchstr(3NCURSES)
  • wadd_wchstr โ†’ add_wchstr(3NCURSES)
  • waddch โ†’ addch(3NCURSES)
  • waddchnstr โ†’ addchstr(3NCURSES)
  • waddchstr โ†’ addchstr(3NCURSES)
  • waddnstr โ†’ addstr(3NCURSES)
  • waddnwstr โ†’ addwstr(3NCURSES)
  • waddstr โ†’ addstr(3NCURSES)
  • waddwstr โ†’ addwstr(3NCURSES)
  • wattr_get โ†’ attr(3NCURSES)
  • wattr_off โ†’ attr(3NCURSES)
  • wattr_on โ†’ attr(3NCURSES)
  • wattr_set โ†’ attr(3NCURSES)
  • wattroff โ†’ attr(3NCURSES)
  • wattron โ†’ attr(3NCURSES)
  • wattrset โ†’ attr(3NCURSES)
  • wbkgd โ†’ bkgd(3NCURSES)
  • wbkgdset โ†’ bkgd(3NCURSES)
  • wbkgrnd โ†’ bkgrnd(3NCURSES)
  • wbkgrndset โ†’ bkgrnd(3NCURSES)
  • wborder โ€” border(3NCURSES)
  • wborder_set โ€” border_set(3NCURSES)
  • wchgat โ€” attr(3NCURSES)
  • wclear โ€” clear(3NCURSES)
  • wclrtobot โ€” clear(3NCURSES)
  • wclrtoeol โ€” clear(3NCURSES)
  • wcolor_set โ€” attr(3NCURSES)
  • wcursyncup โ€” window(3NCURSES)
  • wdelch โ€” delch(3NCURSES)
  • wdeleteln โ€” deleteln(3NCURSES)
  • wecho_wchar โ€” add_wch(3NCURSES)
  • wechochar โ€” addch(3NCURSES)
  • wenclose โ€” mouse(3NCURSES)*
  • werase โ€” clear(3NCURSES)
  • wget_wch โ€” get_wch(3NCURSES)
  • wget_wstr โ€” get_wstr(3NCURSES)
  • wgetbkgrnd โ€” bkgrnd(3NCURSES)
  • wgetch โ€” getch(3NCURSES)
  • wgetdelay โ€” opaque(3NCURSES)*
  • wgetn_wstr โ€” get_wstr(3NCURSES)
  • wgetnstr โ€” getstr(3NCURSES)
  • wgetparent โ€” opaque(3NCURSES)*
  • wgetscrreg โ€” opaque(3NCURSES)*
  • wgetstr โ€” getstr(3NCURSES)
  • whline โ€” border(3NCURSES)
  • whline_set โ€” border_set(3NCURSES)
  • win_wch โ€” in_wch(3NCURSES)
  • win_wchnstr โ€” in_wchstr(3NCURSES)
  • win_wchstr โ€” in_wchstr(3NCURSES)
  • winch โ€” inch(3NCURSES)
  • winchnstr โ€” inchstr(3NCURSES)
  • winchstr โ€” inchstr(3NCURSES)
  • winnstr โ€” instr(3NCURSES)
  • winnwstr โ€” inwstr(3NCURSES)
  • wins_nwstr โ€” ins_wstr(3NCURSES)
  • wins_wch โ€” ins_wch(3NCURSES)
  • wins_wstr โ€” ins_wstr(3NCURSES)
  • winsch โ€” insch(3NCURSES)
  • winsdelln โ€” deleteln(3NCURSES)
  • winsertln โ€” deleteln(3NCURSES)
  • winsnstr โ€” insstr(3NCURSES)
  • winsstr โ€” insstr(3NCURSES)
  • winstr โ€” instr(3NCURSES)
  • winwstr โ€” inwstr(3NCURSES)
  • wmouse_trafo โ€” mouse(3NCURSES)*
  • wmove โ€” move(3NCURSES)
  • wnoutrefresh โ€” refresh(3NCURSES)
  • wprintw โ€” printw(3NCURSES)
  • wredrawln โ€” refresh(3NCURSES)
  • wrefresh โ€” refresh(3NCURSES)
  • wresize โ€” wresize(3NCURSES)*
  • wscanw โ€” scanw(3NCURSES)
  • wscrl โ€” scroll(3NCURSES)
  • wsetscrreg โ€” outopts(3NCURSES)
  • wstandend โ€” attr(3NCURSES)
  • wstandout โ€” attr(3NCURSES)
  • wsyncdown โ€” window(3NCURSES)
  • wsyncup โ€” window(3NCURSES)
  • wtimeout โ€” inopts(3NCURSES)
  • wtouchln โ€” touch(3NCURSES)
  • wunctrl โ€” util(3NCURSES)
  • wvline โ€” border(3NCURSES)
  • wvline_set โ€” border_set(3NCURSES)

okay so ncurses has this screen-pointer extension that adds extra functions matching a lot of the ones above, each one rocking an _sp suffix; peep sp_funcs(3NCURSES) for the deets. ๐Ÿ’…

and lowkey, whether you get some of these extensions depends on how ncurses was compiled โ€” check the sections โ€œALTERNATE CONFIGURATIONSโ€ and โ€œEXTENSIONSโ€ down below. ๐Ÿ› ๏ธ

๐ŸŽฏ RETURN VALUE

okay so unless the manpage says otherwise, functions that return integers give you OK when things are slay and ERR when they're a flop โ€” check curses_variables(3NCURSES) for the receipts. functions that return pointers? they hand you a null pointer on failure. and bestie, ncurses usually treats a null pointer passed as a parameter as a big ol' failure too. also, any function starting with mv does cursor movement first, and it'll fail if the position (y, x) is outside the window boundaries. no cap. ๐Ÿ’ฏ

๐ŸŒ ENVIRONMENT

these process environment symbols let you customize how ncurses apps act at runtime. but heads up: the library can be configured to ignore TERMINFO, TERMINFO_DIRS, TERMPATH, and HOME if you're the superuser (root), or if the app uses setuid(2) or setgid(2). so yeah, security vibes. ๐Ÿ”’

๐Ÿข BAUDRATE

when the app has redirected output to a file, the debugging library peeks at this variable. ncurses takes its integral value as the terminal's line speed in bits per second. if that value is missing or just plain wrong, ncurses falls back to 9600. this lets devs build repeatable test cases that account for optimization choices based on the terminal's line speed. iykyk. ๐Ÿ“‰

โŒจ๏ธ CC (command character)

when you set this, the command_character (cmdch) capability value of any loaded terminfo entries changes to whatever this variable is. honestly, like, very few terminfo entries even have this feature.

and because this name is also used in dev environments to store the C compiler's name, ncurses straight up ignores its value if it's not exactly one character long. so don't try to put gcc in there. ๐Ÿ’€

๐Ÿ“ COLUMNS

this variable is the screen width in character cells. apps running in a windowing environment can usually just grab the width of their window, but ncurses enforces an upper limit of 512 when reading the value. if COLUMNS isn't defined and the terminal's screen size isn't available from the terminal driver, ncurses uses the size from the columns (cols) capability of the terminal type's terminfo entry, if there is one.

it's super important that your app uses the correct screen size. automatic detection isn't always possible because the app might be running on a host that doesn't honor NAWS (Negotiations About Window Size), or as a different user ID than the owner of the terminal device file. setting COLUMNS and/or LINES overrides the library's use of the screen size from the operating system.

and you can set COLUMNS and LINES independently! that's clutch for dodging the weird quirks of legacy terminal type descriptions โ€” like, xterm(1) descriptions that said 65 lines were once totally notorious. for best results, don't put cols and lines capability codes in terminfo descriptions of terminal emulators. periodt.

use_env(3NCURSES) can turn off using the process environment for determining screen size. use_tioctl(3NCURSES) can update COLUMNS and LINES to match the screen size from system calls or the terminal database. ๐Ÿ’…

โณ ESCDELAY

so for curses to tell the difference between an ESC character from you pressing the โ€œEscapeโ€ key and one that's the start of an escape sequence (like function keys make), it waits after getting that escape character to see if more characters show up on the input stream within a short interval. there's a global variable ESCDELAY that stores this interval in milliseconds. the default 1000 (one second) is fine for most uses, but this environment variable overrides it. ncurses enforces an upper limit of 30,000 (30 seconds) when reading the value.

the most common reason you'd wanna change this is when you're working with a remote host over a slow connection. if the host running the curses app doesn't get the characters of an escape sequence in time, the library might think they're separate key presses. and on the flip side, a fast typist on a low-latency connection who hits ESC followed by characters that match an escape sequence might get super confusing app behavior. ๐Ÿ˜ญ

also, xterm(1) mouse events are a type of escape sequence, so if your app does a lot of multiple-clicking, you might wanna lengthen the default value โ€” because the delay applies to the whole multi-click event, not just individual clicks. ๐Ÿ–ฑ๏ธ

portable apps shouldn't rely on ESCDELAY existing in either form, but setting the environment variable instead of the global variable won't cause problems when compiling. and if keypad(3NCURSES) is disabled for the curses window getting input, ESCDELAY is irrelevant and your program has to disambiguate escape sequences all by itself. good luck bestie. ๐Ÿ’€

๐Ÿ  HOME

ncurses might read and write extra terminal descriptions in .termcap and .terminfo files in the user's home directory. so like, keep an eye on those. ๐Ÿก

๐Ÿ“ LINES

this is the counterpart to COLUMNS โ€” it sets the screen height in characters. the matching terminfo capability and code is lines. peep the COLUMNS description above for the full tea. โ˜•

๐Ÿ–ฑ๏ธ MOUSE_BUTTONS_123

(OS/2 EMX port only, bestie) OS/2 numbers a three-button mouse weirdly compared to other platforms: 1 is the left button, 2 is the right, and 3 is the middle. this variable customizes the mouse button numbering. its value must be three digits 1-3 in any order. by default, ncurses assumes a numbering of โ€œ132โ€. ๐Ÿญ

๐ŸŽจ NCURSES_ASSUMED_COLORS

if you set this, it overrides ncurses's compiled-in assumption that the terminal's default colors are white on black. check default_colors(3NCURSES) for more. set the foreground and background color values with this environment variable by giving it two integer values separated by a comma โ€” first is foreground, second is background.

for example, to tell ncurses not to assume anything about colors, use a value of โ€œ-1,-1โ€. 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โ€. ncurses accepts integral values from -1 up to the value of the terminfo max_colors (colors) capability for the selected terminal type. ๐ŸŒˆ

๐Ÿ’ป NCURSES_CONSOLE2

(MinGW port only) the Console2 program has a defective handling of the Microsoft Console API call CreateConsoleScreenBuffer. apps that use it will hang. ๐Ÿ˜ฑ but you can simulate what that call does by mapping coordinates, explicitly saving and restoring the original screen contents. setting the environment variable NCGDB has the same effect. so yeah, hack the planet. ๐Ÿ› ๏ธ

๐Ÿง NCURSES_GPM_TERMS

(Linux only) when ncurses is set up to use the GPM interface, this variable can list one or more terminal type names, separated by vertical bars (|) or colons (:), and it'll match against the TERM variable (see below). an empty value disables the GPM interface, so ncurses uses its built-in support for xterm(1) mouse protocols instead. if the variable isn't there at all, ncurses tries to open GPM if TERM contains โ€œlinuxโ€. ๐Ÿญ

๐Ÿ“ NCURSES_NO_HARD_TABS

okay so bestie, sometimes ncurses is gonna use tab characters in its cursor movement optimization. efficient, iconic, we love her. BUT โ€” in some cases your terminal driver just does not handle tabs properly, and it all falls apart. ๐Ÿ’€ so if that's happening to you, set this environment variable to any value at all and the feature gets disabled. you can also go tweak your stty(1) settings if you'd rather fix it that way. both are valid, you do you.

so like, a lot of terminals store video attributes as properties of a character cell โ€” which is literally what curses does too. but historically? some terminals recorded attribute changes as data that logically (but invisibly!!) occupied character cells on the display, flipping attributes on and off like tags in a markup language. and then those cells had to be overprinted to show the actual contents you wanted. these are what we call "magic cookies" ๐Ÿชโœจ

if the terminfo entry for your terminal type doesn't adequately describe how it handles magic cookies, set this variable to any value and ncurses will be instructed to disable attributes entirely. yes, entirely. she's dramatic like that.

๐ŸŒธ NCURSES_NO_PADDING

most of the terminal type descriptions in the terminfo database are describing actual hardware devices. but plenty of us are running curses-based apps inside terminal emulator programs chillin' in a windowing environment. those programs can duplicate all the important features of a hardware terminal โ€” highkey slay โ€” but they often lack the limitations.

and the biggest missing drawback? data flow management. that's the whole "limiting the speed of communication to what the hardware could handle" situation. unless a hardware terminal is interfaced into a terminal concentrator (which does flow control for you), an application has to manage flow itself to prevent overruns and data loss.

so here's a solution that costs zero hardware: an application just pauses transmission after telling the terminal to do something slow โ€” like clearing the display. and a ton of terminal type descriptions (including the one for the VT100) embed delay specifications right there in the capabilities. so you might wanna use those descriptions without paying the performance penalty. set NCURSES_NO_PADDING to any value to disable all but mandatory padding. and mandatory padding is what such terminal capabilities as flash_screen (flash) use. ๐Ÿซถ

๐Ÿ™ˆ NCURSES_NO_SETBUF

(Obsolete) so before the internal changes developed in ncurses 5.9 (patches 20120825 through 20130126), the library used setbuf(3) to enable fully buffered output when it initialized the terminal. it did this, just like in SVr4 curses, to boost performance. and for testing purposes โ€” both of ncurses and of certain applications โ€” this feature was made optional. setting this variable disabled output buffering, leaving the output stream in the original (usually line-buffered) mode.

these days though? ncurses does its own buffering and doesn't need this workaround at all; it does not modify the buffering of the standard output stream. this approach makes the library's handling of keyboard-initiated signals way more robust. one drawback: certain unconventional programs mixed stdio(3) calls with ncurses calls and (usually) got the behavior they expected. that is no longer the case โ€” ncurses does not write to the standard output file descriptor through a stdio-buffered stream.

as a special case though, low-level API calls such as putp(3NCURSES) still use the standard output stream. high-level curses calls such as printw(3NCURSES) do not. iykyk ๐Ÿ’…

๐Ÿฆ‹ NCURSES_NO_UTF8_ACS

at initialization, ncurses inspects the TERM environment variable looking for special cases where VT100 forms-drawing characters (and the corresponding alternate character set terminfo capabilities) are known to be unsupported by terminal types that otherwise claim VT100 compatibility. specifically: when running in a UTF-8 locale, the Linux virtual console device and the GNU screen(1) program just ignore them. ๐Ÿ˜ญ

set this variable to a nonzero value to tell ncurses that the terminal's ACS support is broken; the library then outputs Unicode code points that correspond to the forms-drawing characters. set it to zero (or a non-integer) to disable the special check for terminal type names matching "linux" or "screen" โ€” which directs ncurses to assume the ACS feature works if the terminal type description advertises it.

as an alternative to using this variable, ncurses checks for an extended terminfo numeric capability U8 that can be compiled using tic -x. examples follow. โฌ‡๏ธ

# linux console, if patched to provide working
# VT100 shift-in/shift-out, with corresponding font.
linux-vt100|linux console with VT100 line-graphics,
        U8#0, use=linux,

# uxterm with vt100Graphics resource set to false
xterm-utf8|xterm relying on UTF-8 line-graphics,
        U8#1, use=xterm,

the two-character name "U8" was chosen to permit its use via ncurses's termcap interface. little detail, big brain move. ๐Ÿ’–

โญ NCURSES_TRACE

at initialization, ncurses (in its debugging configuration) checks for this variable's presence. if it's defined with an integral value, the library calls curses_trace(3NCURSES) with that value as the argument. that's it, that's the whole thing.

๐Ÿ‘‘ TERM

the TERM variable denotes the terminal type. each one is distinct, though lots of them are similar. it's commonly set by terminal emulators to help applications find a workable terminal description. some of them choose a popular approximation like "ansi", "vt100", or "xterm" rather than an exact fit for their capabilities. and not infrequently, an application will have problems with that approach โ€” like maybe a keystroke doesn't operate correctly, or it does nothing except spew what looks like garbage characters on the screen. ๐Ÿซ 

setting TERM has no effect on hardware operation; it affects the way applications communicate with the terminal. likewise, as a general rule (xterm(1) being a rare exception), terminal emulators that let you specify TERM as a parameter or configuration value do not change their behavior to match that setting. so don't expect them to shapeshift, bestie.

๐ŸŒˆ TERMCAP

if ncurses is configured with termcap support, it checks for a terminal type description in termcap format whenever one in terminfo format isn't available. setting this variable directs ncurses to ignore the usual termcap database location, /etc/termcap โ€” see TERMPATH below. TERMCAP should contain either a terminal description (with newlines stripped out), or a file name indicating where the information required by the TERM environment variable is stored.

๐Ÿ’œ TERMINFO

ncurses can be configured to read terminal type description databases in various locations using different formats. this variable overrides the default location.

  • descriptions in terminfo format are normally stored in a directory tree using subdirectories named for the common first letters of the terminal types named therein. System V used this scheme.
  • if ncurses is configured to use hashed databases, then TERMINFO may name its location, such as /usr/share/terminfo.db, rather than /usr/share/terminfo/.

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, ignoring the terminfo API. rude, honestly.

  • if ncurses is configured with termcap support, this variable may contain the location of a termcap file.
  • if the value of TERMINFO begins with "hex:" or "b64:", ncurses uses the remainder of the value as a compiled terminfo description. you might produce the base64 format using infocmp(1).
TERMINFO=$(infocmp -0 -Q2 -q)
export TERMINFO

ncurses uses the compiled description only if it corresponds to the terminal type identified by TERM.

setting TERMINFO is the simplest โ€” but not the only โ€” way to direct ncurses to a terminal database. the search path is as follows. ๐Ÿ“œ

  • the last terminal database to which the running ncurses application wrote, if any
  • the location specified by the TERMINFO environment variable
  • $HOME/.terminfo
  • locations listed in the TERMINFO_DIRS environment variable
  • location(s) configured and compiled into ncurses
    • /etc/terminfo:/lib/terminfo:/usr/share/terminfo
    • /etc/terminfo

๐Ÿงš TERMINFO_DIRS

this variable specifies a list of locations, akin to PATH, in which ncurses searches for the terminal type descriptions described by TERMINFO above. the list items are separated by colons on Unix and semicolons on OS/2 EMX. System V terminfo lacks a corresponding feature, so heads up: TERMINFO_DIRS is an ncurses extension. โญ

๐ŸŽ€ TERMPATH

if TERMCAP does not hold a terminal type description or file name, then ncurses checks the contents of TERMPATH โ€” a list of locations, akin to PATH, in which it searches for termcap terminal type descriptions. the list items are separated by colons on Unix and semicolons on OS/2 EMX.

and if both TERMCAP and TERMPATH are unset or invalid, ncurses searches for the files /etc/termcap, /usr/share/misc/termcap, and $HOME/.termcap, in that order. no skipping, no vibes-based ordering, just that order. ๐Ÿ’…

โœจ ALTERNATE CONFIGURATIONS โœจ

okay so bestie, here's the tea โ˜• โ€” there are so many different ncurses configurations possible, and they're all determined by the options you hand to the configure script when you're building the library. Run the script with the --help option to peruse them all ๐Ÿ‘€. A few of them are particularly significant to the application developer employing ncurses, so let's get into those ones.


๐Ÿšซ --disable-overwrite

Avoid file name conflicts between ncurses and an existing curses installation on the system. The standard C preprocessor inclusion for the curses library is as follows:

#include <curses.h>

If ncurses is installed disabling overwrite, it puts its header files in a subdirectory. Here's an example:

#include <ncurses/curses.h>

With --disable-overwrite, installation also omits a symbolic link that would cause the compiler's -lcurses option to link object files with ncurses instead of the system curses library. ๐Ÿ’…

The directory used by this configuration of ncurses is shown in section โ€œSYNOPSISโ€ above.

๐ŸŒˆ --enable-widec

(default for ABI 6+ since 2023-10-21) Enable support for wide characters. The configure script renames the ncurses library (and the tinfo library, if --with-termlib is also specified), appending โ€œwโ€. An application desirous of wide-character support then uses -lncursesw (or -ltinfow) instead of -lncurses (or -ltinfo) as its linker option. The ncurses++, panel, form, and menu libraries are renamed similarly.

An application must also define certain C preprocessor symbols to enable wide-character features in curses header files to use the extended (wide-character) functions. The symbol that enables these features has changed since X/Open Curses Issue 4. ๐Ÿ•ฐ๏ธ

  • Originally, the wide-character feature required the symbol _XOPEN_SOURCE_EXTENDED, but that was valid only for XPG4 (1996).
  • Later, that was deemed conflicting with an _XOPEN_SOURCE value of 500.
  • As of mid-2018, no ncurses feature requires an _XOPEN_SOURCE value greater than 600. However, X/Open Curses Issue 7 (2009) recommends defining it to 700.
  • Alternatively, you can enable the feature by defining NCURSES_WIDECHAR with the caveat that some header file other than curses.h may require a specific value for _XOPEN_SOURCE (or a system-specific symbol).

The 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 WINDOW structure differs; few applications require more than pointers to WINDOW.

If ncurses's header files are installed allowing overwrite (the default, but see --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. ๐Ÿซถ

๐Ÿงต --with-pthread

Enable support for multi-threaded applications. The configure script renames the ncurses library (and the tinfo library, if --with-termlib is also specified), appending โ€œtโ€ (before any โ€œwโ€ added by --enable-widec). An application desirous of support for multiple threads of execution then uses, for example, -lncursest (or -ltinfot) instead of -lncurses (or -ltinfo) as its linker option. The ncurses++, panel, form, and menu libraries are renamed similarly.

ncursest and ncursestw replace global variables such as 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.

๐Ÿ“ฆ --with-shared, --with-normal, --with-debug, --with-profile

Mandate compilation of the ncurses library (and the tinfo library, if --with-termlib is also specified) in the specified forms. The shared and normal (static) library names differ by their suffixes, as with libncurses.so and libncurses.a. The debugging and profiling libraries add a โ€œ_gโ€ and a โ€œ_pโ€ to the roots of these respective names, forming libncurses_g.so and libncurses_p.a, for example. The ncurses++, panel, form, and menu libraries are made available similarly.

๐Ÿ” --with-termlib

Provide ncurses's lower-level terminal interface functions (those that do not depend on the SCREEN and WINDOW abstractions) in a library named tinfo. This arrangement reduces an application's linking and/or loading times when it does not require curses's higher-level features. โฑ๏ธ

The following pages document curses functions provided by tinfo.

  • extensions(3NCURSES) - miscellaneous ncurses extensions
  • inopts(3NCURSES) - curses input options
  • kernel(3NCURSES) - low-level curses routines
  • termattrs(3NCURSES) - curses environment query routines
  • termcap(3NCURSES) - curses emulation of termcap
  • terminfo(3NCURSES) - curses interface to terminfo database
  • util(3NCURSES) - miscellaneous curses utility routines

๐Ÿ•ต๏ธ --with-trace

Expose the curses_trace(3NCURSES) function in the ncurses(w) shared and static libraries. Normally, it is available only in the debugging library. (If --with-termlib is also specified, tinfo(w) rather than ncurses(w) supplies the deprecated trace(3NCURSES) function.) An application's configuration script should check for the function's existence rather than assuming its confinement to the debugging library. ๐Ÿ‘€


๐Ÿ—‚๏ธ FILES

  • /usr/share/tabset โ€” tab stop initialization database
  • /etc/terminfo โ€” compiled terminal capability database

๐Ÿ“ NOTES

X/Open Curses permits most functions it specifies to be made available as macros as well. ncurses does so ๐Ÿซก

  • for functions that return values via their parameters,
  • to support obsolete features,
  • to reuse functions (for example, those that move the cursor before another operation), and
  • in a few special cases.

If the standard output file descriptor of an 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 curses. ๐Ÿ’€

See subsection โ€œHeader Filesโ€ below regarding symbols exposed by inclusion of curses.h.


๐Ÿฆ‹ EXTENSIONS

ncurses enables an application to capture mouse events from certain terminals, including xterm(1); see mouse(3NCURSES). ๐Ÿญ

ncurses provides a means of responding to window resizing events, as when running in a GUI terminal emulator application such as xterm; see resizeterm(3NCURSES) and wresize(3NCURSES).

ncurses allows an application to query the terminal for the presence of a wide variety of special keys; see has_key(3NCURSES).

ncurses extends the fixed set of function key capabilities specified by X/Open Curses by allowing the application programmer to define additional key events at runtime; see define_key(3NCURSES), key_defined(3NCURSES), keybound(3NCURSES), and keyok(3NCURSES). โŒจ๏ธ

ncurses can exploit the capabilities of terminals implementing ISO 6429/ECMA-48 SGR 39 and SGR 49 sequences, which allow an application to reset the terminal to its original foreground and background colors. From a user's perspective, the application is able to draw colored text on a background whose color is set independently, providing better control over color contrasts. See default_colors(3NCURSES). ๐ŸŽจ

An ncurses application can eschew knowledge of SCREEN and WINDOW structure internals, instead using accessor functions such as is_cbreak(3NCURSES) and is_scrollok(3NCURSES).

ncurses enables an application to direct its output to a printer attached to the terminal device; see print(3NCURSES). ๐Ÿ–จ๏ธ

ncurses offers slk_attr(3NCURSES) as a counterpart of attr_get(3NCURSES) for soft-label key lines, and extended_slk_color(3NCURSES) as a form of slk_color(3NCURSES) that can gather color information from them when many colors are supported.

ncurses permits modification of unctrl(3NCURSES)'s behavior; see use_legacy_coding(3NCURSES).

Rudimentary support for multi-threaded applications may be available; see threads(3NCURSES). ๐Ÿงต

Functions that ease the management of multiple screens can be exposed; see sp_funcs(3NCURSES).

To aid applications to debug their memory usage, ncurses optionally offers functions to more aggressively free memory it dynamically allocates itself; see memleaks(3NCURSES).

The library facilitates auditing and troubleshooting of its behavior; see trace(3NCURSES).

Compiling ncurses with the option -DUSE_GETCAP causes it to fall back to reading /etc/termcap if the terminal setup code cannot find a terminfo entry corresponding to TERM.

โš ๏ธ Use of this feature is not recommended, as it essentially includes an entire termcap compiler in the ncurses startup code, at a cost in memory usage and application launch latency. like, it works, but at what cost bestie ๐Ÿ˜ญ

PDCurses and NetBSD curses incorporate some ncurses extensions. Individual man pages indicate where this is the case. ๐Ÿ‘‘

๐Ÿ’… PORTABILITY ๐Ÿ’…

okay so X/Open Curses defines two levels of conformance, and they're called โ€œbaseโ€ and โ€œenhancedโ€. the enhanced one comes with extra features like wide-character support and color support, cute. ncurses is aiming for base-level conformance with X/Open Curses, and it supports all the features of the enhanced level except the untic utility (yeah, that one didn't make the cut bestie).

all the differences between X/Open Curses and ncurses are documented in the โ€œPORTABILITYโ€ sections of the applicable man pages. yes, they each have their own receipts โœจ


๐Ÿซถ Error Checking

in many cases, X/Open Curses is vague about error conditions and straight-up omits some of the SVr4 documentation. iconic of them honestly.

unlike other implementations, ncurses checks pointer parameters, like the ones to WINDOW structures, to make sure they're not null. it does this mainly to guard against programmer error (protecting you from yourself, bestie ๐Ÿ’–). the standard interface doesn't give the library a way to tell an application which of several possible errors happened, so heads up: if an application relies on ncurses to check its function parameters for validity, that limits its portability and robustness. no cap.

๐ŸŽ€ Padding Differences

back in historical curses implementations, the delays embedded in these terminfo capabilities activated corresponding delay bits in the Unix terminal driver:

  • carriage_return (cr)
  • scroll_forward (ind)
  • cursor_left (cub1)
  • form_feed (ff)
  • tab (ht)

ncurses does all padding by sending NUL bytes to the device. this method is slightly more expensive, yeah, but it narrows the interface to the Unix kernel significantly and correspondingly increases the package's portability. glow-up for the whole package fr fr ๐Ÿ’…

๐Ÿฆ‹ Header Files

the header file curses.h itself includes the header files stdio.h and unctrl.h. periodt.

X/Open Curses has more to say:

The inclusion of curses.h may make visible all symbols from the headers stdio.h, term.h, termios.h, and wchar.h.

โ€ฆbut bestie that does not finish the story. here's the full lore:

  • the first curses, in 4BSD, provided a curses.h file.
    • BSD curses code included curses.h and unctrl.h from an internal header file curses.ext, where โ€œextโ€ abbreviated โ€œexternsโ€.
    • the implementations of printw and scanw used undocumented internal functions of the standard I/O library (_doprnt and _doscan), but nothing in curses.h itself relied upon stdio.h.
  • SVr2 curses added newterm, which relies upon stdio.h because its function prototype employs the FILE type.
    • SVr4 curses added putwin and getwin, which also use stdio.h.
    • X/Open Curses specifies all three of these functions.
    • SVr4 curses and X/Open Curses do not require the developer to include stdio.h before curses.h. both document use of curses as requiring only curses.h.
    • as a result, standard curses.h always includes stdio.h. slay.
  • X/Open Curses and SVr4 curses are inconsistent with respect to unctrl.h.
    • as noted in util(3NCURSES), ncurses includes unctrl.h from curses.h (as SVr4 does).
  • X/Open Curses's comments about term.h and termios.h may refer to HP-UX and AIX.
    • HP-UX curses includes term.h from curses.h to declare setupterm in curses.h, but ncurses and Solaris curses do not.
    • AIX curses includes term.h and termios.h. again, ncurses and Solaris curses do not.
  • X/Open Curses says that curses.h may include term.h, but does not require it to do so.
    • some programs use functions declared in both curses.h and term.h, and must include both header files in the same translation unit.
    • the header files supplied by ncurses include the standard library headers required for its declarations, so ncurses's own header files can be included in any order ๐ŸŽ€
    • for portability even to old AIX systems, include curses.h before term.h.
  • X/Open Curses says โ€œmay make visibleโ€ because including a header file does not necessarily make visible all of the symbols in it (consider #ifdef and similar).
    • for instance, ncurses's curses.h may include wchar.h if the proper symbol is defined, and if ncurses is configured for wide-character support.
    • if wchar.h is included, its symbols may be made visible depending on the value of the _XOPEN_SOURCE feature test macro.
  • X/Open Curses mandates an application's inclusion of one standard C library header in a special case: stdarg.h before curses.h to prototype the functions vw_printw and vw_scanw (as well as the obsolete vwprintw and vwscanw). each of these takes a variadic argument list, a va_list parameter, like that of printf(3).
    • SVr3 curses introduced the two obsolete functions, and X/Open Curses the others.
    • in between, SVr4 curses provided for the possibility that an application might include either varargs.h or stdarg.h. these represented contrasting approaches to handling variadic argument lists.
    • the older interface, varargs.h, used a pointer to char for variadic functions' va_list parameter. later, the list acquired its own standard data type, va_list, defined in stdarg.h, empowering the compiler to check the types of a function call's actual parameters against the formal ones declared in its prototype. the compiler said โ€œi got you bestie, type-checkedโ€ ๐Ÿ”ฅ
    • no conforming implementations of X/Open Curses require an application to include stdarg.h before curses.h, because they either have allowed for a special type, or, like ncurses, they include stdarg.h themselves to provide a portable interface. she's self-sufficient ๐Ÿ’…

๐Ÿ‘‘ AUTHORS ๐Ÿ‘‘

the icons behind all of this:

  • Zeyd M. Ben-Halim
  • Eric S. Raymond
  • Thomas E. Dickey

based on pcurses by Pavel Curtis. legends only ๐ŸŒŸ


๐ŸŒˆ SEE ALSO ๐ŸŒˆ


and that's the whole page bestie!! ๐Ÿซถ this was ncurses 6.6, dated 2025-11-11 โ€” go forth and write some absolutely iconic terminal code, you ate ๐Ÿ’–โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from
  • ubuntu stonking: ncurses-doc 6.6+20260608-2 ยท MIT/X11
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms