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 π¦
getyxdropswin's cursor position into the variablesyandxπgetmaxyxdropswin's maximum valid line and column dimensions intoyandx, respectively π and heads up, those are one more than the corresponding maximum positions (iykyk, that's just how it is)getbegyxdoes the same thing but for the position ofwin's origin relative to the screen's origin π and forstdscrthose coordinates are always0
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 variablesyandxπ
π PORTABILITY π
- these macros are described in X/Open Curses Issue 4 π
ncursesalso provides functionsgetbegy,getbegx,getcury,getcurx,getmaxy,getmaxx,getpary, andgetparxfor compatibility with System V curses that were not standardized; seelegacy(3NCURSES)π¦- X/Open Curses doesn't address this, but many implementations expose members of the
WINDOWstructure holding values corresponding to these macros. do not rely on their availability β some implementations makeWINDOWopaque (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._maxxandWINDOW._maxyinncurseshave long differed by one from some other implementations. thegetmaxyxmacro 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) introducedgetyxπSVr3(1987) addedgetbegyxandgetmaxyxπΈSVr3.1later that same year suppliedgetparyxβ¨
π 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
- Copyright 2020-2025,2026 Thomas E. Dickey
- Copyright 1998-2007,2010 Free Software Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms