]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_getyx.3x
92b48af9ffb5f86f36741b624f7cf0500f16f3c1
[ncurses.git] / man / curs_getyx.3x
1 .\"***************************************************************************
2 .\" Copyright 2020-2023,2024 Thomas E. Dickey                                *
3 .\" Copyright 1998-2007,2010 Free Software Foundation, Inc.                  *
4 .\"                                                                          *
5 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
6 .\" copy of this software and associated documentation files (the            *
7 .\" "Software"), to deal in the Software without restriction, including      *
8 .\" without limitation the rights to use, copy, modify, merge, publish,      *
9 .\" distribute, distribute with modifications, sublicense, and/or sell       *
10 .\" copies of the Software, and to permit persons to whom the Software is    *
11 .\" furnished to do so, subject to the following conditions:                 *
12 .\"                                                                          *
13 .\" The above copyright notice and this permission notice shall be included  *
14 .\" in all copies or substantial portions of the Software.                   *
15 .\"                                                                          *
16 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23 .\"                                                                          *
24 .\" Except as contained in this notice, the name(s) of the above copyright   *
25 .\" holders shall not be used in advertising or otherwise to promote the     *
26 .\" sale, use or other dealings in this Software without prior written       *
27 .\" authorization.                                                           *
28 .\"***************************************************************************
29 .\"
30 .\" $Id: curs_getyx.3x,v 1.45 2024/05/11 20:39:53 tom Exp $
31 .TH curs_getyx 3X 2024-05-11 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
32 .ie \n(.g \{\
33 .ds `` \(lq
34 .ds '' \(rq
35 .\}
36 .el \{\
37 .ie t .ds `` ``
38 .el   .ds `` ""
39 .ie t .ds '' ''
40 .el   .ds '' ""
41 .\}
42 .
43 .SH NAME
44 \fB\%getyx\fP,
45 \fB\%getparyx\fP,
46 \fB\%getbegyx\fP,
47 \fB\%getmaxyx\fP \-
48 get \fIcurses\fR cursor and window coordinates
49 .SH SYNOPSIS
50 .nf
51 \fB#include <curses.h>
52 .PP
53 \fBvoid getyx(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP);
54 \fBvoid getbegyx(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP);
55 \fBvoid getmaxyx(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP);
56 .PP
57 \fBvoid getparyx(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP);
58 .fi
59 .SH DESCRIPTION
60 These macros obtain the cursor position and bounds information of a
61 .I curses
62 window
63 .IR win "."
64 .B \%getyx
65 stores
66 .IR win "'s"
67 cursor position in the variables
68 .I y
69 and
70 .IR x "."
71 .B \%getmaxyx
72 stores
73 .IR win "'s"
74 maximum valid row and column numbers in
75 .I y
76 and
77 .IR x ","
78 respectively.
79 .B \%getbegyx
80 similarly stores the position of
81 .IR win "'s"
82 origin relative to that of the screen
83 (for
84 .BR stdscr ","
85 these coordinates are always
86 .BR 0 ")."
87 .PP
88 If
89 .I win
90 is a subwindow
91 (see \fB\%subwin\fP(3X)),
92 the
93 .B \%getparyx
94 macro places the coordinates of its origin relative to its parent window
95 into
96 .I y
97 and
98 .IR x ","
99 and
100 .B \-1
101 into both if it is not.
102 .SH RETURN VALUE
103 No return values are defined for macros.
104 Do not use them as the right-hand side of assignment statements.
105 .SH NOTES
106 All of these interfaces are implemented as macros.
107 An \*(``&\*('' operator is not necessary before the variables
108 .I y
109 and
110 .IR x "."
111 .SH PORTABILITY
112 These macros are described in X/Open Curses,
113 Issue 4.
114 .PP
115 .I \%ncurses
116 also provides functions
117 .BR \%getbegx ","
118 .BR \%getbegy ","
119 .BR \%getcurx ","
120 .BR \%getcury ","
121 .BR \%getmaxx ","
122 .BR \%getmaxy ","
123 .BR \%getparx ","
124 and
125 .B \%getpary
126 for compatibility with older versions of
127 .IR curses ";"
128 see \fB\%curs_legacy\fP(3X).
129 .PP
130 Although X/Open Curses does not address the issue,
131 many implementations expose members of the
132 .I \%WINDOW
133 structure containing values corresponding to these macros.
134 Do not rely on their availability;
135 some implementations make
136 .I \%WINDOW
137 opaque
138 (that is,
139 they do not allow direct access to its members).
140 .PP
141 Besides the problem of opaque structures,
142 the data stored in like-named members may not have values of the same
143 meaning different implementations.
144 For example,
145 the values of
146 .B \%WINDOW._maxx
147 and
148 .B \%WINDOW._maxy
149 in
150 .I \%ncurses
151 have long
152 .\" (at least since its initial release, 1.8.1)
153 differed by one from some other implementations.
154 The
155 .B \%getmaxyx
156 macro hides this difference.
157 .SH SEE ALSO
158 \fB\%curses\fP(3X),
159 \fB\%curs_legacy\fP(3X),
160 \fB\%curs_opaque\fP(3X)