addwstr(3NCURSES)

✨ addwstr β€” the ncurses wide-string glow-up ✨

okay so bestie, welcome to addwstr(3NCURSES), a genuine Library calls icon from the ncurses fam πŸ’– she's the one who takes a whole wide-character string and just... drops it into your window, cursor sliding forward like she owns the place. and honestly? she does. πŸ’…


🌸 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 whole vibe. ✨


πŸŽ€ 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);

πŸ¦‹ DESCRIPTION πŸ¦‹

so waddwstr writes the characters of the (wide-null-terminated) wide-character string wstr into the window win. the way it does this is giving build a cchar_t for each wchar_t in wstr, and then calling wadd_wch(3NCURSES) with the resulting cchar_t. iconic pipeline behavior, no cap. πŸ”₯

curses handles the spacing and non-spacing characters in wstr one at a time β€” she's methodical like that. πŸ’…

waddnwstr is the same situation, except she writes at most n wide characters. and if n is -1? she writes the entire wide string, go off queen πŸ‘‘

also, ncurses(3NCURSES) is the one who describes the variants of these functions β€” she's the group chat admin for all of this, iykyk.


πŸ’– RETURN VALUE πŸ’–

these functions return OK when it works and ERR when it doesn't. simple. binary. main character energy. ✨

in ncurses, these functions fail if:

  • the curses screen has not been initialized 😭
  • wstr is a null pointer πŸ’€
  • (for the functions taking a WINDOW pointer argument) win is a null pointer 🫠
  • an internal wadd_wch(3NCURSES) call returns ERR πŸ™ˆ

and the functions prefixed with β€œmv”? they do cursor movement first, and they fail if the position (y, x) is outside the window boundaries. boundary check first, always. periodt. πŸ‘‘


🌈 NOTES 🌈

all of these functions except waddnwstr may be implemented as macros. so like, don't do weird stuff with them. 🧚


🌟 PORTABILITY 🌟

X/Open Curses Issue 4 describes these functions. πŸ“š

SVr4 describes a successful return value only as β€œan integer value other than ERR” β€” which is so vague of them honestly, we love an unbothered king. 😌


πŸ‘‘ HISTORY πŸ‘‘

X/Open Curses Issue 4 (1995) initially specified these functions. the System V Interface Definition Version 4 of that same year specified functions named waddwstr and waddnwstr (plus the usual variants, of course). and here's the tea: these were later additions to SVr4.x β€” they were not in the first SVr4 (1989). glow-up era, fr fr. πŸ’…βœ¨


πŸ“ SEE ALSO πŸ“

addstr(3NCURSES) describes comparable functions of the ncurses library in its non-wide-character configuration β€” like, the regular-string sister. 🫢

also go say hi to: ncurses(3NCURSES), add_wch(3NCURSES), add_wchstr(3NCURSES) πŸ’œ


and that's the page bestie!! 🌸 this was ncurses 6.6, dated 2025-03-15, from the addwstr(3NCURSES) manual β€” go forth and write your wide strings, you absolute icon πŸŽ€βœ¨πŸ’–

πŸ“¦ where this page comes from