insch(3NCURSES)
π insch β insert a curses character in a window π
okay bestie, welcome to insch(3NCURSES), straight out of the Library calls section of the manual. this is the lil family of functions that shoves a character into your window and makes everybody else scooch over. it's giving polite queue energy. let's get into it β¨
β¨ SYNOPSIS β¨
#include <curses.h>
int insch(chtype ch);
int winsch(WINDOW * win, chtype ch);
int mvinsch(int y, int x, chtype ch);
int mvwinsch(WINDOW * win, int y, int x, chtype ch);
four functions, one dream, no cap π«Ά
πΈ DESCRIPTION πΈ
so winsch inserts the curses character ch at the cursor position in the window win. that's the whole vibe.
and the way it works? the character that was already sitting at the cursor, plus literally everything to its right, all move one cell to the right. the character that used to be the rightmost one on the line? bestieβ¦ it's discarded. gone. no forwarding address π
BUT β and this is the part people miss β unlike addch(3NCURSES), winsch does not advance the cursor. it inserts and then it justβ¦ stays put. main character behavior honestly π
ncurses(3NCURSES) describes the variants of this function, so go read that if you wanna know how the family tree works π§
β RETURN VALUE β
these functions return OK on success and ERR on failure. simple as that π
in ncurses, they return ERR if:
- the curses screen has not been initialized, or
- (for functions taking a
WINDOWpointer argument)winis a null pointer.
and the ones with that mv prefix? they do cursor movement first, and they fail if the position (y, x) is outside the window boundaries. so if you're trying to move somewhere that doesn't exist, it's an ERR, periodt π
π NOTES π
okay a couple of lil things you should know:
insch,mvinsch, andmvwinschmay be implemented as macros. so don't get cute with them, iykyk.- curses does not necessarily employ the terminal's
insert_character(ich1) capability to achieve insertion. so likeβ¦ don't assume the terminal is doing the work here. the library might be doing it all by itself. iconic of it honestly π₯
π PORTABILITY π
X/Open Curses Issue 4 describes these functions. it specifies no error conditions for them. wild, i know. we're just out here raw-dogging error handling bestie π
SVr4 describes a successful return value only as βan integer value other than ERRβ. so like, not even OK specifically. justβ¦ not ERR. the bar is on the floor fr fr π«Ά
π¦ HISTORY π¦
SVr2 (1984) introduced these functions. so they've been around since before your parents were cool. vintage. antique. elder emoji π
π SEE ALSO π
ins_wch(3NCURSES)β describes comparable functions in the wide-character curses configuration. so if you're doing wide chars, that's your girl πΈncurses(3NCURSES)terminfo(5)
quick reminder bestie: this isinsch, notinch. one inserts a character, the other reads one. do not mix them up in front of company π
and that's the whole page!! this was ncurses 6.6, dated 2025-03-08, and yes the header really did say insch(3NCURSES) up top and Library calls as its section. slay, go insert some characters, you got this πβ¨π
π¦ where this page comes from
- ubuntu resolute: ncurses-doc 6.6+20251231-1 Β· MIT/X11
- ubuntu stonking: ncurses-doc 6.6+20260608-2 Β· MIT/X11
- 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