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