41 |
|
|
42 |
|
#define hashcolr(c) ((67*(c)[RED]+59*(c)[GRN]+71*(c)[BLU])%ncolors) |
43 |
|
|
44 |
< |
#define flush() while (XPending() > 0) getevent() |
44 |
> |
#define checkinp() while (XPending() > 0) getevent() |
45 |
|
|
46 |
|
#define levptr(etype) ((etype *)&thisevent) |
47 |
|
|
67 |
|
|
68 |
|
static TEXTWIND *comline = NULL; /* our command line */ |
69 |
|
|
70 |
– |
static int c_erase, c_kill; /* erase and kill characters */ |
71 |
– |
|
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 |
|
{ |
92 |
– |
struct sgttyb ttymode; |
93 |
– |
|
94 |
– |
if (isatty(0)) { |
95 |
– |
ioctl(0, TIOCGETP, &ttymode); |
96 |
– |
c_erase = ttymode.sg_erase; |
97 |
– |
c_kill = ttymode.sg_kill; |
98 |
– |
} else { |
99 |
– |
c_erase = 'H'-'@'; |
100 |
– |
c_kill = 'U'-'@'; |
101 |
– |
} |
90 |
|
ourdisplay = XOpenDisplay(NULL); |
91 |
|
if (ourdisplay == NULL) { |
92 |
|
stderr_v("cannot open X-windows; DISPLAY variable set?\n"); |
105 |
|
BlackPixel, WhitePixel, GXcopy); |
106 |
|
clientname = name; |
107 |
|
x_driver.inpready = 0; |
108 |
< |
errvec = x_errout; /* set error vectors */ |
121 |
< |
cmdvec = x_comout; |
108 |
> |
cmdvec = x_comout; /* set error vectors */ |
109 |
|
if (wrnvec != NULL) |
110 |
|
wrnvec = x_errout; |
111 |
|
return(&x_driver); |
115 |
|
static |
116 |
|
x_close() /* close our display */ |
117 |
|
{ |
118 |
< |
errvec = stderr_v; /* reset error vectors */ |
132 |
< |
cmdvec = NULL; |
118 |
> |
cmdvec = NULL; /* reset error vectors */ |
119 |
|
if (wrnvec != NULL) |
120 |
|
wrnvec = stderr_v; |
121 |
|
if (ourdisplay == NULL) |
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 |
|
} |
197 |
|
} |
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 |
|
|
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 */ |