curs_addchstr(3X)
π curs_addchstr β bestie's guide to yeeting a whole character string into a window π
okay so this is a Library calls page (manual section 3X, iykyk) and it's all about one iconic little family of functions: addchstr, waddchstr, mvaddchstr, mvwaddchstr, addchnstr, waddchnstr, mvaddchnstr, mvwaddchnstr β they add a curses character string to a window. that's the whole vibe. π
β¨ NAME β¨
addchstr, waddchstr, mvaddchstr, mvwaddchstr, addchnstr, waddchnstr, mvaddchnstr, mvwaddchnstr β add a curses character string to a window π«Ά
β¨ SYNOPSIS β¨
#include <curses.h>
int addchstr(const chtype * chstr);
int waddchstr(WINDOW * win, const chtype * chstr);
int mvaddchstr(int y, int x, const chtype * chstr);
int mvwaddchstr(WINDOW * win, int y, int x,
const chtype * chstr);
int addchnstr(const chtype * chstr, int n);
int waddchnstr(WINDOW * win, const chtype * chstr, int n);
int mvaddchnstr(int y, int x, const chtype * chstr, int n);
int mvwaddchnstr(WINDOW * win, int y, int x,
const chtype * chstr, int n);
β¨ DESCRIPTION β¨
so waddchstr copies the string of curses characters chstr to the window win. a null curses character terminates the string, like the end of a sentence but for curses. π
waddchnstr does the exact same thing, but it copies at most n characters β or as many as possible if n is -1. queen behaviour honestly.
ncurses(3X) describes the variants of these functions, if you wanna go deeper down the rabbit hole. π
the way that these functions do not call waddch(3X) internally means they're faster than waddstr(3X) and waddnstr(3X). speed demon energy. π₯
on the other hand β and bestie listen, this is the trade-off β they:
- do not treat the backspace, carriage return, or line feed characters specially;
- do not represent unprintable characters with
unctrl(3X); - do not update the cursor position to follow the last character written; and
- truncate the string at the window's right margin, rather than wrapping it to the next line and potentially scrolling.
so like, fast but feral. they're not gonna hold your hand through any of the fancy formatting. π
β¨ RETURN VALUE β¨
these functions return OK on success and ERR on failure. slay or flop, no in-between. π
in ncurses, these functions fail if
- the curses screen has not been initialized,
chstris a null pointer, or- (for functions taking a
WINDOWpointer argument)winis a null pointer.
functions prefixed with mv first perform cursor movement, and they fail if the position (y, x) is outside the window boundaries. stay in your lane or get an ERR, fr fr. π§
β¨ NOTES β¨
all of these functions except waddchnstr may be implemented as macros. yes, that means waddchnstr is the odd one out. main character behaviour, honestly. π
β¨ PORTABILITY β¨
X/Open Curses Issue 4 describes these functions. it specifies no error conditions for them. π
SVr4 describes a successful return value only as "an integer value other than ERR". so likeβ¦ vague. mysterious. iconic. β¨
β¨ HISTORY β¨
SVr3.1 (1987) introduced these functions. vintage but still eating. π
β¨ SEE ALSO β¨
curs_add_wchstr(3X)describes comparable functions of the ncurses library in its wide-character configuration (ncursesw).curses(3X)curs_addch(3X)curs_addstr(3X)
and that's the whole page, bestie!! π¦ this little gem came out of ncurses 6.6, dated 2025-08-16 β go forth and copy your character strings with confidence, no cap. πβ¨π
π¦ where this page comes from
- alpine 3.24: ncurses-doc 6.6_p20260516-r0 Β· X11
- arch rolling: ncurses 6.6-2 Β· MIT-open-group
- fedora 44: ncurses-devel 6.6-1.fc44 Β· MIT-open-group
- fedora 44: ncurses-devel 6.6-1.fc44 Β· MIT-open-group
- Copyright 2019-2024,2025 Thomas E. Dickey
- Copyright 1998-2012,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