getyx(3NCURSES)

πŸ’– getyx(3NCURSES) β€” bestie edition πŸ’–

okay so this is a library calls page from the 3NCURSES manual, and it's all about peeking at where your cursor is and how big your window is ✨


🌸 NAME 🌸

getyx, getparyx, getbegyx, getmaxyx β€” grab your curses cursor position and window coordinates, no cap πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <curses.h>

void getyx(WINDOW *win, int y, int x);
void getbegyx(WINDOW *win, int y, int x);
void getmaxyx(WINDOW *win, int y, int x);

void getparyx(WINDOW *win, int y, int x);

✨ DESCRIPTION ✨

so these are macros, right, and they hand you the cursor position + the bounds info of a curses window win πŸ¦‹

  • getyx drops win's cursor position into the variables y and x πŸ“
  • getmaxyx drops win's maximum valid line and column dimensions into y and x, respectively πŸ‘‘ and heads up, those are one more than the corresponding maximum positions (iykyk, that's just how it is)
  • getbegyx does the same thing but for the position of win's origin relative to the screen's origin 🌈 and for stdscr those coordinates are always 0

and then if win is a subwindow (go read subwin(3NCURSES) bestie), getparyx puts the coordinates of its origin relative to its parent window into y and x β€” and if it's not a subwindow, it puts -1 into both 🫢


πŸ’€ RETURN VALUE πŸ’€

ngl there are no return values defined for these macros. so do NOT use them as the right-hand side of assignment statements. not a vibe, don't do it πŸ™ˆ


🧚 NOTES 🧚

  • every single one of these interfaces is implemented as a macro ✨
  • so you do not need an & operator before the variables y and x πŸ’…

🌈 PORTABILITY 🌈

  • these macros are described in X/Open Curses Issue 4 πŸ“œ
  • ncurses also provides functions getbegy, getbegx, getcury, getcurx, getmaxy, getmaxx, getpary, and getparx for compatibility with System V curses that were not standardized; see legacy(3NCURSES) πŸ¦‹
  • X/Open Curses doesn't address this, but many implementations expose members of the WINDOW structure holding values corresponding to these macros. do not rely on their availability β€” some implementations make WINDOW opaque (meaning they don't let you touch its members directly) πŸ™…
  • and beyond the whole opaque-structure situation, the data in like-named members might not even mean the same thing across different implementations 😭 for example, the values of WINDOW._maxx and WINDOW._maxy in ncurses have long differed by one from some other implementations. the getmaxyx macro is the icon that hides this difference πŸ‘‘
bestie this is the part where you go "oh so THAT's why I always use the macro" β€” yes. exactly that. periodt πŸ’…

⭐ HISTORY ⭐

  • 4BSD (1980) introduced getyx πŸŽ€
  • SVr3 (1987) added getbegyx and getmaxyx 🌸
  • SVr3.1 later that same year supplied getparyx ✨

πŸ‘‘ SEE ALSO πŸ‘‘

  • ncurses(3NCURSES)
  • legacy(3NCURSES)
  • opaque(3NCURSES)

and that's the whole page, bestie 🫢 this was ncurses 6.6, dated 2026-03-14, and yes this whole thing is literally titled getyx(3NCURSES) πŸ’– mwah, go get those coordinates πŸŽ€

πŸ“¦ where this page comes from
  • ubuntu stonking: ncurses-doc 6.6+20260608-2 Β· MIT/X11
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms