gtx: use getmaxyx() with sensible fallbacks
[openafs.git] / src / gtx / gtxcurseswin.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  *
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #ifndef __gator_curseswindows_h
11 #define __gator_curseswindows_h  1
12
13 #include "gtxwindows.h"         /*Base gator window dfns */
14
15 #if defined(AFS_HPUX110_ENV) && !defined(__HP_CURSES)
16 # define __HP_CURSES
17 #endif
18
19 #if defined(HAVE_NCURSES_H)
20 # include <ncurses.h>
21 #elif defined(HAVE_NCURSES_NCURSES_H)
22 # include <ncurses/ncurses.h>
23 #elif defined(HAVE_CURSES_H)
24 # include <curses.h>
25 #endif
26
27 #ifndef HAVE_GETMAXYX
28 #  if defined(HAVE_GETMAXY) && defined(HAVE_GETMAXX)
29 #    define getmaxyx(w,y,x) do {(y) = getmaxy(w); (x) = getmaxx(w);} while (0)
30 #  else
31 #    define getmaxyx(w,y,x) do {(y) = (w)->_maxy; (x) = (w)->_maxx;} while (0)
32 #  endif
33 #endif
34
35 /*Value for gwin w_type field*/
36 #define GATOR_WIN_CURSES    2
37
38 /*Private data for a curses gwin*/
39 struct gator_cursesgwin {
40     WINDOW *wp;                 /*Window pointer */
41     int charwidth;              /*Character width in pixels */
42     int charheight;             /*Character height in pixels */
43     char box_vertchar;          /*Vertical char for boxing purposes */
44     char box_horizchar;         /*Horizontal char for boxing purposes */
45 };
46
47 /*Curses gwin's creation parameters*/
48 struct gator_cursesgwin_params {
49     struct gwin_createparams gwin_params;       /*Basic params for the window */
50     int charwidth;              /*Character width in pixels */
51     int charheight;             /*Character height in pixels */
52     char box_vertchar;          /*Vertical char for boxing purposes */
53     char box_horizchar;         /*Horizontal char for boxing purposes */
54 };
55
56 /*Curses initialization routine*/
57
58 extern int gator_cursesgwin_init(int adebug);
59     /*
60      * Summary:
61      *    Initialize the curses window package.
62      *
63      * Args:
64      *    int adebug: Is debugging turned on?
65      *
66      * Returns:
67      *    0 on success,
68      *    Error value otherwise.
69      */
70
71 /*Curses window's creation routine*/
72
73 extern struct gwin *gator_cursesgwin_create(void *);
74     /*
75      * Summary:
76      *    Create a curses window.
77      *
78      * Args:
79      *    struct gator_cursesgwin_params *params : Ptr to creation parameters.
80      *
81      * Returns:
82      *    Ptr to the created curses window structure if successful,
83      *    Error value otherwise.
84      */
85
86 /*Curses cleanup routine*/
87
88 extern int gator_cursesgwin_cleanup(struct gwin *);
89     /*
90      * Summary:
91      *    Clean up after the curses window package.
92      *
93      * Args:
94      *    struct gwin *gwp : Ptr to base window.
95      *
96      * Returns:
97      *    0 on success,
98      *    Error value otherwise.
99      */
100
101 extern struct gwinbaseops gator_curses_gwinbops;
102
103 /*Curses window's routines*/
104
105 extern int gator_cursesgwin_box(struct gwin *);
106     /*
107      * Summary:
108      *    Draw a box around the given curses window.
109      *
110      * Args:
111      *   struct gwin *gwp : Ptr to the curses window to draw
112      *                              a box around.
113      *
114      * Returns:
115      *    0: Success.
116      *    Error value otherwise.
117      */
118
119 extern int gator_cursesgwin_clear(struct gwin *);
120     /*
121      * Summary:
122      *    Clear out the given curses window.
123      *
124      * Args:
125      *   struct gwin *gwp : Ptr to the curses window to clear
126      *                              out.
127      *
128      * Returns:
129      *    0: Success.
130      *    Error value otherwise.
131      */
132
133 extern int gator_cursesgwin_destroy(struct gwin *);
134     /*
135      * Summary:
136      *    Destroy the given curses window.
137      *
138      * Args:
139      *   struct gwin *gwp : Ptr to the curses window to destroy.
140      *
141      * Returns:
142      *    0: Success.
143      *    Error value otherwise.
144      */
145
146 extern int gator_cursesgwin_display(struct gwin *);
147     /*
148      * Summary:
149      *    Display/redraw the given curses window.
150      *
151      * Args:
152      *   struct gwin *gwp : Ptr to the curses window to draw.
153      *
154      * Returns:
155      *    0: Success.
156      *    Error value otherwise.
157      */
158
159 extern int gator_cursesgwin_drawline(struct gwin *, struct gwin_lineparams *);
160     /*
161      * Summary:
162      *    Draw a line between two points in the given curses
163      *    window.
164      *
165      * Args:
166      *   struct gwin *gwp : Ptr to the curses window in which
167      *                              the line is to be drawn.
168      *   struct gwin_lineparams *params : Ptr to other params.
169      *
170      * Returns:
171      *    0: Success.
172      *    Error value otherwise.
173      */
174
175 extern int gator_cursesgwin_drawrectangle(struct gwin *,
176                                           struct gwin_rectparams *);
177     /*
178      * Summary:
179      *    Draw a rectangle in the given curses window.
180      *
181      * Args:
182      *   struct gwin *gwp : Ptr to the curses window in which
183      *                              the rectangle is to be drawn.
184      *   struct gwin_rectparams *params : Ptr to other params.
185      *
186      * Returns:
187      *    0: Success.
188      *    Error value otherwise.
189      */
190
191 extern int gator_cursesgwin_drawchar(struct gwin *, struct gwin_charparams *);
192     /*
193      * Summary:
194      *    Draw a character in the given curses window.
195      *
196      * Args:
197      *   struct gwin *gwp : Ptr to the curses window in which
198      *                              the character is to be drawn.
199      *   struct gwin_charparams *params : Ptr to other params.
200      *
201      * Returns:
202      *    0: Success.
203      *    Error value otherwise.
204      */
205
206 extern int gator_cursesgwin_drawstring(struct gwin *, struct gwin_strparams *);
207     /*
208      * Summary:
209      *    Draw a string in the given curses window.
210      *
211      * Args:
212      *   struct gwin *gwp : Ptr to the curses window in which
213      *                              the string is to be drawn.
214      *   struct gwin_strparams *params : Ptr to other params.
215      *
216      * Returns:
217      *    0: Success.
218      *    Error value otherwise.
219      */
220
221 extern int gator_cursesgwin_invert(struct gwin *, struct gwin_invparams *);
222     /*
223      * Summary:
224      *    Invert a region in the given curses window.
225      *
226      * Args:
227      *   struct gwin *gwp : Ptr to the curses window in which
228      *                              the inverted region lies.
229      *   struct gwin_invparams *params : Ptr to other params.
230      *
231      * Returns:
232      *    0: Success.
233      *    Error value otherwise.
234      */
235
236 extern int gator_cursesgwin_getchar(struct gwin *);
237
238 extern int gator_cursesgwin_getdimensions(struct gwin *,
239                                           struct gwin_sizeparams *aparms);
240
241 extern int gator_cursesgwin_wait(struct gwin *);
242
243 #endif /* __gator_curseswindows_h */