330be0dd9c34a27c5639c64d0d47047302715695
[openafs.git] / src / gtx / input.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 #define IGNORE_STDS_H
11 #include <afs/param.h>
12 #include <afsconfig.h>
13
14 RCSID("$Header$");
15
16 #ifdef AFS_HPUX_ENV
17 #include <sys/types.h>
18 #endif
19 #include <lwp.h>
20
21 #include "gtxobjects.h"
22 #include "gtxwindows.h"
23 #include "gtxcurseswin.h"
24 #include "gtxinput.h"
25 #include "gtxkeymap.h"
26 #include "gtxframe.h"
27 #include <afs/stds.h>
28
29
30 /* process input */
31 gtx_InputServer(awin)
32 register struct gwin *awin; {
33     register int tc;
34     register int code;
35     register struct gtx_frame *tframe;
36
37     WOP_DISPLAY(awin);  /* start off with a clean display */
38     while (1) {
39         /* get a character from the generic window */
40         tframe = awin->w_frame;
41         code = WOP_WAIT(awin);
42         if (code) {
43             printf("***WAIT FAILURE %d****\n", code);
44             exit(1);
45         }
46         tc = WOP_GETCHAR(awin);
47         tframe->flags &= ~GTXFRAME_NEWDISPLAY;  /* OK to clear now */
48         if (tc < 0) break;      /* EOF or some such */
49         /* otherwise, process the character and go get a new one */
50         gtxframe_ClearMessageLine(tframe);
51         tframe->flags &= ~(GTXFRAME_RECURSIVEEND | GTXFRAME_RECURSIVEERR);
52         keymap_ProcessKey(tframe->keystate, tc, awin);
53         tframe = awin->w_frame; /* in case command changed it */
54         if (tframe->flags & GTXFRAME_RECURSIVEEND) {
55             tframe->flags &= ~GTXFRAME_RECURSIVEEND;
56             return 0;
57         }
58         tframe->flags &= ~GTXFRAME_RECURSIVEEND;
59         WOP_DISPLAY(awin);      /* eventually calls gtxframe_Display */
60     }
61 }
62
63 struct gwin *gtx_Init(astartInput, atype)
64 int atype;                                      /* type of window to create */
65 int astartInput; {
66     PROCESS junk;
67     struct onode_initparams oi_params;          /* object init params*/
68     struct gwin_initparams wi_params;           /* window initialization params*/
69     register struct gwin *twin;
70     register int code;
71
72     /* setup the main window structure */
73     wi_params.i_type   = GATOR_WIN_CURSES;
74     wi_params.i_x      =   0;
75     wi_params.i_y      =   0;
76     wi_params.i_width  =  80;
77     wi_params.i_height = 200;
78     wi_params.i_debug  = 0;     /* or 1 if we want debugging done */
79
80     /*
81      * Set up the basic onode initialization parameters, throwing in
82      * the graphics-specific stuff.
83      */
84     oi_params.i_debug = 0;      /* or 1 if we want debugging */
85     oi_params.i_gwparams = &wi_params;
86
87     code = gator_objects_init(&oi_params);
88     if (code) return (struct gwin *) 0;
89     
90     /* if we start input thread */
91     IOMGR_Initialize(); /* input thread uses it */
92     if (astartInput)
93         code = LWP_CreateProcess(gtx_InputServer, 8192, LWP_NORMAL_PRIORITY,
94                                  0, "gx-listener", &junk);
95     /* all done */
96     twin = &gator_basegwin;
97     return twin;
98 }