curs_inchstr(3X)
π curs_inchstr β get a curses character string from a window π
okay bestie, welcome to curs_inchstr(3X), a genuine library calls moment. this is the one where you yoink a whole string of curses characters out of a window and shove it in your buffer. let's get into it π«Ά
β¨ NAME β¨
inchstr, inchnstr, winchstr, winchnstr, mvinchstr, mvinchnstr, mvwinchstr, mvwinchnstr β get a curses character string from a window
πΈ SYNOPSIS πΈ
#include <curses.h>
int inchstr(chtype * chstr);
int inchnstr(chtype * chstr, int n);
int winchstr(WINDOW * win, chtype * chstr);
int winchnstr(WINDOW * win, chtype * chstr, int n);
int mvinchstr(int y, int x, chtype * chstr);
int mvinchnstr(int y, int x, chtype * chstr, int n);
int mvwinchstr(WINDOW * win, int y, int x, chtype * chstr);
int mvwinchnstr(WINDOW * win, int y, int x, chtype * chstr, int n);
π¦ DESCRIPTION π¦
so winchstr grabs a curses character string out of a curses window win, and it starts right at the cursor and keeps going until it hits the end of the line, then drops the whole thing into chstr and caps it off with a null curses character. that's the vibe. π
winchnstr does the exact same thing but copies at most n curses characters out of win. and here's the fun part β a negative n means no limit at all, so winchnstr just acts like winchstr in that case. slay.
ncurses(3X) is where you go if you wanna know about the variants of these functions, iykyk.
π RETURN VALUE π
these cuties return OK when it works and ERR when it does not. periodt.
in ncurses, these functions fail if:
- the curses screen has not been initialized,
- (for functions taking a
WINDOWpointer argument)winis a null pointer, or chstris a null pointer.
and the ones prefixed with βmvβ? they do the cursor movement first, and they fail if the position (y, x) is outside the window boundaries. rude but fair. π
π NOTES π
all of these functions except winchnstr may be implemented as macros. not me finding that out the hard way π
and now the serious one, bestie, listen up:
reading a line that overflows the array pointed to by chstr and its variants causes undefined results. fr fr, do not do this.
instead, use the n-infixed functions with a positive n argument no larger than the size of the buffer backing chstr. that's the safe route, take it. π
π EXTENSIONS π
inchnstr, winchnstr, mvinchnstr, and mvwinchnstr's acceptance of negative n values is an ncurses extension. iconic behavior, but keep it in mind.
β PORTABILITY β
apps that use ncurses extensions should condition their use on the visibility of the NCURSES_VERSION preprocessor macro. yes, like that. π
- X/Open Curses Issue 4 describes these functions. it specifies no error conditions for them. it characterizes the strings stored by these functions as containing βat most n elementsβ from a window, but it does not specify whether the string stored by these functions is null-terminated.
- SVr4 does not document whether it null-terminates the curses character string it stores in
chstr, and does not document whether a trailing null curses character counts toward the length limitn. - SVr4 describes a successful return value only as βan integer value other than ERRβ. okay bestie, be vague about it then. π
π§ HISTORY π§
SVr3.1 (1987) introduced these functions. old money, honestly.
π₯ SEE ALSO π₯
curs_in_wchstr(3X)β describes comparable functions of the ncurses library in its wide-character configuration (ncursesw). πcurses(3X)curs_inch(3X)curs_inwstr(3X)
that's the whole page, bestie β this was ncurses 6.6, dated 2025-10-20, and it ate, no cap πβ¨ go forth and read your windows 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 1998-2010,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