terminfo_variables(3NCURSES)
π terminfo_variables β the terminfo global variables, explained by your fave β¨
okay bestie, this one lives in the ncurses library calls section, and it's literally a tour of the global variables the lower-level terminfo interface hands you π«Ά
πΈ NAME πΈ
SP, acs_map, boolcodes, boolfnames, boolnames, cur_term, numcodes, numfnames, numnames, strcodes, strfnames, strnames, ttytype β these are the terminfo global variables, and yes that's a lot of them, stay with me π
β¨ SYNOPSIS β¨
#include <curses.h>
#include <term.h>
chtype acs_map[];
SCREEN * SP;
TERMINAL * cur_term;
char ttytype[];
NCURSES_CONST char * const boolcodes[];
NCURSES_CONST char * const boolfnames[];
NCURSES_CONST char * const boolnames[];
NCURSES_CONST char * const numcodes[];
NCURSES_CONST char * const numfnames[];
NCURSES_CONST char * const numnames[];
NCURSES_CONST char * const strcodes[];
NCURSES_CONST char * const strfnames[];
NCURSES_CONST char * const strnames[];
π DESCRIPTION π
So this page is basically the sparknotes version of the variables that the curses library's lower-level terminfo interface gives you. If you want the full deep dive, the real tea is in the terminfo(3NCURSES) manual page β go read that one too, bestie, no cap π
Depending on how ncurses was configured at build time, these might be actual variables, or they might be macros (peep threads(3NCURSES)) that give you read-only access to curses's internal state. Either way, the vibe is the same: applications should treat them as read-only, because messing with them will confuse the library and that's giving chaos energy π
π¦ Alternate Character Set Mapping π¦
Once you've initialized the curses or terminfo interfaces, the acs_map array holds the info used to translate cells that carry the A_ALTCHARSET video attribute into actual line-drawing characters. Iconic, honestly β¨
The encoding of the info in this array has changed periodically over time. Application developers only need to know that it's what backs the βACS_β constants in curses.h. That's the whole assignment π
The comparable data for the wide-character library is not exposed as symbols in the API. It's just not out here like that, sorry π«
π Current Terminal Data π
After initializing the curses or terminfo interfaces, cur_term contains data describing the current terminal. It also gets updated as a side effect of set_term(3NSES) and delscreen(3NCURSES). So like, it's lowkey moving on its own, keep an eye on it π
You can save a value of cur_term for later use as a parameter to set_term(3NSES) if you want to switch between screens. Alternatively, you can save the return value from newterm(3NCURSES) or setupterm(3NCURSES) and reuse that in set_term(3NSES). Multiple routes, same destination, choose your fighter π
πΈ terminfo Lookup Tables πΈ
The tic(1) and infocmp(1) programs use lookup tables for the long and short names of terminfo capabilities, plus the corresponding names for termcap capabilities. These tables are available to other applications too β but heads up, the hash tables used by the terminfo and termcap functions are not available. Those stay private, periodt π
terminfo stores capability names in arrays with an βfβ (eff) in their names: boolfnames, numfnames, and strfnames. It stores the briefer capability codes in arrays without the βfβ: boolnames, numnames, and strnames. The corresponding termcap capability codes live in boolcodes, numcodes, and strcodes. terminfo(5) catalogs all of these β go look, it's a whole index π
β Terminal Type β
A terminal description begins with one or more terminal names separated by β|β (vertical bars). When the curses or terminfo interfaces initialize, setupterm(3NCURSES) copies the terminal name into the ttytype array. Cute, short, does its job π
π terminfo Names π
On top of the variables, term.h also defines a symbol for every terminfo capability name. These are defined in terms of the symbol CUR, which is defined as:
#define CUR ((TERMTYPE *)(cur_term))->
These symbols give you a faster way to access terminfo capabilities than using, say, tigetstr(3NCURSES). Speed, slay π₯
The definition of CUR is implementation-dependent, but every terminfo library defines these names to point into the in-memory description of the current terminal. For example, in ncurses, the expressions tigetstr("key_dc") and βCUR Strings[59]β are equivalent. Same thing, two fits π
π§ terminfo and curses π§
setupterm(3NCURSES) initializes the lower-level terminfo interface. The higher-level curses interface uses the terminfo interface internally, and the symbol SP bridges the curses SCREEN type with the terminfo TERMINAL type. It's giving matchmaker, it's giving glue π
π PORTABILITY π
X/Open Curses does not describe any of these symbols except for cur_term. And honestly? The inclusion of cur_term appears to be an oversight, since X/Open omits other comparable low-level information. Awkward π
Other implementations may have comparable variables. Some implementations provide the variables in their libraries but omit them from the header files β so like, they exist but they're not in the group chat. Rude.
All implementations that provide terminfo interfaces add definitions as described in the βterminfo Namesβ section above. Most, but not all, base the definition on the cur_term variable. Not all of them!! Pay attention!! π
π SEE ALSO π
ncurses(3NCURSES)terminfo(3NCURSES)threads(3NCURSES)terminfo(5)
okay and that's the whole page bestie π«Ά this was ncurses 6.6, dated 2025-11-11, and it's the terminfo_variables(3NCURSES) page from the Library calls section β mwah, go read terminfo(3NCURSES) next, iykyk πβ¨π
π¦ where this page comes from
- ubuntu resolute: ncurses-doc 6.6+20251231-1 Β· MIT/X11
- ubuntu stonking: ncurses-doc 6.6+20260608-2 Β· MIT/X11
- Copyright 2019-2024,2025 Thomas E. Dickey
- Copyright 2010-2015,2017 Free Software Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms