41 |
|
|
42 |
|
#define hashcolr(c) ((67*(c)[RED]+59*(c)[GRN]+71*(c)[BLU])%ncolors) |
43 |
|
|
44 |
< |
#define flush() XFlush() |
44 |
> |
#define checkinp() while (XPending() > 0) getevent() |
45 |
|
|
46 |
– |
#define checkinp() while (QLength() > 0) getevent() |
47 |
– |
|
46 |
|
#define levptr(etype) ((etype *)&thisevent) |
47 |
|
|
48 |
|
static char *clientname; /* calling client's name */ |
67 |
|
|
68 |
|
static TEXTWIND *comline = NULL; /* our command line */ |
69 |
|
|
72 |
– |
static int c_erase, c_kill; /* erase and kill characters */ |
73 |
– |
|
70 |
|
static char c_queue[64]; /* input queue */ |
71 |
|
static int c_first = 0; /* first character in queue */ |
72 |
|
static int c_last = 0; /* last character in queue */ |
87 |
|
x_init(name) /* initialize driver */ |
88 |
|
char *name; |
89 |
|
{ |
94 |
– |
struct sgttyb ttymode; |
95 |
– |
|
96 |
– |
if (isatty(0)) { |
97 |
– |
ioctl(0, TIOCGETP, &ttymode); |
98 |
– |
c_erase = ttymode.sg_erase; |
99 |
– |
c_kill = ttymode.sg_kill; |
100 |
– |
} else { |
101 |
– |
c_erase = 'H'-'@'; |
102 |
– |
c_kill = 'U'-'@'; |
103 |
– |
} |
90 |
|
ourdisplay = XOpenDisplay(NULL); |
91 |
|
if (ourdisplay == NULL) { |
92 |
|
stderr_v("cannot open X-windows; DISPLAY variable set?\n"); |
162 |
|
} else /* just clear */ |
163 |
|
XClear(gwind); |
164 |
|
newmap(); |
165 |
< |
flush(); |
165 |
> |
checkinp(); |
166 |
|
return; |
167 |
|
fail: |
168 |
|
stderr_v("Failure opening window in x_clear\n"); |
189 |
|
pixval[ndx]); |
190 |
|
} |
191 |
|
if (nrays - lastflush >= WFLUSH) { |
192 |
< |
flush(); |
192 |
> |
if (ncolors <= 0) /* output necessary for death */ |
193 |
> |
XPixSet(gwind,0,0,1,1,BlackPixel); |
194 |
> |
checkinp(); |
195 |
|
lastflush = nrays; |
196 |
|
} |
209 |
– |
checkinp(); |
197 |
|
} |
198 |
|
|
199 |
|
|
204 |
|
int x_getc(), x_comout(); |
205 |
|
|
206 |
|
xt_cursor(comline, TBLKCURS); |
207 |
< |
editline(inp, x_getc, x_comout, c_erase, c_kill); |
207 |
> |
editline(inp, x_getc, x_comout); |
208 |
|
xt_cursor(comline, TNOCURS); |
209 |
|
} |
210 |
|
|
215 |
|
{ |
216 |
|
if (comline != NULL) |
217 |
|
xt_puts(out, comline); |
218 |
< |
flush(); |
218 |
> |
XFlush(); |
219 |
|
} |
220 |
|
|
221 |
|
|
242 |
|
*yp = gheight-1 - levptr(XKeyOrButtonEvent)->y; |
243 |
|
XFocusKeyboard(RootWindow); |
244 |
|
XUngrabMouse(); |
245 |
< |
flush(); /* insure release */ |
245 |
> |
XFlush(); /* insure release */ |
246 |
|
if (c_last > c_first) /* key pressed */ |
247 |
|
return(x_getc()); |
248 |
|
/* button pressed */ |