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