1 /* Public Domain Curses */
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 int 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
32 are merely illustrative) puts the current cursor position of the
33 specified window into y and x. getbegyx() and getmaxyx() return
34 the starting coordinates and size of the specified window,
35 respectively. getparyx() returns the starting coordinates of the
36 parent's window, if the specified window is a subwindow;
37 otherwise it sets y and x to -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.
41 If lines have been removed with ripoffline(), then getsyx()
42 includes these lines in its count; so, the returned y and x
43 values should only be used with setsyx().
44
45 setsyx() sets the virtual screen cursor to the y, x coordinates.
46 If y, x are -1, -1, leaveok() is set TRUE.
47
48 getsyx() and setsyx() are meant to be used by a library routine
49 that manipulates curses windows without altering the position of
50 the cursor. Note that getsyx() is defined only as a macro.
51
52 getbegy(), getbegx(), getcurx(), getcury(), getmaxy(),
53 getmaxx(), getpary(), and getparx() return the appropriate
54 coordinate or size values, or ERR in the case of a NULL window.
55
56 ### Portability
57 X/Open BSD SYS V
58 getyx Y Y Y
59 getparyx - - 4.0
60 getbegyx - - 3.0
61 getmaxyx - - 3.0
62 getsyx - - 3.0
63 setsyx - - 3.0
64 getbegy - - -
65 getbegx - - -
66 getcury - - -
67 getcurx - - -
68 getpary - - -
69 getparx - - -
70 getmaxy - - -
71 getmaxx - - -
72
73 **man-end****************************************************************/
74
getbegy(WINDOW * win)75 int getbegy(WINDOW *win)
76 {
77 PDC_LOG(("getbegy() - called\n"));
78
79 return win ? win->_begy : ERR;
80 }
81
getbegx(WINDOW * win)82 int getbegx(WINDOW *win)
83 {
84 PDC_LOG(("getbegx() - called\n"));
85
86 return win ? win->_begx : ERR;
87 }
88
getcury(WINDOW * win)89 int getcury(WINDOW *win)
90 {
91 PDC_LOG(("getcury() - called\n"));
92
93 return win ? win->_cury : ERR;
94 }
95
getcurx(WINDOW * win)96 int getcurx(WINDOW *win)
97 {
98 PDC_LOG(("getcurx() - called\n"));
99
100 return win ? win->_curx : ERR;
101 }
102
getpary(WINDOW * win)103 int getpary(WINDOW *win)
104 {
105 PDC_LOG(("getpary() - called\n"));
106
107 return win ? win->_pary : ERR;
108 }
109
getparx(WINDOW * win)110 int getparx(WINDOW *win)
111 {
112 PDC_LOG(("getparx() - called\n"));
113
114 return win ? win->_parx : ERR;
115 }
116
getmaxy(WINDOW * win)117 int getmaxy(WINDOW *win)
118 {
119 PDC_LOG(("getmaxy() - called\n"));
120
121 return win ? win->_maxy : ERR;
122 }
123
getmaxx(WINDOW * win)124 int getmaxx(WINDOW *win)
125 {
126 PDC_LOG(("getmaxx() - called\n"));
127
128 return win ? win->_maxx : ERR;
129 }
130
setsyx(int y,int x)131 int setsyx(int y, int x)
132 {
133 PDC_LOG(("setsyx() - called\n"));
134
135 if(y == -1 && x == -1)
136 {
137 curscr->_leaveit = TRUE;
138 return OK;
139 }
140 else
141 {
142 curscr->_leaveit = FALSE;
143 return wmove(curscr, y, x);
144 }
145 }
146