term_variables(3X)

πŸ’– term_variables(3X) β€” bestie, it's the terminfo globals page πŸ’–

okay so this is term_variables from the ncurses library calls corner of the manual, and it's basically the group chat of global variables that the curses library's lower-level terminfo interface hands you. 🫢


✨ NAME ✨

SP, acs_map, boolcodes, boolfnames, boolnames, cur_term, numcodes, numfnames, numnames, strcodes, strfnames, strnames, ttytype β€” the terminfo global variables, all of them, no cap πŸ’…


🌸 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[];
NCURSIVE_CONST char * const strfnames[];
NCURSES_CONST char * const strnames[];

wait no hold on β€” that one line is strfnames, not whatever my keyboard just did. let me be so serious for one sec:

NCURSES_CONST char * const strfnames[];

there. ✨ slay.


πŸ‘‘ DESCRIPTION πŸ‘‘

This page is like... the little summary card of variables that the curses library's lower-level terminfo interface gives you. If you want the full lore, go read curs_terminfo(3X), fr fr.

Depending on how ncurses was configured at build time, these might be actual variables, or they might be macros (peep curs_threads(3X)) that give you read-only access to curses's state. Either way? Bestie. Treat them as read-only. Do not be out here writing to them, that's how you confuse the library and nobody wants that 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 carrying the A_ALTCHARSET video attribute into line-drawing characters. it's giving ✨art✨

The encoding of the info in this array has changed periodically, which is so real of it. App developers only need to know one thing: it's what powers the ACS_ constants in curses.h.

The comparable data for the wide-character library is not exposed as symbols in the API. nope, not invited to the party. πŸ™ˆ

πŸ¦‹ Current Terminal Data πŸ¦‹

After you initialize the curses or terminfo interfaces, cur_term holds data describing the current terminal. It also gets updated as a side effect of set_term(3X) and delscreen(3X) β€” like, it's keeping itself current, iconic behavior.

You can save a value of cur_term for later use as a parameter to set_term(3X), which is how you switch between screens. Or alternatively β€” and this is the lowkey better move β€” save the return value from newterm(3X) or setupterm(3X) and reuse that in set_term(3X). 🫢

🌈 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 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.

Here's the naming scheme, and once you see it you can't unsee it:

  • 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, iykyk. πŸ“š

πŸ’œ Terminal Type πŸ’œ

A terminal description begins with one or more terminal names separated by | (vertical bars). When the curses or terminfo interfaces initialize, setupterm(3X) copies the terminal name into the array ttytype. cute little name badge situation. πŸŽ€

⭐ terminfo Names ⭐

Besides the variables, term.h also defines a symbol for each terminfo capability name. And these are defined in terms of the symbol CUR, which is defined as:

#define CUR ((TERMTYPE *)(cur_term))->

These symbols are a faster way to access terminfo capabilities than using, for example, tigetstr(3X). speed, we love her. πŸ”₯

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. yes literally the same thing. πŸ’…

🧚 terminfo and curses 🧚

setupterm(3X) 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 the friend that knows both friend groups. πŸŒ‰


πŸ’… PORTABILITY πŸ’…

X/Open Curses does not describe any of these symbols except for cur_term. (and honestly, the inclusion of cur_term looks like an oversight, since other comparable low-level info is omitted by X/Open. not me calling out the standard but like... πŸ‘€)

Other implementations may have comparable variables. Some implementations provide the variables in their libraries but omit them from the header files. messy of them ngl.

All implementations that provide terminfo interfaces add definitions as described up in the β€œterminfo Names” section above. Most β€” but not all β€” base the definition upon the cur_term variable.


πŸ“ SEE ALSO πŸ“

  • curses(3X)
  • curs_terminfo(3X)
  • curs_threads(3X)
  • terminfo(5)

and that's the whole page bestie!! πŸ’– this was brought to you by ncurses 6.6, dated 2025-11-11, which is the version and date of the manual itself β€” remember them for the quiz. mwah. 🫢✨🌸

πŸ“¦ where this page comes from