curs_add_wchstr(3X)
β¨ curs_add_wchstr β Library calls β¨
okay bestie, so this is the ncurses page all about yeeting a whole string of complex characters into a window. yes, the wide/wide-ish character ones. no cap, it's a whole family of eight functions and we're doing ALL of them π
πΈ NAME πΈ
add_wchstr, wadd_wchstr, mvadd_wchstr, mvwadd_wchstr, add_wchnstr, wadd_wchnstr, mvadd_wchnstr, mvwadd_wchnstr β add a curses complex character string to a window
it's giving "eight names, one destiny" fr fr π«Ά
β¨ SYNOPSIS β¨
#include <curses.h>
int add_wchstr(const cchar_t * wchstr);
int wadd_wchstr(WINDOW * win, const cchar_t * wchstr);
int mvadd_wchstr(int y, int x, const cchar_t * wchstr);
int mvwadd_wchstr(WINDOW * win, int y, int x, const cchar_t * wchstr);
int add_wchnstr(const cchar_t * wchstr, int n);
int wadd_wchnstr(WINDOW * win, const cchar_t * wchstr, int n);
int mvadd_wchnstr(int y, int x, const cchar_t * wchstr, int n);
int mvwadd_wchnstr(WINDOW * win, int y, int x,
const cchar_t * wchstr, int n);
π DESCRIPTION π
so wadd_wchstr copies the string of complex characters wchstr to the window win. a null complex character is what ends the string β that's the terminator, periodt. and if a complex character doesn't completely fit at the end of the line, curses fills its leftover cells with the window's background character; go peek at bkgrnd(3X) for the lore on that.
wadd_wchnstr does the exact same thing, except it copies at most n characters β or as many as it possibly can if n is -1. and ncurses(3X) is where you go to read up on all the variants of these functions.
now here's the tea, bestie π: because these functions do not call wadd_wch(3X) internally, they are faster than waddwstr(3X) and waddnwstr(3X). iconic speedrun behaviour. but on the other hand β and this is the trade-off, so listen up β they
- do not treat the backspace, carriage return, or line feed characters specially;
- do not represent unprintable characters with
wunctrl(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.
translation: fast and feral. no fancy character handling, no cursor babysitting, no wrap-around. it just goes and then it stops. π
π RETURN VALUE π
these functions return OK on success and ERR on failure. simple as.
in ncurses, these functions fail if
- the curses screen has not been initialized,
wchstris a null pointer, or- (for functions taking a
WINDOWpointer argument)winis a null pointer.
and the ones prefixed with βmvβ first perform cursor movement, and they fail if the position (y, x) is outside the window boundaries. so yeah, don't be out here moving the cursor to the void π
π NOTES π
all of these functions except wadd_wchnstr may be implemented as macros. so like, don't get weird with them, okay? iykyk.
π¦ PORTABILITY π¦
X/Open Curses Issue 4 describes these functions. and it specifies no error conditions for them. wild, but okay π
β HISTORY β
X/Open Curses Issue 4 (1995) initially specified these functions. the System V Interface Definition Version 4 of the same year specified functions named waddwchstr and waddwchnstr (and the usual variants). these were later additions to SVr4.x, not appearing in the first SVr4 (1989) β so like, they showed up fashionably late to the party. π§
and here's the plot twist: they differed from X/Open's later wadd_wchstr and wadd_wchnstr in that they each took an argument of type wchar_t instead of cchar_t. the way that one little type change is the whole differenceβ¦ π
π SEE ALSO π
curs_addchstr(3X) describes comparable functions of the ncurses library in its non-wide-character configuration.
curses(3X), curs_addwstr(3X), curs_add_wch(3X)
and that's the whole page, bestie π go forth and write your complex character strings. this was ncurses 6.6, dated 2025-10-20 β mwah, slay, you're welcome πβ¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright 2019-2024,2025 Thomas E. Dickey
- Copyright 2002-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