in_wch(3NCURSES)

πŸ’… in_wch β€” get a curses complex character from a window πŸŽ€

okay bestie, so this is a library call page from the 3NCURSES corner of the world. Sit down, grab a boba, we're learning how to yoink a complex character out of a window. ✨


✨ NAME ✨

in_wch, win_wch, mvin_wch, mvwin_wch β€” get a curses complex character from a window πŸ¦‹


🌸 SYNOPSIS 🌸

#include <curses.h>

int in_wch(cchar_t * wch);
int win_wch(WINDOW * win, cchar_t * wch);
int mvin_wch(int y, int x, cchar_t * wch);
int mvwin_wch(WINDOW * win, int y, int x, cchar_t * wch);

πŸ’– DESCRIPTION πŸ’–

So here's the tea: win_wch copies the curses complex character that's sitting at the cursor position in win right into wch. Like, it reaches in and grabs it. 🫳✨

Then, to actually pull apart what you got β€” its character code, its attributes, and its color pair identifier β€” you use getcchar(3NCURSES). That's the unlock. πŸ”‘

And if you're wondering about all the different flavors of this function, ncurses(3NCURSES) describes the variants. iykyk. πŸ’…


πŸ”₯ RETURN VALUE πŸ”₯

  • OK on success πŸŽ‰
  • ERR on failure 😭

In ncurses specifically, they return ERR if win is NULL. Yeah. No window, no vibes.

And for the ones prefixed with mv β€” those do a cursor movement first, and they fail if the position (y, x) is outside the window boundaries. Stay in bounds or get an ERR, no in-between. 🚧


πŸŽ€ NOTES πŸŽ€

  • in_wch, mvin_wch, and mvwin_wch may be implemented as macros. Sneaky little things. πŸ‘€
  • Unlike winch(3NCURSES), win_wch and its variants store the value of the retrieved character in an additional wch parameter instead of in the return value. That's the whole plot twist of this function fr fr. 🌈

🧚 PORTABILITY 🧚

X/Open Curses Issue 4 describes these functions. It specifies no error conditions for them. So like… make of that what you will. πŸ€·β™€οΈ


πŸ‘‘ 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 winwch (and the usual variants). That one was a later addition to SVr4.x β€” it did not appear in the first SVr4 (1989), so don't go looking for it there. πŸ•΅οΈβ™€οΈ

And here's the difference, bestie: it differed from X/Open's later win_wch in that it returned a value of type chtype instead of cchar_t. So close, yet so different. πŸ’€


🌈 SEE ALSO 🌈

  • inch(3NCURSES) β€” describes comparable functions of the ncurses library in its non-wide-character configuration. The skinny version. πŸ¦‹
  • ncurses(3NCURSES)
  • inwstr(3NCURSES)

and that's the whole page, bestie, you ate that πŸ“βœ¨ go forth and grab your complex characters, main character energy only πŸ’œ

ncurses 6.6 Β· 2025-02-01 Β· in_wch(3NCURSES) β€” periodt. πŸ’…πŸŽ€

πŸ“¦ where this page comes from