curs_termattrs(3X)

πŸ’– curs_termattrs β€” terminal attributes, but make it a group chat πŸ’–

okay bestie, welcome to curs_termattrs from the ncurses library calls section ✨ this is the page where you find out literally everything about what your terminal can and can't do. baud rate, erase char, kill char, whether it can insert lines, what its long fancy name is β€” all of it. let's go πŸ¦‹


🌸 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 β€” how fast is she going 🏎️

baudrate returns the line speed of the terminal, an integer value measured in bits per second β€” like, say, 9600. no cap, that's the actual unit. πŸ’«

erasechar, erasewchar β€” the delete key energy

erasechar returns the terminal's erase character.

erasewchar stores the erase character in the location referenced by wc. and here's the thing bestie: if no erase character has been defined, it fails, and the location referenced by wc is not changed. so don't go assuming something got written there πŸ™ˆ

has_ic, has_il β€” capability check, main character edition

has_ic returns TRUE if the terminal has insert- and delete-character capabilities.

has_il returns TRUE if the terminal has insert- and delete-line capabilities, or can simulate them using scrolling regions. lowkey you might use this to figure out whether it would be appropriate to use scrollok(3X) to turn on scrolling. πŸ‘‘

killchar, killwchar β€” the line-kill bestie

killchar returns the terminal's line kill character.

killwchar stores the 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 referenced by wc is not changed. 🫢

longname β€” the full government name, periodt

longname returns a pointer to static storage containing a verbose description of the terminal being managed by curses. the maximum length of a verbose description is 128 characters. πŸ“

now listen closely because this part matters: the storage is populated only after initscr(3X) or newterm(3X) is called. and it gets overwritten by each call to newterm and is not restored by set_term(3X). so if you're gonna use longname with multiple terminals, you better save its contents between calls to initscr or newterm. it's giving "shared locker, one key" 😭

termattrs, term_attrs β€” the vibe check of video attributes

so here's the situation: if a given terminal doesn't support a video attribute that an application program is trying to use, curses may substitute a different video attribute for it. termattrs and term_attrs return a logical "or" of all video attributes supported by the terminal, using A_ and WA_ constants respectively. πŸ’–

this info is useful when a curses program needs complete control over the appearance of the screen. total main character energy over your own pixels. 🌈

termname β€” who even are you

termname returns the terminal name used by setupterm(3X). iconic. ⭐


🫢 RETURN VALUE 🫢

longname and termname return NULL on error.

Functions that return an integer return ERR upon failure and OK upon success. πŸ’€ (the ERR, not the OK, obviously)


πŸ’… NOTES πŸ’…

erasewchar, killwchar, and term_attrs are part of ncurses's wide-character API, and are not available in its non-wide-character configuration. so if you're running the narrow build, those three are simply not invited to the party πŸŽ€

termattrs may be implemented as a macro. iykyk. ⚠️


🌍 PORTABILITY 🌍

X/Open Curses Issue 4 describes these functions.

SVr4 describes a successful return value only as "an integer value other than ERR". like, okay, be vague about it then πŸ’€

Most versions of curses truncate the string returned by termname to 14 characters. 14!! not 15, bestie. fourteen. πŸ™ˆ


πŸ“œ HISTORY πŸ“œ

  • 4BSD (1980) introduced longname.
  • SVr2 (1984) added baudrate, erasechar, killchar, has_ic, and has_il.
  • SVr3 (1987) supplied termname. later that year, SVr3.1 brought termattrs.
  • X/Open Curses Issue 4 (1995) specified erasewchar, killwchar, and term_attrs.

the way this page has been cooking since 1980 and is still relevant… ate and left no crumbs πŸ‘‘


πŸ‘€ SEE ALSO πŸ‘€

  • curses(3X)
  • curs_initscr(3X)
  • curs_outopts(3X)

and that's the whole page, bestie!! πŸ¦‹ this was curs_termattrs(3X) from ncurses 6.6, dated 2025-08-23. go forth and interrogate your terminal about its baud rate, its kill char, and its full name. she'll tell you everything. mwah πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from