curs_in_wchstr(3X)
π curs_in_wchstr β bestie edition β¨
okay so this is a page from the curses library manual (section 3X, "library calls"), and it's all about scooping a whole complex character string out of a window. yes, complex characters. no, not like emotionally complicated (tho honestly same). grab a snack π, we're doing this.
πΈ NAME πΈ
in_wchstr, in_wchnstr, win_wchstr, win_wchnstr, mvin_wchstr, mvin_wchnstr, mvwin_wchstr, mvwin_wchnstr β get a curses complex character string from a window π«Ά
β¨ SYNOPSIS β¨
#include <curses.h>
int in_wchstr(cchar_t * wchstr);
int win_wchstr(WINDOW * win, cchar_t * wchstr);
int mvin_wchstr(int y, int x, cchar_t * wchstr);
int mvwin_wchstr(WINDOW * win, int y, int x, cchar_t * wchstr);
int in_wchnstr(cchar_t * wchstr, int n);
int win_wchnstr(WINDOW * win, cchar_t * wchstr, int n);
int mvin_wchnstr(int y, int x, cchar_t * wchstr, int n);
int mvwin_wchnstr(WINDOW * win, int y, int x, cchar_t * wchstr, int n)
not me pointing out that last line has no semicolon in the original β it's giving "the compiler will tell you bestie" π
π DESCRIPTION π
win_wchstr snatches a curses complex character string out of a curses window win, starting right at the cursor and going until the end of the line, then tucks it into wchstr and slaps a wide null curses character on the end to terminate it. iconic behavior, truly.
win_wchnstr does the exact same thing, except it copies at most n curses complex characters from win. and listen β if n is negative, that means no limit at all, so win_wchnstr just vibes like win_wchstr.
oh and ncurses(3X) describes the variants of these functions, if you want the extended lore. iykyk π
π RETURN VALUE π
These functions return OK when it works and ERR when it doesn't. simple as that, periodt.
In ncurses, these functions fail if:
- the curses screen has not been initialized π
- (for functions taking a
WINDOWpointer argument) win is a null pointer - wchstr is a null pointer
Functions prefixed with "mv" first perform cursor movement, and they fail if the position (y, x) is outside the window boundaries. like, stay in your lane pls π§
π¦ NOTES π¦
All of these functions except win_wchnstr may be implemented as macros. surprise mechanics, love that for us π
BIG WARNING ENERGY: reading a line that overflows the array pointed to by wchstr and its variants causes undefined results. not "oopsie" undefined, like genuinely undefined. instead, use the n-infixed functions with a positive n argument no larger than the size of the buffer backing wchstr. protect your buffer bestie, it's the main character π
π PORTABILITY π
X/Open Curses Issue 4 describes these functions. it specifies no error conditions for them. so like, they exist, and that's the whole statement. π
β HISTORY β
X/Open Curses Issue 4 (1995) initially specified these functions.
the System V Interface Definition Version 4 of the same year specified a function named winwchstr (and the usual variants). this was a later addition to SVr4.x β it did not appear in the first SVr4 (1989).
and the tea β: it differed from X/Open's later win_wchstr in that it took an argument of type pointer-to-chtype instead of pointer-to-cchar_t. glow-up era fr fr β¨
π§ SEE ALSO π§
curs_inchstr(3X)describes comparable functions of the ncurses library in its non-wide-character configuration.curses(3X)curs_inwstr(3X)curs_in_wch(3X)
and that's the whole page, bestie!! π«Ά this was ncurses 6.6, dated 2025-10-20, and the page you just read is curs_in_wchstr(3X). go forth and read your complex character strings responsibly β with the n versions, with a buffer that can actually hold them, mwah πππΈ
π¦ 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 2018-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