Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Utilities/cmpdcurses/pdcurses/getyx.c
3153 views
1
/* PDCurses */
2
3
#include <curspriv.h>
4
5
/*man-start**************************************************************
6
7
getyx
8
-----
9
10
### Synopsis
11
12
void getyx(WINDOW *win, int y, int x);
13
void getparyx(WINDOW *win, int y, int x);
14
void getbegyx(WINDOW *win, int y, int x);
15
void getmaxyx(WINDOW *win, int y, int x);
16
17
void getsyx(int y, int x);
18
void setsyx(int y, int x);
19
20
int getbegy(WINDOW *win);
21
int getbegx(WINDOW *win);
22
int getcury(WINDOW *win);
23
int getcurx(WINDOW *win);
24
int getpary(WINDOW *win);
25
int getparx(WINDOW *win);
26
int getmaxy(WINDOW *win);
27
int getmaxx(WINDOW *win);
28
29
### Description
30
31
The getyx() macro (defined in curses.h -- the prototypes here are
32
merely illustrative) puts the current cursor position of the
33
specified window into y and x. getbegyx() and getmaxyx() return the
34
starting coordinates and size of the specified window, respectively.
35
getparyx() returns the starting coordinates of the parent's window,
36
if the specified window is a subwindow; otherwise it sets y and x to
37
-1. These are all macros.
38
39
getsyx() gets the coordinates of the virtual screen cursor, and
40
stores them in y and x. If leaveok() is TRUE, it returns -1, -1. If
41
lines have been removed with ripoffline(), then getsyx() includes
42
these lines in its count; so, the returned y and x values should only
43
be used with setsyx().
44
45
setsyx() sets the virtual screen cursor to the y, x coordinates. If
46
either y or x is -1, leaveok() is set TRUE, else it's set FALSE.
47
48
getsyx() and setsyx() are meant to be used by a library routine that
49
manipulates curses windows without altering the position of the
50
cursor. Note that getsyx() is defined only as a macro.
51
52
getbegy(), getbegx(), getcurx(), getcury(), getmaxy(), getmaxx(),
53
getpary(), and getparx() return the appropriate coordinate or size
54
values, or ERR in the case of a NULL window.
55
56
### Portability
57
X/Open ncurses NetBSD
58
getyx Y Y Y
59
getparyx Y Y Y
60
getbegyx Y Y Y
61
getmaxyx Y Y Y
62
getsyx - Y Y
63
setsyx - Y Y
64
getbegy - Y Y
65
getbegx - Y Y
66
getcury - Y Y
67
getcurx - Y Y
68
getpary - Y Y
69
getparx - Y Y
70
getmaxy - Y Y
71
getmaxx - Y Y
72
73
**man-end****************************************************************/
74
75
int getbegy(WINDOW *win)
76
{
77
PDC_LOG(("getbegy() - called\n"));
78
79
return win ? win->_begy : ERR;
80
}
81
82
int getbegx(WINDOW *win)
83
{
84
PDC_LOG(("getbegx() - called\n"));
85
86
return win ? win->_begx : ERR;
87
}
88
89
int getcury(WINDOW *win)
90
{
91
PDC_LOG(("getcury() - called\n"));
92
93
return win ? win->_cury : ERR;
94
}
95
96
int getcurx(WINDOW *win)
97
{
98
PDC_LOG(("getcurx() - called\n"));
99
100
return win ? win->_curx : ERR;
101
}
102
103
int getpary(WINDOW *win)
104
{
105
PDC_LOG(("getpary() - called\n"));
106
107
return win ? win->_pary : ERR;
108
}
109
110
int getparx(WINDOW *win)
111
{
112
PDC_LOG(("getparx() - called\n"));
113
114
return win ? win->_parx : ERR;
115
}
116
117
int getmaxy(WINDOW *win)
118
{
119
PDC_LOG(("getmaxy() - called\n"));
120
121
return win ? win->_maxy : ERR;
122
}
123
124
int getmaxx(WINDOW *win)
125
{
126
PDC_LOG(("getmaxx() - called\n"));
127
128
return win ? win->_maxx : ERR;
129
}
130
131
void setsyx(int y, int x)
132
{
133
PDC_LOG(("setsyx() - called\n"));
134
135
if (curscr)
136
{
137
curscr->_leaveit = y == -1 || x == -1;
138
139
if (!curscr->_leaveit)
140
wmove(curscr, y, x);
141
}
142
}
143
144