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