11 |
|
*/ |
12 |
|
|
13 |
|
#include <stdio.h> |
14 |
+ |
#include <math.h> |
15 |
|
|
15 |
– |
#include <sys/ioctl.h> |
16 |
– |
|
16 |
|
#include <X/Xlib.h> |
17 |
|
#include <X/cursors/bcross.cursor> |
18 |
|
#include <X/cursors/bcross_mask.cursor> |
60 |
|
|
61 |
|
extern char *progname; |
62 |
|
|
63 |
< |
int x_close(), x_clear(), x_paintr(), x_errout(), |
63 |
> |
static int x_close(), x_clear(), x_paintr(), x_errout(), |
64 |
|
x_getcur(), x_comout(), x_comin(), x_flush(); |
65 |
|
|
66 |
|
static struct driver x_driver = { |
73 |
|
x_init(name, id) /* initialize driver */ |
74 |
|
char *name, *id; |
75 |
|
{ |
76 |
+ |
extern char *getenv(); |
77 |
+ |
char *gv; |
78 |
|
char defgeom[32]; |
79 |
|
OpaqueFrame mainframe; |
80 |
|
|
87 |
|
stderr_v("not enough colors\n"); |
88 |
|
return(NULL); |
89 |
|
} |
90 |
< |
make_gmap(GAMMA); /* make color map */ |
90 |
> |
/* make color map */ |
91 |
> |
if ((gv = getenv("GAMMA")) != NULL) |
92 |
> |
make_gmap(atof(gv)); |
93 |
> |
else |
94 |
> |
make_gmap(GAMMA); |
95 |
|
|
96 |
|
pickcursor = XCreateCursor(bcross_width, bcross_height, |
97 |
|
bcross_bits, bcross_mask_bits, |
151 |
|
int xres, yres; |
152 |
|
{ |
153 |
|
if (xres != gwidth || yres != gheight) { /* new window */ |
149 |
– |
if (comline != NULL) |
150 |
– |
xt_close(comline); |
154 |
|
XChangeWindow(gwind, xres, yres+COMHEIGHT); |
152 |
– |
comline = xt_open(gwind, 0, yres, xres, COMHEIGHT, 0, COMFN); |
153 |
– |
if (comline == NULL) { |
154 |
– |
stderr_v("Cannot open command line window\n"); |
155 |
– |
quit(1); |
156 |
– |
} |
155 |
|
gwidth = xres; |
156 |
|
gheight = yres; |
157 |
|
} else /* just clear */ |
161 |
|
stderr_v("cannot allocate colors\n"); |
162 |
|
else |
163 |
|
new_ctab(ncolors); |
164 |
< |
|
164 |
> |
/* open new command line */ |
165 |
> |
if (comline != NULL) |
166 |
> |
xt_close(comline); |
167 |
> |
comline = xt_open(gwind, 0, yres, xres, COMHEIGHT, 0, COMFN); |
168 |
> |
if (comline == NULL) { |
169 |
> |
stderr_v("Cannot open command line window\n"); |
170 |
> |
quit(1); |
171 |
> |
} |
172 |
|
XMapWindow(gwind); /* make sure it's mapped */ |
173 |
|
XSync(1); /* discard input */ |
174 |
|
return; |
204 |
|
x_comin(inp, prompt) /* read in a command line */ |
205 |
|
char *inp, *prompt; |
206 |
|
{ |
207 |
< |
int x_getc(), x_comout(); |
207 |
> |
extern int x_getc(); |
208 |
|
|
209 |
|
if (prompt != NULL) |
210 |
|
if (fromcombuf(inp, &x_driver)) |
221 |
|
x_comout(out) /* output a string to command line */ |
222 |
|
char *out; |
223 |
|
{ |
224 |
< |
if (comline != NULL) |
225 |
< |
xt_puts(out, comline); |
226 |
< |
XFlush(); |
224 |
> |
if (comline == NULL) |
225 |
> |
return; |
226 |
> |
xt_puts(out, comline); |
227 |
> |
if (out[strlen(out)-1] == '\n') |
228 |
> |
XFlush(); |
229 |
|
} |
230 |
|
|
231 |
|
|
233 |
|
x_errout(msg) /* output an error message */ |
234 |
|
char *msg; |
235 |
|
{ |
229 |
– |
x_comout(msg); |
236 |
|
stderr_v(msg); /* send to stderr also! */ |
237 |
+ |
x_comout(msg); |
238 |
|
} |
239 |
|
|
240 |
|
|