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