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