termattrs(3NCURSES)
π termattrs β bestie edition π
okay so this is a page from the ncurses manual (that's the 3NCURSES section, library calls, for the record), and it's literally all about asking your terminal "hey girl, what are you, what can you do, and what buttons do you use to erase things?" π
β¨ NAME β¨
baudrate, erasechar, erasewchar, has_ic, has_il, killchar, killwchar, longname, term_attrs, termattrs, termname β get and set terminal attributes with curses π¦
β¨ SYNOPSIS β¨
#include <curses.h>
int baudrate(void);
char erasechar(void);
int erasewchar(wchar_t * wc);
bool has_ic(void);
bool has_il(void);
char killchar(void);
int killwchar(wchar_t * wc);
char * longname(void);
attr_t term_attrs(void);
chtype termattrs(void);
char * termname(void);
β¨ DESCRIPTION β¨
πΈ baudrate
baudrate hands you the line speed of the terminal. it's an integer, measured in bits per second β like, for example 9600. so retro, so cute. π
πΈ erasechar, erasewchar
erasechar returns the terminal's erase character. that's the key you smash when you want to un-type something bestie.
erasewchar stores the erase character in the location that wc points to. and if no erase character has been defined, it just fails β and the location wc points to is not changed. no notes, no update, nothing. π
πΈ has_ic, has_il
has_ic returns TRUE if the terminal has insert- and delete-character capabilities. icon behavior honestly.
has_il returns TRUE if the terminal has insert- and delete-line capabilities, or can simulate them using scrolling regions. the manpage even says it might be used to figure out whether it would be appropriate to use scrollok(3NCURSES) to turn on scrolling. slay. π«Ά
πΈ killchar, killwchar
killchar returns the terminal's line kill character. yes, the one that nukes the whole line, main character energy.
killwchar stores that line-kill character in the location referenced by wc. and same deal as before: if no line-kill character has been defined, it fails, and the location wc points to is left completely untouched. π
πΈ longname
longname returns a pointer to static storage holding a verbose description of the terminal that curses is managing. the max length of that verbose description is 128 characters.
lowkey important: that storage only gets populated after initscr(3NCURSES) or newterm(3NCURSES) is called. and β warning β it gets overwritten by each call to newterm, and it is not restored by set_term(3NSES). so if you're using longname with multiple terminals, save its contents between calls to initscr or newterm. do not skip that step, i'm begging. π
πΈ termattrs, term_attrs
so here's the vibe: if a given terminal doesn't support a video attribute that an application program is trying to use, curses may swap in a different video attribute instead. sneaky!
termattrs and term_attrs return a logical βorβ of all video attributes supported by the terminal β using A_ and WA_ constants respectively. this info hits when a curses program needs complete control over the appearance of the screen. it's giving total aesthetic authority. π
πΈ termname
termname returns the terminal name used by setupterm(3NCURSES). that's it, that's the whole thing, and she ate. β¨
β¨ RETURN VALUE β¨
longname and termname return NULL on error.
functions that return an integer return ERR upon failure and OK upon success. classic.
β¨ NOTES β¨
erasewchar, killwchar, and term_attrs are part of ncurses's wide-character API, and they are not available in its non-wide-character configuration. so if you're on the narrow build, don't come for them, they're not there. π
termattrs may be implemented as a macro. no cap.
β¨ PORTABILITY β¨
X/Open Curses Issue 4 describes these functions. β¨
SVr4 describes a successful return value only as βan integer value other than ERRβ. vague of them fr fr.
most versions of curses truncate the string returned by termname to 14 characters. so short. so demure. π
β¨ HISTORY β¨
4BSD(1980) introducedlongname.SVr2(1984) addedbaudrate,erasechar,killchar,has_ic, andhas_il.SVr3(1987) suppliedtermname. later that year,SVr3.1broughttermattrs.- X/Open Curses Issue 4 (1995) specified
erasewchar,killwchar, andterm_attrs.
a whole timeline, we love a glow-up. π
β¨ SEE ALSO β¨
ncurses(3NCURSES)initscr(3NCURSES)outopts(3NCURSES)
okay that's the whole page!! this one came from the ncurses crew β ncurses 6.6, dated 2025-08-23 β and it's filed under termattrs(3NCURSES) in the library calls section. mwah, bye bestie ππ¦πβ¨
π¦ 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 2018-2024,2025 Thomas E. Dickey
- Copyright 1998-2010,2015 Free Software Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms