curs_inwstr(3X)
π curs_inwstr β Library calls π
okay bestie, so this is the curs_inwstr(3X) page from the ncurses library, and it's literally all about getting a wide-character string out of a curses window. yes, we're pulling whole wide strings out of a window, cursor-first, no cap. let's get into it π«Ά
β¨ NAME β¨
inwstr, winwstr, mvinwstr, mvwinwstr, innwstr, winnwstr, mvinnwstr, mvwinnwstr β grab a wide-character string from a curses window π
πΈ SYNOPSIS πΈ
#include <curses.h>
int inwstr(wchar_t * wstr);
int winwstr(WINDOW * win, wchar_t * wstr);
int mvinwstr(int y, int x, wchar_t * wstr);
int mvwinwstr(WINDOW * win, int y, int x, wchar_t * wstr);
int innwstr(wchar_t * wstr, int n);
int winnwstr(WINDOW * win, wchar_t * wstr, int n);
int mvinnwstr(int y, int x, wchar_t * wstr, int n);
int mvwinnwstr(WINDOW * win, int y, int x, wchar_t * wstr, int n);
π¦ DESCRIPTION π¦
so winwstr is the main character here: it extracts a wide-character string from a curses window β that's win β and it starts right at the cursor and keeps going until it hits the end of the line. then it drops all that into wstr, and it terminates it with a wide null character. and here's the tea: it omits any attributes and color pair identifier that curses has associated with each character. so you get the text, not the whole glow-up. β¨
winnwstr does the exact same thing, but it copies at most n wide characters from win. and okay, a negative n implies no limit β so winnwstr just acts like winwstr at that point. iconic.
ncurses(3X) describes the variants of these functions, iykyk.
π₯ RETURN VALUE π₯
when it works, these functions return the count of wide characters copied from win to wstr β and no, that count does not include the wide null terminator. if something goes wrong? you get ERR. periodt.
innwstr, winnwstr, mvinnwstr, and mvwinnwstr return ERR if n is insufficiently large to store a complete wide character string. (and like, remember β a curses complex character can hold multiple wide characters, and some of them may be non-spacing. so it's giving more than you think.)
in ncurses, these functions return ERR if:
- the curses screen has not been initialized π
- (for functions taking a
WINDOWpointer argument) win is a null pointer - wstr is a null pointer
and the functions prefixed with βmvβ? they do the cursor movement first, and they fail if the position (y, x) is outside the window boundaries.
π NOTES π
all of these functions except winnwstr may be implemented as macros. so don't be out here doing macro shenanigans and acting surprised.
also, huge heads up bestie: reading a line that overflows the array pointed to by wstr and its variants causes undefined results. π instead, use the n-infixed functions with a positive n that's no larger than the size of the buffer backing wstr. protect your buffer, protect your peace. π«Ά
π EXTENSIONS π
innwstr, winnwstr, mvinnwstr, and mvwinnwstr accepting negative n values? yeah that's an ncurses extension. slay, but it's an extension.
π PORTABILITY π
if you're using ncurses extensions, you should condition your use on the visibility of the NCURSES_VERSION preprocessor macro. that's the vibe check you have to pass first.
X/Open Curses Issue 4 describes these functions. it specifies no error conditions for them. okay.
notwithstanding the foregoing, X/Open Curses Issues 4 and 7 both state that innwstr, winnwstr, mvinnwstr, and mvwinnwstr:
βfail ... [i]f the array is not large enough to contain any complete charactersβ
and strictly interpreted? that means a caller of these functions cannot use their return values to detect truncation of a wide-character string copied from more than one character cell in win. π ncurses reports any truncation with ERR, for the record.
also X/Open Curses specifies inwstr, winwstr, mvinwstr, and mvwinwstr as returning OK rather than a (wide) character count β unlike their non-wide counterparts instr, winstr, mvinstr, and mvwinstr. ncurses regards this inconsistency as an error in the standard. not me agreeing, but like. yeah.
π§ HISTORY π§
The System V Interface Definition, Version 4 (1995), specified winwstr and winnwstr (and the usual variants). these were later additions to SVr4.x β they did not appear in the first SVr4 (1989). and get this: their synopses described each function as taking an argument of type pointer-to-char instead of pointer-to-wchar_t, even while describing them as βreturning the string of wchar_t in strβ. presumably that was an error in the System V Interface Definition. π
β SEE ALSO β
curs_instr(3X)β describes comparable functions of the ncurses library in its non-wide-character configuration.curses(3X)curs_in_wch(3X)curs_in_wchstr(3X)
okay that's the whole page bestie, you ate it π
this was ncurses 6.6, dated 2025-10-20, and the manual page is curs_inwstr(3X). go forth and read your wide strings responsibly ππ
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- 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