gtx-prototypes-20090316
[openafs.git] / src / gtx / curseswindows.c
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 /*
11  * gator_curseswindows.c
12  *
13  * Description:
14  *      Implementation of the gator curses window facility.
15  *
16  *------------------------------------------------------------------------*/
17
18 #include <afsconfig.h>
19 #include <afs/param.h>
20
21 RCSID
22     ("$Header$");
23
24
25 #if defined(AFS_HPUX110_ENV) && !defined(__HP_CURSES)
26 #define __HP_CURSES
27 #endif
28
29 #ifndef AFS_SUN5_ENV
30 #include <curses.h>             /*Curses library */
31 #endif
32 #include <sys/types.h>
33 #include <sys/file.h>
34 #if !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV)
35 #include <sgtty.h>
36 #endif
37 #include <stdio.h>
38 #include <sys/time.h>
39 #include <errno.h>
40 #include <string.h>
41 #include <stdlib.h>
42
43 #include <lwp.h>
44
45 #include "gtxcurseswin.h"       /*Interface definition */
46 #include "gtxobjects.h"
47 #include "gtxframe.h"
48
49
50
51 int curses_debug;               /*Is debugging turned on? */
52 static char mn[] = "gator_curseswindows";       /*Module name */
53
54 /*
55  * Version of standard operations for a curses window.
56  */
57 struct gwinops curses_gwinops = {
58     gator_cursesgwin_box,
59     gator_cursesgwin_clear,
60     gator_cursesgwin_destroy,
61     gator_cursesgwin_display,
62     gator_cursesgwin_drawline,
63     gator_cursesgwin_drawrectangle,
64     gator_cursesgwin_drawchar,
65     gator_cursesgwin_drawstring,
66     gator_cursesgwin_invert,
67     gator_cursesgwin_getchar,
68     gator_cursesgwin_getdimensions,
69     gator_cursesgwin_wait,
70 };
71
72 struct gwinbaseops gator_curses_gwinbops = {
73     gator_cursesgwin_create,
74     gator_cursesgwin_cleanup,
75 };
76
77
78 /*
79  * Macros to map pixel positions to row & column positions.
80  * (Note: for now, they are the identity function!!)
81  */
82 #define GATOR_MAP_X_TO_COL(w, x)    (x)
83 #define GATOR_MAP_Y_TO_LINE(w, y)   (y)
84
85 /*------------------------------------------------------------------------
86  * gator_cursesgwin_init
87  *
88  * Description:
89  *      Initialize the curses window package.
90  *
91  * Arguments:
92  *      int adebug: Is debugging turned on?
93  *
94  * Returns:
95  *      0 on success,
96  *      Error value otherwise.
97  *
98  * Environment:
99  *      Nothing interesting.
100  *
101  * Side Effects:
102  *      As advertised.
103  *------------------------------------------------------------------------*/
104
105 int
106 gator_cursesgwin_init(int adebug)
107 {                               /*gator_cursesgwin_init */
108
109     static char rn[] = "gator_cursesgwin_init"; /*Routine name */
110     struct gator_cursesgwin *c_data;    /*Ptr to curses-specific data */
111
112     /*
113      * Remember if we'll be doing debugging, then init the curses package.
114      */
115     curses_debug = adebug;
116
117     if (curses_debug)
118         fprintf(stderr, "[%s:%s] Calling initscr()\n", mn, rn);
119     initscr();
120
121     /*
122      * Fill out the base window structure for curses.
123      */
124     if (curses_debug)
125         fprintf(stderr,
126                 "[%s:%s] Allocating %lu bytes for curses window private space in base window\n",
127                 mn, rn, sizeof(struct gator_cursesgwin));
128     c_data =
129         (struct gator_cursesgwin *)malloc(sizeof(struct gator_cursesgwin));
130     if (c_data == (struct gator_cursesgwin *)0) {
131         fprintf(stderr,
132                 "[%s:%s] Can't allocate %lu bytes for curses window private space in base window\n",
133                 mn, rn, sizeof(struct gator_cursesgwin));
134         return (-1);
135     }
136
137     /*
138      * Fill in the curses-specific base window info.  We assume that chars are 8x13.
139      */
140     c_data->wp = stdscr;
141     c_data->charwidth = 8;
142     c_data->charheight = 13;
143     c_data->box_vertchar = '|';
144     c_data->box_horizchar = '-';
145
146     /*
147      * Fill in the generic base window info.
148      */
149     gator_basegwin.w_type = GATOR_WIN_CURSES;
150     gator_basegwin.w_x = 0;
151     gator_basegwin.w_y = 0;
152     gator_basegwin.w_width = c_data->charwidth * COLS;
153     gator_basegwin.w_height = c_data->charheight * LINES;
154     gator_basegwin.w_changed = 0;
155     gator_basegwin.w_op = &curses_gwinops;
156     gator_basegwin.w_parent = NULL;
157
158     /*
159      * Plug the private data into the generic part of the base window.
160      */
161     gator_basegwin.w_data = (int *)c_data;
162
163     /*
164      * Now, set the terminal into the right mode for handling input
165      */
166     raw();                      /* curses raw mode */
167
168     /* init the frame */
169     gator_basegwin.w_frame = gtxframe_Create();
170
171     /*
172      * Clear out the screen and return the good news.
173      */
174     wclear(((struct gator_cursesgwin *)(gator_basegwin.w_data))->wp);
175     return (0);
176
177 }                               /*gator_cursesgwin_init */
178
179 /*------------------------------------------------------------------------
180  * gator_cursesgwin_create
181  *
182  * Description:
183  *      Create a curses window (incorrectly).
184  *
185  * Arguments:
186  *      struct gator_cursesgwin_params *params : Ptr to creation parameters.
187  *
188  * Returns:
189  *      Ptr to the created curses window if successful,
190  *      Null ptr otherwise.
191  *
192  * Environment:
193  *      Nothing interesting.
194  *
195  * Side Effects:
196  *      As advertised.
197  *------------------------------------------------------------------------*/
198
199 struct gwin *
200 gator_cursesgwin_create(struct gator_cursesgwin_params *params)
201 {                               /*gator_cursesgwin_create */
202
203     static char rn[] = "gator_cursesgwin_create";       /*Routine name */
204     struct gwin *newgwin;       /*Ptr to new curses window */
205     struct gator_cursesgwin *c_data;    /*Ptr to curses-specific data */
206     WINDOW *newcursgwin;        /*Ptr to new curses window */
207
208     if (curses_debug)
209         fprintf(stderr,
210                 "[%s:%s] Allocating %lu bytes for new gwin structure\n", mn,
211                 rn, sizeof(struct gwin));
212     newgwin = (struct gwin *)malloc(sizeof(struct gwin));
213     if (newgwin == NULL) {
214         fprintf(stderr,
215                 "[%s:%s] Can't malloc() %lu bytes for new gwin structure: Errno is %d\n",
216                 mn, rn, sizeof(struct gwin), errno);
217         return (NULL);
218     }
219
220     newgwin->w_type = GATOR_WIN_CURSES;
221     newgwin->w_x = params->gwin_params.cr_x;
222     newgwin->w_y = params->gwin_params.cr_y;
223     newgwin->w_width = params->gwin_params.cr_width;
224     newgwin->w_height = params->gwin_params.cr_height;
225     newgwin->w_changed = 1;
226     newgwin->w_op = &curses_gwinops;
227     newgwin->w_parent = params->gwin_params.cr_parentwin;
228
229     if (curses_debug)
230         fprintf(stderr,
231                 "[%s:%s] Allocating %lu bytes for curses window private space\n",
232                 mn, rn, sizeof(struct gator_cursesgwin));
233     c_data =
234         (struct gator_cursesgwin *)malloc(sizeof(struct gator_cursesgwin));
235     if (c_data == (struct gator_cursesgwin *)0) {
236         fprintf(stderr,
237                 "[%s:%s] Can't allocate %lu bytes for curses window private space\n",
238                 mn, rn, sizeof(struct gator_cursesgwin));
239         free(newgwin);
240         return (NULL);
241     }
242
243     newcursgwin = newwin(newgwin->w_height,     /*Number of lines */
244                          newgwin->w_width,      /*Number of columns */
245                          newgwin->w_y,  /*Beginning y value */
246                          newgwin->w_x); /*Beginning x value */
247     if (newcursgwin == (WINDOW *) 0) {
248         fprintf(stderr,
249                 "[%s:%s] Failed to create curses window via newwin()\n", mn,
250                 rn);
251         free(newgwin);
252         free(c_data);
253         return (NULL);
254     }
255
256     /*
257      * Now, fill in the curses-specific window info.
258      */
259     c_data->wp = newcursgwin;
260     c_data->charwidth = params->charwidth;
261     c_data->charheight = params->charheight;
262     c_data->box_vertchar = params->box_vertchar;
263     c_data->box_horizchar = params->box_horizchar;
264
265     /*
266      * Plug in a frame at the top-level.
267      */
268     newgwin->w_frame = gtxframe_Create();
269
270     /*
271      * Plug the curses private data into the generic window object, then
272      * return the new window's info.
273      */
274     newgwin->w_data = (int *)c_data;
275     return (newgwin);
276
277 }                               /*gator_cursesgwin_create */
278
279 /*------------------------------------------------------------------------
280  * gator_cursesgwin_cleanup
281  *
282  * Description:
283  *      Clean up, probably right before the caller exits.
284  *
285  * Arguments:
286  *      struct gwin *gwp : Ptr to base window.
287  *
288  * Returns:
289  *      0 on success,
290  *      Error value otherwise.
291  *
292  * Environment:
293  *      Nothing interesting.
294  *
295  * Side Effects:
296  *      As advertised.
297  *------------------------------------------------------------------------*/
298
299 int
300 gator_cursesgwin_cleanup(struct gwin *gwp)
301 {                               /*gator_cursesgwin_cleanup */
302
303     static char rn[] = "gator_cursesgwin_cleanup";      /*Routine name */
304     struct gator_cursesgwin *cwp;       /*Curses private area ptr */
305
306     cwp = (struct gator_cursesgwin *)(gwp->w_data);
307
308     /*
309      * Cleaning up in curses is extremely easy - one simple call.  We also
310      * want to clear the screen before we go.
311      */
312     if (curses_debug)
313         fprintf(stderr, "[%s:%s] Calling wclear() on window at %p\n", mn,
314                 rn, cwp->wp);
315     wclear(cwp->wp);
316     wrefresh(cwp->wp);
317
318     /*
319      * Now, set the terminal back into normal mode.
320      */
321     noraw();
322
323     if (curses_debug)
324         fprintf(stderr, "[%s:%s] Calling endwin()\n", mn, rn);
325     endwin();
326
327     return (0);
328
329 }                               /*gator_cursesgwin_cleanup */
330
331 /*------------------------------------------------------------------------
332  * gator_cursesgwin_box
333  *
334  * Description:
335  *      Draw a box around the given curses window.
336  *
337  * Arguments:
338  *      struct gwin *gwp : Ptr to the curses window to draw
339  *                         a box around.
340  *
341  * Returns:
342  *      0 on success,
343  *      Error value otherwise.
344  *
345  * Environment:
346  *      Nothing interesting.
347  *
348  * Side Effects:
349  *      As advertised.
350  *------------------------------------------------------------------------*/
351
352 int
353 gator_cursesgwin_box(struct gwin *gwp)
354 {                               /*gator_cursesgwin_box */
355
356     static char rn[] = "gator_cursesgwin_box";  /*Routine name */
357     struct gator_cursesgwin *cwp;       /*Ptr to curses private area */
358
359     cwp = (struct gator_cursesgwin *)(gwp->w_data);
360     if (curses_debug)
361         fprintf(stderr, "[%s:%s] Calling box() on window at %p\n", mn, rn,
362                 cwp->wp);
363     box(cwp->wp, cwp->box_vertchar, cwp->box_horizchar);
364
365     return (0);
366
367 }                               /*gator_cursesgwin_box */
368
369 /*------------------------------------------------------------------------
370  * gator_cursesgwin_clear
371  *
372  * Description:
373  *      Clear out the given curses window.
374  *
375  * Arguments:
376  *      struct gwin *gwp : Ptr to the curses window to clear out.
377  *
378  * Returns:
379  *      0 on success,
380  *      Error value otherwise.
381  *
382  * Environment:
383  *      Nothing interesting.
384  *
385  * Side Effects:
386  *      As advertised.
387  *------------------------------------------------------------------------*/
388
389 int
390 gator_cursesgwin_clear(struct gwin *gwp)
391 {                               /*gator_cursesgwin_clear */
392
393     static char rn[] = "gator_cursesgwin_clear";        /*Routine name */
394     struct gator_cursesgwin *cwp;       /*Ptr to curses private area */
395
396     /*
397      * Clearing windows is very easy in curses; just one call will do it.
398      */
399     cwp = (struct gator_cursesgwin *)(gwp->w_data);
400     if (curses_debug)
401         fprintf(stderr, "[%s:%s] Calling wclear() on window at %p\n", mn,
402                 rn, cwp->wp);
403     wclear(cwp->wp);
404
405     return (0);
406
407 }                               /*gator_cursesgwin_clear */
408
409 /*------------------------------------------------------------------------
410  * gator_cursesgwin_destroy
411  *
412  * Description:
413  *      Destroy the given curses window.
414  *
415  * Arguments:
416  *      struct gwin *gwp : Ptr to the curses window to destroy.
417  *
418  * Returns:
419  *      0 on success,
420  *      Error value otherwise.
421  *
422  * Environment:
423  *      Nothing interesting.
424  *
425  * Side Effects:
426  *      As advertised.
427  *------------------------------------------------------------------------*/
428
429 int
430 gator_cursesgwin_destroy(struct gwin *gwp)
431 {                               /*gator_cursesgwin_destroy */
432
433     static char rn[] = "gator_cursesgwin_destroy";      /*Routine name */
434     struct gator_cursesgwin *cwp;       /*Ptr to curses private area */
435
436     cwp = (struct gator_cursesgwin *)(gwp->w_data);
437     if (curses_debug)
438         fprintf(stderr, "[%s:%s] Calling delwin() on window at %p\n", mn,
439                 rn, cwp->wp);
440     delwin(cwp->wp);
441
442     return (0);
443
444 }                               /*gator_cursesgwin_destroy */
445
446 /*------------------------------------------------------------------------
447  * gator_cursesgwin_display
448  *
449  * Description:
450  *      Display/redraw the given curses window.
451  *
452  * Arguments:
453  *      struct gwin *gwp : Ptr to the curses window to draw.
454  *
455  * Returns:
456  *      0 on success,
457  *      Error value otherwise.
458  *
459  * Environment:
460  *      Nothing interesting.
461  *
462  * Side Effects:
463  *      As advertised.
464  *------------------------------------------------------------------------*/
465
466 int
467 gator_cursesgwin_display(struct gwin *gwp)
468 {                               /*gator_cursesgwin_display */
469
470     struct gator_cursesgwin *cwp;       /*Curses private area ptr */
471
472     cwp = (struct gator_cursesgwin *)(gwp->w_data);
473
474     wclear(cwp->wp);            /* clear screen */
475     gtxframe_Display(gwp->w_frame, gwp);        /* display the frame */
476     wrefresh(cwp->wp);          /* redraw the guy */
477     return (0);
478
479 }                               /*gator_cursesgwin_display */
480
481 /*------------------------------------------------------------------------
482  * gator_cursesgwin_drawline
483  *
484  * Description:
485  *      Draw a line between two points in the given curses
486  *      window.
487  *
488  * Arguments:
489  *      struct gwin *gwp : Ptr to the curses window in which
490  *                                 the line is to be drawn.
491  *      struct gwin_lineparams *params : Ptr to other params.
492  *
493  * Returns:
494  *      0 on success,
495  *      Error value otherwise.
496  *
497  * Environment:
498  *      Nothing interesting.
499  *
500  * Side Effects:
501  *      As advertised.
502  *------------------------------------------------------------------------*/
503
504 int
505 gator_cursesgwin_drawline(struct gwin *gwp, struct gwin_lineparams *params)
506 {                               /*gator_cursesgwin_drawline */
507
508     static char rn[] = "gator_cursesgwin_drawline";     /*Routine name */
509
510     if (curses_debug)
511         fprintf(stderr, "[%s:%s] This routine is currently a no-op\n", mn,
512                 rn);
513
514     return (0);
515
516 }                               /*gator_cursesgwin_drawline */
517
518 /*------------------------------------------------------------------------
519  * gator_cursesgwin_drawrectangle
520  *
521  * Description:
522  *      Draw a rectangle in the given curses window.
523  *
524  * Arguments:
525  *      struct gwin *gwp : Ptr to the curses window in which
526  *                                 the rectangle is to be drawn.
527  *      struct gwin_rectparams *params : Ptr to other params.
528  *
529  * Returns:
530  *      0 on success,
531  *      Error value otherwise.
532  *
533  * Environment:
534  *      Nothing interesting.
535  *
536  * Side Effects:
537  *      As advertised.
538  *------------------------------------------------------------------------*/
539
540 int
541 gator_cursesgwin_drawrectangle(struct gwin *gwp, struct gwin_rectparams *params)
542 {                               /*gator_cursesgwin_drawrectangle */
543
544     static char rn[] = "gator_cursesgwin_drawrectangle";        /*Routine name */
545
546     if (curses_debug)
547         fprintf(stderr, "[%s:%s] This routine is currently a no-op\n", mn,
548                 rn);
549
550     return (0);
551
552 }                               /*gator_cursesgwin_drawrectangle */
553
554 /*------------------------------------------------------------------------
555  * gator_cursesgwin_drawchar
556  *
557  * Description:
558  *      Draw a character in the given curses window.
559  *
560  * Arguments:
561  *      struct gwin *gwp : Ptr to the curses window in which
562  *                                 the character is to be drawn.
563  *      struct gwin_charparams *params : Ptr to other params.
564  *
565  * Returns:
566  *      0 on success,
567  *      Error value otherwise.
568  *
569  * Environment:
570  *      Nothing interesting.
571  *
572  * Side Effects:
573  *      As advertised.
574  *------------------------------------------------------------------------*/
575
576 int
577 gator_cursesgwin_drawchar(struct gwin *gwp, struct gwin_charparams *params)
578 {                               /*gator_cursesgwin_drawchar */
579
580     static char rn[] = "gator_cursesgwin_drawchar";     /*Routine name */
581     struct gator_cursesgwin *cwp;       /*Ptr to curses private area */
582     int curses_x, curses_y;     /*Mapped x,y positions */
583
584     cwp = (struct gator_cursesgwin *)(gwp->w_data);
585     curses_x = GATOR_MAP_X_TO_COL(cwp, params->x);
586     curses_y = GATOR_MAP_Y_TO_LINE(cwp, params->y);
587     if (curses_debug)
588         fprintf(stderr,
589                 "[%s:%s] Drawing char '%c' on window at %p at (%d, %d) [line %d, column %d]%s\n",
590                 mn, rn, params->c, cwp->wp, params->x, params->y, curses_y,
591                 curses_x, (params->highlight ? ", using standout mode" : ""));
592     wmove(cwp->wp, curses_y, curses_x);
593     if (params->highlight)
594         wstandout(cwp->wp);
595     waddch(cwp->wp, params->c);
596     if (params->highlight)
597         wstandend(cwp->wp);
598
599     return (0);
600
601 }                               /*gator_cursesgwin_drawchar */
602
603 /*------------------------------------------------------------------------
604  * gator_cursesgwin_drawstring
605  *
606  * Description:
607  *      Draw a string in the given curses window.
608  *
609  * Arguments:
610  *      struct gwin *gwp : Ptr to the curses window in which
611  *                                 the string is to be drawn.
612  *      struct gwin_strparams *params : Ptr to other params.
613  *
614  * Returns:
615  *      0 on success,
616  *      Error value otherwise.
617  *
618  * Environment:
619  *      Nothing interesting.
620  *
621  * Side Effects:
622  *      As advertised.
623  *------------------------------------------------------------------------*/
624
625 int
626 gator_cursesgwin_drawstring(struct gwin *gwp, struct gwin_strparams *params)
627 {                               /*gator_cursesgwin_drawstring */
628
629     static char rn[] = "gator_cursesgwin_drawstring";   /*Routine name */
630     struct gator_cursesgwin *cwp;       /*Ptr to curses private area */
631     int curses_x, curses_y;     /*Mapped x,y positions */
632
633     cwp = (struct gator_cursesgwin *)(gwp->w_data);
634     curses_x = GATOR_MAP_X_TO_COL(cwp, params->x);
635     curses_y = GATOR_MAP_Y_TO_LINE(cwp, params->y);
636     if (curses_debug)
637         fprintf(stderr,
638                 "[%s:%s] Drawing string '%s' on window at %p at (%d, %d) [line %d, column %d]%s\n",
639                 mn, rn, params->s, cwp->wp, params->x, params->y, curses_y,
640                 curses_x, (params->highlight ? ", using standout mode" : ""));
641     wmove(cwp->wp, curses_y, curses_x);
642     if (params->highlight)
643         wstandout(cwp->wp);
644     waddstr(cwp->wp, params->s);
645     if (params->highlight)
646         wstandend(cwp->wp);
647
648     return (0);
649
650 }                               /*gator_cursesgwin_drawstring */
651
652 /*------------------------------------------------------------------------
653  * gator_cursesgwin_invert
654  *
655  * Description:
656  *      Invert a region in the given curses window.
657  *
658  * Arguments:
659  *      struct gwin *gwp : Ptr to the curses window in which
660  *                                 the inverted region lies.
661  *      struct gwin_invparams *params : Ptr to other params.
662  *
663  * Returns:
664  *      0 on success,
665  *      Error value otherwise.
666  *
667  * Environment:
668  *      Nothing interesting.
669  *
670  * Side Effects:
671  *      As advertised.
672  *------------------------------------------------------------------------*/
673
674 int
675 gator_cursesgwin_invert(struct gwin *gwp, struct gwin_invparams *params)
676 {                               /*gator_cursesgwin_invert */
677
678     static char rn[] = "gator_cursesgwin_invert";       /*Routine name */
679
680     if (curses_debug)
681         fprintf(stderr, "[%s:%s] This routine is currently a no-op\n", mn,
682                 rn);
683
684     return (0);
685
686 }                               /*gator_cursesgwin_invert */
687
688 /*------------------------------------------------------------------------
689  * gator_cursesgwin_getchar
690  *
691  * Description:
692  *      Pick up a character from the given window.
693  *
694  * Arguments:
695  *      struct gwin *gwp : Ptr to the curses window to listen to.
696  *
697  * Returns:
698  *      Value of the character read,
699  *      -1 otherwise.
700  *
701  * Environment:
702  *      Nothing interesting.
703  *
704  * Side Effects:
705  *      As advertised.
706  *------------------------------------------------------------------------*/
707
708 int
709 gator_cursesgwin_getchar(struct gwin *gwp)
710 {                               /*gator_cursesgwin_getchar */
711
712     return (getc(stdin));
713
714 }                               /*gator_cursesgwin_getchar */
715
716 /*------------------------------------------------------------------------
717  * gator_cursesgwin_wait
718  *
719  * Description:
720  *      Wait until input is available.
721  *
722  * Arguments:
723  *      struct gwin *gwp : Ptr to the curses window to wait on.
724  *
725  * Returns:
726  *      0 on success,
727  *      Error value otherwise.
728  *
729  * Environment:
730  *      Nothing interesting.
731  *
732  * Side Effects:
733  *      As advertised.
734  *------------------------------------------------------------------------*/
735
736 int
737 gator_cursesgwin_wait(struct gwin *gwp)
738 {                               /*gator_cursesgwin_wait */
739
740     while (!LWP_WaitForKeystroke(-1));
741
742     return (0);
743
744 }                               /*gator_cursesgwin_wait */
745
746 /*------------------------------------------------------------------------
747  * gator_cursesgwin_getdimensions
748  *
749  * Description:
750  *      Get the window's X,Y dimensions.
751  *
752  * Arguments:
753  *      struct gwin *gwp               : Ptr to the curses window to examine.
754  *      struct gwin_sizeparams *params : Ptr to the size params to set.
755  *
756  * Returns:
757  *      0 on success,
758  *      Error value otherwise.
759  *
760  * Environment:
761  *      Nothing interesting.
762  *
763  * Side Effects:
764  *      As advertised.
765  *------------------------------------------------------------------------*/
766
767 int
768 gator_cursesgwin_getdimensions(struct gwin *gwp, struct gwin_sizeparams *aparms)
769 {                               /*gator_cursesgwin_getdimensions */
770
771     struct gator_cursesgwin *cwp;       /*Curses-specific data */
772
773     cwp = (struct gator_cursesgwin *)(gwp->w_data);
774 #if defined(AFS_DARWIN_ENV) && !defined(AFS_DARWIN60_ENV)
775     aparms->maxx = cwp->wp->maxx;
776     aparms->maxy = cwp->wp->maxy;
777 #elif defined(AFS_NBSD_ENV)
778     aparms->maxx = getmaxx(cwp->wp);
779     aparms->maxy = getmaxy(cwp->wp);
780 #else
781     aparms->maxx = cwp->wp->_maxx;
782     aparms->maxy = cwp->wp->_maxy;
783 #endif
784
785     return (0);
786
787 }                               /*gator_cursesgwin_getdimensions */