curs_addwstr(3X)
π curs_addwstr β bestie, it's time to add wide strings to your window π
okay so real talk, this is a page from the Library calls section of the manual, and it's all about yeeting a wide-character string into a curses window and letting the cursor do its little scoot forward. eight functions, one vibe. let's get into it π¦
β¨ NAME β¨
addwstr, waddwstr, mvaddwstr, mvwaddwstr, addnwstr, waddnwstr, mvaddnwstr, mvwaddnwstr β add a wide-character string to a curses window and advance the cursor. that's the whole job. that's the assignment. π
πΈ SYNOPSIS πΈ
#include <curses.h>
int addwstr(const wchar_t * wstr);
int waddwstr(WINDOW * win, const wchar_t * wstr);
int mvaddwstr(int y, int x, const wchar_t * wstr);
int mvwaddwstr(WINDOW * win, int y, int x,
const wchar_t * wstr);
int addnwstr(const wchar_t * wstr, int n);
int waddnwstr(WINDOW * win, const wchar_t * wstr, int n);
int mvaddnwstr(int y, int x, const wchar_t * wstr, int n);
int mvwaddnwstr(WINDOW * win, int y, int x,
const wchar_t * wstr, int n);
like, look at that naming convention. w = window, mv = move-then-write, n = "only this many, bestie". iykyk π
π DESCRIPTION π
so waddwstr writes the characters of the (wide-null-terminated) wide-character string wstr to the window win. and the way it does it? it's giving method acting β it acts as if it were constructing a cchar_t for each wchar_t in wstr, then calling wadd_wch(3X) with that resulting cchar_t. cute, right?
curses processes spacing and non-spacing characters in wstr one at a time. no skipping, no grouping, one at a time, periodt.
waddnwstr is similar, but it writes at most n wide characters. and if n is -1? then waddnwstr writes the entire wide string. all of it. the whole thing. no crumbs left. π
and ncurses(3X) is the one that describes the variants of these functions β so if you're curious about the whole fam, that's where you go.
π₯ RETURN VALUE π₯
these functions return OK on success and ERR on failure. simple. clean. iconic.
in ncurses, these functions fail if:
- the curses screen has not been initialized,
wstris a null pointer,- (for functions taking a
WINDOWpointer argument)winis a null pointer, or - an internal
wadd_wch(3X)call returnsERR.
and the ones prefixed with βmvβ? they first perform cursor movement, and they fail if the position (y, x) is outside the window boundaries. so like, don't try to park your cursor outside the window. it will not go well. π
π NOTES π
all of these functions except waddnwstr may be implemented as macros. not me warning you about macro weirdness, but here we are. π
π PORTABILITY π
X/Open Curses Issue 4 describes these functions.
SVr4 describes a successful return value only as βan integer value other than ERRβ. so like, vague. mysterious. keeping secrets. π
β 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 waddwstr and waddnwstr (and the usual variants). these were later additions to SVr4.x, not appearing in the first SVr4 (1989). so they're the younger siblings, basically. π§
π«Ά SEE ALSO π«Ά
curs_addstr(3X) describes comparable functions of the ncurses library in its non-wide-character configuration.
curses(3X), curs_add_wch(3X), curs_add_wchstr(3X)
and that's the whole page, bestie!! this one's ncurses 6.6, dated 2025-03-15, and it's literally the moment where your wide strings meet your windows. go forth and addwstr. slay πβ¨
π¦ 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