add_wchstr(3NCURSES)

✨ add_wchstr β€” the complex-character string glow-up ✨

okay bestie, so this is a page from the 3NCURSES corner of the library calls world, and it's literally all about yeeting a whole string of complex characters onto a window. no cap. let's get into it πŸ’–


πŸŽ€ 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. that's the whole vibe. πŸ‘‘


🌸 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. periodt. a null complex character is what terminates the string β€” that's your little stop sign πŸ›‘

and here's the tea: if a complex character does not completely fit at the end of the line, curses fills its remaining cells with the window's background character. see bkgrnd(3NCURSES) for that whole situation. 🫢

wadd_wchnstr does the exact same thing, except it copies at most n characters β€” or as many as possible if n is -1. and if you're like "wait, what about all the variants??" β€” ncurses(3NCURSES) describes the variants of these functions. iykyk ✨

πŸ¦‹ why these are lowkey the fast ones πŸ¦‹

the way that these functions do not call wadd_wch(3NCURSES) internally?? that's why they're faster than waddwstr(3NCURSES) and waddnwstr(3NCURSES). speed. iconic. πŸ’¨

but bestie, on the other hand, they:

  • do not treat the backspace, carriage return, or line feed characters specially 😳
  • do not represent unprintable characters with wunctrl(3NCURSES) πŸ™ˆ
  • do not update the cursor position to follow the last character written πŸ‘€
  • truncate the string at the window's right margin, rather than wrapping it to the next line and potentially scrolling πŸ›‘

so yeah. fast but feral. main character energy with zero manners. πŸ’€


🌈 RETURN VALUE 🌈

these functions return OK on success and ERR on failure. that's it, that's the scale. ✨

in ncurses, these functions fail if:

  • the curses screen has not been initialized 🌱
  • wchstr is a null pointer 🚫
  • (for functions taking a WINDOW pointer argument) win is 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 don't be out here trying to move to coordinates that don't exist, babe 😭


🧚 NOTES 🧚

all of these functions except wadd_wchnstr may be implemented as macros. yes, macros. keep that in mind, it's giving sneaky πŸ‘‘


πŸ“ PORTABILITY πŸ“

X/Open Curses Issue 4 describes these functions. it specifies no error conditions for them. so like... the spec said nothing, and ncurses said "well, I have opinions." πŸ’…


πŸ’œ HISTORY πŸ’œ

X/Open Curses Issue 4 (1995) initially specified these functions. then the System V Interface Definition Version 4 of the same year specified functions named waddwchstr and waddwchnstr (and the usual variants). those were later additions to SVr4.x β€” not appearing in the first SVr4 (1989), which is so real of them.

and 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 drama. the lore. πŸ«–


🌟 SEE ALSO 🌟

  • addchstr(3NCURSES) β€” describes comparable functions of the ncurses library in its non-wide-character configuration.
  • ncurses(3NCURSES)
  • addwstr(3NCURSES)
  • add_wch(3NCURSES)

and that's the whole page, bestie!! go forth and add those complex character strings πŸ’– this lil tour was brought to you by ncurses 6.6, dated 2025-10-20, for add_wchstr(3NCURSES) β€” slay, stay hydrated, and remember: no wrapping, only truncating πŸŒΈβœ¨πŸŽ€

πŸ“¦ where this page comes from