curs_getyx(3X)
π curs_getyx β library calls, but make it a vibe β¨
okay bestie, so you know how curses has windows and you're always like "where is my cursor actually at tho"?? π This page is the whole girlboss squad of macros that answer exactly that. We're talking getyx, getparyx, getbegyx, and getmaxyx β they get your curses cursor 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);
like, yes, they look like functions. they are not. stay tuned. π
β¨ DESCRIPTION β¨
So these macros are your little coordinate detectives for a curses window win. π΅οΈββοΈ Here's the tea, one by one:
getyxβ storeswin's cursor position into the variablesyandx. where u at, literally.getmaxyxβ storeswin's maximum valid line and column numbers intoyandx, respectively. that's the outer limits, the edge of the map, the "you shall not pass" πgetbegyxβ same energy, but it stores the position ofwin's origin relative to that of the screen. and forstdscrspecifically? those coordinates are always0. main character stays at the origin, periodt. π
And if win is a subwindow (peep subwin(3X) for that lore), then the getparyx macro does something different: it 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. not a subwindow bestie, not sorry. π
π«Ά RETURN VALUE π«Ά
okay so β no return values are defined for macros. None. Zero. They're macros, not functions, so there's nothing to catch. π«
Do not use them as the right-hand side of assignment statements. just don't. it's giving "undefined" and not in the cute way. π
π NOTES π
- All of these interfaces are implemented as macros. every single one.
- An
&operator is not necessary before the variablesyandx. so no&y, no&x, put the ampersand down babe, we don't need it here π«Ά
π PORTABILITY π
These macros are described in X/Open Curses Issue 4. π
ncurses also provides these functions for compatibility with System V curses that were not standardized:
getbegygetbegxgetcurygetcurxgetmaxygetmaxxgetparygetparx
go read curs_legacy(3X) for the whole backstory. π«
Although X/Open Curses does not address the issue, many implementations expose members of the WINDOW structure containing values corresponding to these macros. Do not rely on their availability β some implementations make WINDOW opaque (that is, they do not allow direct access to its members). π§
And besides the whole opaque-structure problem: the data stored in like-named members may not have values of the same meaning across different implementations. example incoming β the values of WINDOW._maxx and WINDOW._maxy in ncurses have long differed by one from some other implementations. π³ The getmaxyx macro hides this difference for you, so like, use the macro, bestie. she's the one holding it down. π
π HISTORY π
- 4BSD (1980) introduced
getyx. - SVr3 (1987) added
getbegyxandgetmaxyx. - SVr3.1 later that year supplied
getparyx.
a whole glow-up timeline, honestly. π
π SEE ALSO π
curses(3X)curs_legacy(3X)curs_opaque(3X)
and that's the whole page, bestie!! π¦ this iconic little manual page is from ncurses 6.6 and it's dated 2025-02-01 β so you know it's fresh, you know it's current, and you know it ate. π mwah, go get those coordinates. β¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright 2020-2024,2025 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