version 1.1.1.1, 2000/01/09 17:00:51 |
version 1.1.1.3, 2003/09/15 07:09:27 |
Line 257 double xscale, yscale, pointsize; |
|
Line 257 double xscale, yscale, pointsize; |
|
|
|
#define Nbuf 1024 |
#define Nbuf 1024 |
char buf[Nbuf], **commands = (char **) 0; |
char buf[Nbuf], **commands = (char **) 0; |
|
static int buffered_input_available = 0; |
|
|
FILE *X11_ipc; |
FILE *X11_ipc; |
char X11_ipcpath[32]; |
char X11_ipcpath[32]; |
Line 275 XSegment Plus[2], Cross[2], Star[4]; |
|
Line 276 XSegment Plus[2], Cross[2], Star[4]; |
|
* main program |
* main program |
*---------------------------------------------------------------------------*/ |
*---------------------------------------------------------------------------*/ |
|
|
int main(argc, argv) |
int |
|
main(argc, argv) |
int argc; |
int argc; |
char *argv[]; |
char *argv[]; |
{ |
{ |
|
|
mainloop(); |
mainloop(); |
|
|
if (persist) { |
if (persist) { |
FPRINTF((stderr, "waiting for %d windows\n, windows_open")); |
FPRINTF((stderr, "waiting for %d windows\n", windows_open)); |
/* read x events until all windows have been quit */ |
/* read x events until all windows have been quit */ |
while (windows_open > 0) { |
while (windows_open > 0) { |
XEvent event; |
XEvent event; |
|
|
* DEFAULT_X11 mainloop |
* DEFAULT_X11 mainloop |
*---------------------------------------------------------------------------*/ |
*---------------------------------------------------------------------------*/ |
|
|
void mainloop() |
void |
|
mainloop() |
{ |
{ |
int nf, nfds, cn = ConnectionNumber(dpy), in; |
int nf, cn = ConnectionNumber(dpy), in; |
struct timeval *timer = (struct timeval *) 0; |
fd_set_size_t nfds; |
#ifdef ISC22 |
struct timeval timeout, *timer = (struct timeval *) 0; |
struct timeval timeout; |
fd_set tset; |
#endif |
|
fd_set rset, tset; |
|
|
|
X11_ipc = stdin; |
X11_ipc = stdin; |
in = fileno(X11_ipc); |
in = fileno(X11_ipc); |
|
|
FD_ZERO(&rset); |
|
FD_SET(cn, &rset); |
|
|
|
FD_SET(in, &rset); |
|
nfds = (cn > in) ? cn + 1 : in + 1; |
|
|
|
#ifdef ISC22 |
#ifdef ISC22 |
/* Added by Robert Eckardt, RobertE@beta.TP2.Ruhr-Uni-Bochum.de */ |
/* Added by Robert Eckardt, RobertE@beta.TP2.Ruhr-Uni-Bochum.de */ |
timeout.tv_sec = 0; /* select() in ISC2.2 needs timeout */ |
timeout.tv_sec = 0; /* select() in ISC2.2 needs timeout */ |
|
|
|
|
XFlush(dpy); |
XFlush(dpy); |
|
|
tset = rset; |
FD_ZERO(&tset); |
nf = select((gp_nfds_t)nfds, gp_fd_set_p &tset, gp_fd_set_p 0, |
FD_SET(cn, &tset); |
gp_fd_set_p 0, gp_timeval_p timer); |
|
|
/* Don't wait for events if we know that input is |
|
* already sitting in a buffer. Also don't wait for |
|
* input to become available. |
|
*/ |
|
if (buffered_input_available) { |
|
timeout.tv_sec = 0; |
|
timeout.tv_usec = 0; |
|
timer = &timeout; |
|
} else { |
|
timer = (struct timeval *) 0; |
|
FD_SET(in, &tset); |
|
} |
|
|
|
nfds = (cn > in) ? cn + 1 : in + 1; |
|
|
|
nf = select(nfds, SELECT_FD_SET_CAST &tset, 0, 0, timer); |
|
|
if (nf < 0) { |
if (nf < 0) { |
if (errno == EINTR) |
if (errno == EINTR) |
continue; |
continue; |
fprintf(stderr, "gnuplot: select failed. errno:%d\n", errno); |
fprintf(stderr, "gnuplot: select failed. errno:%d\n", errno); |
EXIT(1); |
EXIT(1); |
} |
} |
|
|
if (nf > 0) |
if (nf > 0) |
XNoOp(dpy); |
XNoOp(dpy); |
|
|
|
|
process_event(&xe); |
process_event(&xe); |
} while (XPending(dpy)); |
} while (XPending(dpy)); |
} |
} |
if (FD_ISSET(in, &tset)) { |
|
if (!record()) /* end of input */ |
if (FD_ISSET(in, &tset) || buffered_input_available) { |
|
if (!record()) /* end of input */ |
return; |
return; |
} |
} |
} |
} |
} |
} |
|
|
#endif |
|
|
|
|
#elif defined(CRIPPLED_SELECT) |
#ifdef CRIPPLED_SELECT |
|
/*----------------------------------------------------------------------------- |
/*----------------------------------------------------------------------------- |
* CRIPPLED_SELECT mainloop |
* CRIPPLED_SELECT mainloop |
*---------------------------------------------------------------------------*/ |
*---------------------------------------------------------------------------*/ |
|
|
void mainloop() |
void |
|
mainloop() |
{ |
{ |
int nf, nfds, cn = ConnectionNumber(dpy); |
fd_set_size_t nf, nfds, cn = ConnectionNumber(dpy); |
struct timeval timeout, *timer; |
struct timeval timeout, *timer; |
fd_set rset, tset; |
fd_set tset; |
unsigned long all = (unsigned long) (-1L); |
unsigned long all = (unsigned long) (-1L); |
XEvent xe; |
XEvent xe; |
|
|
FD_ZERO(&rset); |
|
FD_SET(cn, &rset); |
|
|
|
timeout.tv_sec = 1; |
timeout.tv_sec = 1; |
timeout.tv_usec = 0; |
timeout.tv_usec = 0; |
timer = &timeout; |
timer = &timeout; |
|
|
|
|
while (1) { |
while (1) { |
XFlush(dpy); /* see above */ |
XFlush(dpy); /* see above */ |
tset = rset; |
|
nf = select((gp_nfds_t)nfds, gp_fd_set_p &tset, gp_fd_set_p 0, |
FD_ZERO(&tset); |
gp_fd_set_p 0, gp_timeval_p timer); |
FD_SET(cn, &tset); |
|
|
|
/* Don't wait for events if we know that input is |
|
* already sitting in a buffer. Also don't wait for |
|
* input to become available. |
|
*/ |
|
if (buffered_input_available) { |
|
timeout.tv_sec = 0; |
|
timeout.tv_usec = 0; |
|
timer = &timeout; |
|
} else { |
|
timer = (struct timeval *) 0; |
|
FD_SET(in, &tset); |
|
} |
|
|
|
nfds = (cn > in) ? cn + 1 : in + 1; |
|
|
|
nf = select(nfds, SELECT_FD_SET_CAST &tset, 0, 0, timer); |
|
|
if (nf < 0) { |
if (nf < 0) { |
if (errno == EINTR) |
if (errno == EINTR) |
continue; |
continue; |
fprintf(stderr, "gnuplot: select failed. errno:%d\n", errno); |
fprintf(stderr, "gnuplot: select failed. errno:%d\n", errno); |
EXIT(1); |
EXIT(1); |
} |
} |
nf > 0 && XNoOp(dpy); |
|
|
if (nf > 0) |
|
XNoOp(dpy); |
|
|
if (FD_ISSET(cn, &tset)) { |
if (FD_ISSET(cn, &tset)) { |
while (XCheckMaskEvent(dpy, all, &xe)) { |
while (XCheckMaskEvent(dpy, all, &xe)) { |
process_event(&xe); |
process_event(&xe); |
|
|
} |
} |
} |
} |
} |
} |
#endif /* CRIPPLED_SELECT */ |
|
|
|
|
|
#ifdef VMS |
#elif defined(VMS) |
/*----------------------------------------------------------------------------- |
/*----------------------------------------------------------------------------- |
* VMS mainloop - Yehavi Bourvine - YEHAVI@VMS.HUJI.AC.IL |
* VMS mainloop - Yehavi Bourvine - YEHAVI@VMS.HUJI.AC.IL |
*---------------------------------------------------------------------------*/ |
*---------------------------------------------------------------------------*/ |
|
|
/* In VMS there is no decent Select(). hence, we have to loop inside |
/* In VMS there is no decent Select(). hence, we have to loop inside |
* XGetNextEvent for getting the next X window event. In order to get input |
* XGetNextEvent for getting the next X window event. In order to get input |
* from the master we assign a channel to SYS$INPUT and use AST's in order to |
* from the master we assign a channel to SYS$INPUT and use AST's in order to |
* receive data. In order to exit the mainloop, we need to somehow make XNextEvent |
* receive data. In order to exit the mainloop, we need to somehow make |
* return from within the ast. We do this with a XSendEvent() to ourselves ! |
* XNextEvent return from within the ast. We do this with a XSendEvent() to |
|
* ourselves ! |
* This needs a window to send the message to, so we create an unmapped window |
* This needs a window to send the message to, so we create an unmapped window |
* for this purpose. Event type XClientMessage is perfect for this, but it |
* for this purpose. Event type XClientMessage is perfect for this, but it |
* appears that such messages come from elsewhere (motif window manager, perhaps ?) |
* appears that such messages come from elsewhere (motif window manager, |
* So we need to check fairly carefully that it is the ast event that has been received. |
* perhaps ?) So we need to check fairly carefully that it is the ast event |
|
* that has been received. |
*/ |
*/ |
|
|
#include <iodef.h> |
#include <iodef.h> |
char STDIIN[] = "SYS$INPUT:"; |
char STDIIN[] = "SYS$INPUT:"; |
short STDIINchannel, STDIINiosb[4]; |
short STDIINchannel, STDIINiosb[4]; |
struct { short size, type; char *address; } STDIINdesc; |
struct { |
|
short size, type; |
|
char *address; |
|
} STDIINdesc; |
char STDIINbuffer[64]; |
char STDIINbuffer[64]; |
int status; |
int status; |
|
|
ast() |
ast() |
{ |
{ |
int status = sys$qio(0, STDIINchannel, IO$_READVBLK, STDIINiosb, record, |
int status = sys$qio(0, STDIINchannel, IO$_READVBLK, STDIINiosb, record, |
0, STDIINbuffer, sizeof(STDIINbuffer) - 1, 0, 0, 0, 0); |
0, STDIINbuffer, sizeof(STDIINbuffer) - 1, 0, 0, 0, 0); |
if ((status & 0x1) == 0) |
if ((status & 0x1) == 0) |
EXIT(status); |
EXIT(status); |
} |
} |
|
|
Window message_window; |
Window message_window; |
|
|
void mainloop() |
void |
|
mainloop() |
{ |
{ |
/* dummy unmapped window for receiving internally-generated terminate |
/* dummy unmapped window for receiving internally-generated terminate |
* messages |
* messages |
|
|
process_event(&xe); |
process_event(&xe); |
} |
} |
} |
} |
|
#else /* !(DEFAULT_X11 || CRIPPLED_SELECT || VMS */ |
|
You lose. No mainloop. |
|
#endif /* !(DEFAULT_X11 || CRIPPLED_SELECT || VMS */ |
|
|
#endif /* VMS */ |
|
|
|
/* delete a window / plot */ |
/* delete a window / plot */ |
|
|
void delete_plot(plot) |
void |
|
delete_plot(plot) |
plot_struct *plot; |
plot_struct *plot; |
{ |
{ |
int i; |
int i; |
Line 559 plot_struct *plot; |
|
Line 597 plot_struct *plot; |
|
|
|
/* prepare the plot structure */ |
/* prepare the plot structure */ |
|
|
void prepare_plot(plot, term_number) |
void |
|
prepare_plot(plot, term_number) |
plot_struct *plot; |
plot_struct *plot; |
int term_number; |
int term_number; |
{ |
{ |
Line 580 int term_number; |
|
Line 619 int term_number; |
|
plot->width = gW; |
plot->width = gW; |
plot->height = gH; |
plot->height = gH; |
} |
} |
|
|
if (!plot->window) { |
if (!plot->window) { |
plot->window = pr_window(plot->posn_flags, plot->x, plot->y, plot->width, plot->height); |
plot->window = pr_window(plot->posn_flags, plot->x, plot->y, plot->width, plot->height); |
++windows_open; |
++windows_open; |
Line 612 int term_number; |
|
Line 650 int term_number; |
|
|
|
/* store a command in a plot structure */ |
/* store a command in a plot structure */ |
|
|
void store_command(buffer, plot) |
void |
|
store_command(buffer, plot) |
char *buffer; |
char *buffer; |
plot_struct *plot; |
plot_struct *plot; |
{ |
{ |
Line 635 plot_struct *plot; |
|
Line 674 plot_struct *plot; |
|
} |
} |
|
|
#ifndef VMS |
#ifndef VMS |
|
|
|
/* Handle input. Use read instead of fgets because stdio buffering |
|
* causes trouble when combined with calls to select. |
|
*/ |
|
int |
|
read_input () |
|
{ |
|
static int rdbuf_size = 10*Nbuf; |
|
static char rdbuf[10*Nbuf-1]; |
|
static int total_chars; |
|
static int rdbuf_offset; |
|
static int buf_offset; |
|
static int partial_read = 0; |
|
int fd = fileno (X11_ipc); |
|
|
|
if (! partial_read) |
|
buf_offset = 0; |
|
|
|
if (! buffered_input_available) { |
|
total_chars = read (fd, rdbuf, rdbuf_size); |
|
buffered_input_available = 1; |
|
partial_read = 0; |
|
rdbuf_offset = 0; |
|
if (total_chars < 0) |
|
return -1; |
|
} |
|
|
|
if (rdbuf_offset < total_chars) { |
|
while (rdbuf_offset < total_chars && buf_offset < Nbuf) { |
|
char c = rdbuf[rdbuf_offset++]; |
|
buf[buf_offset++] = c; |
|
if (c == '\n') |
|
break; |
|
} |
|
|
|
if (buf_offset == Nbuf) { |
|
fputs("\ |
|
\n\ |
|
gnuplot: buffer overflow in read_input!\n\ |
|
gnuplot: X11 aborted.\n", stderr); |
|
EXIT(1); |
|
} else |
|
buf[buf_offset] = NUL; |
|
} |
|
|
|
if (rdbuf_offset == total_chars) { |
|
buffered_input_available = 0; |
|
if (buf[buf_offset-1] != '\n') |
|
partial_read = 1; |
|
} |
|
|
|
return partial_read; |
|
} |
|
|
|
|
/*----------------------------------------------------------------------------- |
/*----------------------------------------------------------------------------- |
* record - record new plot from gnuplot inboard X11 driver (Unix) |
* record - record new plot from gnuplot inboard X11 driver (Unix) |
*---------------------------------------------------------------------------*/ |
*---------------------------------------------------------------------------*/ |
|
|
int record() |
int |
|
record() |
{ |
{ |
static plot_struct *plot = plot_array; |
static plot_struct *plot = plot_array; |
|
|
while (fgets(buf, Nbuf, X11_ipc)) { |
while (1) { |
|
int status = read_input (); |
|
if (status != 0) |
|
return status; |
|
|
switch (*buf) { |
switch (*buf) { |
case 'G': /* enter graphics mode */ |
case 'G': /* enter graphics mode */ |
{ |
{ |
int plot_number = atoi(buf + 1); /* 0 if none specified */ |
int plot_number = atoi(buf + 1); /* 0 if none specified */ |
|
|
if (plot_number < 0 || plot_number >= MAX_WINDOWS) |
if (plot_number < 0 || plot_number >= MAX_WINDOWS) |
plot_number = 0; |
plot_number = 0; |
|
|
continue; |
continue; |
} |
} |
} |
} |
|
|
/* get here if fgets fails */ |
|
|
|
#ifdef OSK |
|
if (feof(X11_ipc)) /* On OS-9 sometimes while resizing the window, */ |
|
_cleareof(X11_ipc); /* and plotting data, the eof or error flag of */ |
|
if (ferror(X11_ipc)) /* X11_ipc stream gets set, while there is */ |
|
clearerr(X11_ipc); /* nothing wrong! Probably a bug in my select()? */ |
|
#else |
|
if (feof(X11_ipc) || ferror(X11_ipc)) |
|
return 0; |
|
#endif /* not OSK */ |
|
|
|
return 1; |
|
} |
} |
|
|
#else /* VMS */ |
#else /* VMS */ |
|
|
* display - display a stored plot |
* display - display a stored plot |
*---------------------------------------------------------------------------*/ |
*---------------------------------------------------------------------------*/ |
|
|
void display(plot) |
void |
|
display(plot) |
plot_struct *plot; |
plot_struct *plot; |
{ |
{ |
int n, x, y, sw, sl, lt = 0, width, type, point, px, py; |
int n, x, y, sw, sl, lt = 0, width, type, point, px, py; |
Line 775 plot_struct *plot; |
|
Line 861 plot_struct *plot; |
|
XFreeGC(dpy, gc); |
XFreeGC(dpy, gc); |
|
|
if (!plot->pixmap) { |
if (!plot->pixmap) { |
FPRINTF((stderr, "Create pixmap %d : %dx%dx%d\n", plot - plot_array, plot->width, plot->height, D)); |
FPRINTF((stderr, "Create pixmap %d : %dx%dx%d\n", plot - plot_array, plot->width, |
|
plot->height, D)); |
plot->pixmap = XCreatePixmap(dpy, root, plot->width, plot->height, D); |
plot->pixmap = XCreatePixmap(dpy, root, plot->width, plot->height, D); |
} |
} |
|
|
gc = XCreateGC(dpy, plot->pixmap, 0, (XGCValues *) 0); |
gc = XCreateGC(dpy, plot->pixmap, 0, (XGCValues *) 0); |
|
|
XSetFont(dpy, gc, font->fid); |
XSetFont(dpy, gc, font->fid); |
Line 846 plot_struct *plot; |
|
Line 932 plot_struct *plot; |
|
* There may be an off-by-one (or more) error here. |
* There may be an off-by-one (or more) error here. |
* style ignored here for the moment |
* style ignored here for the moment |
*/ |
*/ |
ytmp += h; /* top left corner of rectangle to be filled */ |
ytmp += h; /* top left corner of rectangle to be filled */ |
w *= xscale; |
w *= xscale; |
h *= yscale; |
h *= yscale; |
XSetForeground(dpy, gc, colors[0]); |
XSetForeground(dpy, gc, colors[0]); |
Line 1006 plot_struct *plot; |
|
Line 1092 plot_struct *plot; |
|
* reset all cursors (since we dont have a record of the previous terminal #) |
* reset all cursors (since we dont have a record of the previous terminal #) |
*---------------------------------------------------------------------------*/ |
*---------------------------------------------------------------------------*/ |
|
|
void reset_cursor() |
void |
|
reset_cursor() |
{ |
{ |
int plot_number; |
int plot_number; |
plot_struct *plot = plot_array; |
plot_struct *plot = plot_array; |
Line 1028 void reset_cursor() |
|
Line 1115 void reset_cursor() |
|
* resize - rescale last plot if window resized |
* resize - rescale last plot if window resized |
*---------------------------------------------------------------------------*/ |
*---------------------------------------------------------------------------*/ |
|
|
plot_struct *find_plot(window) |
plot_struct * |
|
find_plot(window) |
Window window; |
Window window; |
{ |
{ |
int plot_number; |
int plot_number; |
|
|
return NULL; |
return NULL; |
} |
} |
|
|
void process_event(event) |
void |
|
process_event(event) |
XEvent *event; |
XEvent *event; |
{ |
{ |
FPRINTF((stderr, "Event 0x%x\n", event->type)); |
FPRINTF((stderr, "Event 0x%x\n", event->type)); |
|
|
/*----------------------------------------------------------------------------- |
/*----------------------------------------------------------------------------- |
* preset - determine options, open display, create window |
* preset - determine options, open display, create window |
*---------------------------------------------------------------------------*/ |
*---------------------------------------------------------------------------*/ |
|
/* |
#define On(v) ( !strcmp(v,"on") || !strcmp(v,"true") || \ |
#define On(v) ( !strcmp(v,"on") || !strcmp(v,"true") || \ |
!strcmp(v,"On") || !strcmp(v,"True") || \ |
!strcmp(v,"On") || !strcmp(v,"True") || \ |
!strcmp(v,"ON") || !strcmp(v,"TRUE") ) |
!strcmp(v,"ON") || !strcmp(v,"TRUE") ) |
|
*/ |
|
#define On(v) ( !strnicmp(v,"on",2) || !strnicmp(v,"true",4) ) |
|
|
#define AppDefDir "/usr/lib/X11/app-defaults" |
#define AppDefDir "/usr/lib/X11/app-defaults" |
#ifndef MAXHOSTNAMELEN |
#ifndef MAXHOSTNAMELEN |
Line 1157 static XrmOptionDescRec options[] = { |
|
Line 1248 static XrmOptionDescRec options[] = { |
|
|
|
#define Nopt (sizeof(options) / sizeof(options[0])) |
#define Nopt (sizeof(options) / sizeof(options[0])) |
|
|
void preset(argc, argv) |
void |
|
preset(argc, argv) |
int argc; |
int argc; |
char *argv[]; |
char *argv[]; |
{ |
{ |
|
|
|
|
while (++Argv, --Argc > 0) { |
while (++Argv, --Argc > 0) { |
if (!strcmp(*Argv, "-name") && Argc > 1) { |
if (!strcmp(*Argv, "-name") && Argc > 1) { |
safe_strncpy(Name, Argv[1], sizeof(Name)); |
strncpy(Name, Argv[1], sizeof(Name) - 1); |
safe_strncpy(Class, Argv[1], sizeof(Class)); |
strncpy(Class, Argv[1], sizeof(Class) - 1); |
|
/* just in case */ |
|
Name[sizeof(Name)-1] = NUL; |
|
Class[sizeof(Class)-1] = NUL; |
if (Class[0] >= 'a' && Class[0] <= 'z') |
if (Class[0] >= 'a' && Class[0] <= 'z') |
Class[0] -= 0x20; |
Class[0] -= 0x20; |
} |
} |
Line 1240 gnuplot: X11 aborted.\n", ldisplay); |
|
Line 1335 gnuplot: X11 aborted.\n", ldisplay); |
|
|
|
#ifdef VMS |
#ifdef VMS |
strcpy(buffer, "DECW$USER_DEFAULTS:GNUPLOT_X11.INI"); |
strcpy(buffer, "DECW$USER_DEFAULTS:GNUPLOT_X11.INI"); |
#else |
#elif defined OS2 |
# ifdef OS2 |
|
/* for Xfree86 ... */ |
/* for Xfree86 ... */ |
{ |
{ |
char *appdefdir = "XFree86/lib/X11/app-defaults"; |
char *appdefdir = "XFree86/lib/X11/app-defaults"; |
char *xroot = getenv("X11ROOT"); |
char *xroot = getenv("X11ROOT"); |
sprintf(buffer, "%s/%s/%s", xroot, appdefdir, "Gnuplot"); |
sprintf(buffer, "%s/%s/%s", xroot, appdefdir, "Gnuplot"); |
} |
} |
# else |
# else /* !OS/2 */ |
sprintf(buffer, "%s/%s", AppDefDir, "Gnuplot"); |
strcpy(buffer, AppDefDir); |
# endif /* !OS2 */ |
strcat(buffer, "/"); |
|
strcat(buffer, "Gnuplot"); |
#endif /* !VMS */ |
#endif /* !VMS */ |
|
|
dbApp = XrmGetFileDatabase(buffer); |
dbApp = XrmGetFileDatabase(buffer); |
Line 1264 gnuplot: X11 aborted.\n", ldisplay); |
|
Line 1359 gnuplot: X11 aborted.\n", ldisplay); |
|
#ifdef VMS |
#ifdef VMS |
strcpy(buffer, "DECW$USER_DEFAULTS:DECW$XDEFAULTS.DAT"); |
strcpy(buffer, "DECW$USER_DEFAULTS:DECW$XDEFAULTS.DAT"); |
#else |
#else |
sprintf(buffer, "%s/.Xdefaults", home); |
strcpy(buffer, home); |
|
strcat(buffer, "/.Xdefaults"); |
#endif |
#endif |
dbDef = XrmGetFileDatabase(buffer); |
dbDef = XrmGetFileDatabase(buffer); |
} |
} |
Line 1284 gnuplot: X11 aborted.\n", ldisplay); |
|
Line 1380 gnuplot: X11 aborted.\n", ldisplay); |
|
} |
} |
if ((p = strchr(host, '.')) != NULL) |
if ((p = strchr(host, '.')) != NULL) |
*p = '\0'; |
*p = '\0'; |
sprintf(buffer, "%s/.Xdefaults-%s", home, host); |
strcpy(buffer, home); |
|
strcat(buffer, "/.Xdefaults-"); |
|
strcat(buffer, host); |
dbEnv = XrmGetFileDatabase(buffer); |
dbEnv = XrmGetFileDatabase(buffer); |
} |
} |
XrmMergeDatabases(dbEnv, &db); |
XrmMergeDatabases(dbEnv, &db); |
Line 1311 gnuplot: X11 aborted.\n", ldisplay); |
|
Line 1409 gnuplot: X11 aborted.\n", ldisplay); |
|
*---------------------------------------------------------------------------*/ |
*---------------------------------------------------------------------------*/ |
|
|
char * |
char * |
pr_GetR(xrdb, resource) |
pr_GetR(xrdb, resource) |
XrmDatabase xrdb; |
XrmDatabase xrdb; |
char *resource; |
char *resource; |
{ |
{ |
Line 1322 char *resource; |
|
Line 1420 char *resource; |
|
strcpy(class, Class); |
strcpy(class, Class); |
strcat(class, resource); |
strcat(class, resource); |
rc = XrmGetResource(xrdb, name, class, type, &value) |
rc = XrmGetResource(xrdb, name, class, type, &value) |
? (char *) value.addr |
? (char *) value.addr |
: (char *) 0; |
: (char *) 0; |
return (rc); |
return (rc); |
} |
} |
|
|
Line 1347 char gray_values[Ncolors][30] = { |
|
Line 1445 char gray_values[Ncolors][30] = { |
|
"gray90", "gray50", "gray70", "gray30" |
"gray90", "gray50", "gray70", "gray30" |
}; |
}; |
|
|
void pr_color() |
void |
|
pr_color() |
{ |
{ |
unsigned long black = BlackPixel(dpy, scr), white = WhitePixel(dpy, scr); |
unsigned long black = BlackPixel(dpy, scr), white = WhitePixel(dpy, scr); |
char option[20], color[30], *v, *ctype; |
char option[20], color[30], *v, *ctype; |
Line 1429 char dash_color[Ndashes][10] = { |
|
Line 1528 char dash_color[Ndashes][10] = { |
|
"0", "0", "0", "0", "0", "0", "0", "0" |
"0", "0", "0", "0", "0", "0", "0", "0" |
}; |
}; |
|
|
void pr_dashes() |
void |
|
pr_dashes() |
{ |
{ |
int n, j, l, ok; |
int n, j, l, ok; |
char option[20], *v; |
char option[20], *v; |
Line 1465 void pr_dashes() |
|
Line 1565 void pr_dashes() |
|
* pr_font - determine font |
* pr_font - determine font |
*---------------------------------------------------------------------------*/ |
*---------------------------------------------------------------------------*/ |
|
|
void pr_font() |
void |
|
pr_font() |
{ |
{ |
char *fontname = pr_GetR(db, ".font"); |
char *fontname = pr_GetR(db, ".font"); |
|
|
Line 1490 gnuplot: no useable font - X11 aborted.\n", FallbackFo |
|
Line 1591 gnuplot: no useable font - X11 aborted.\n", FallbackFo |
|
* pr_geometry - determine window geometry |
* pr_geometry - determine window geometry |
*---------------------------------------------------------------------------*/ |
*---------------------------------------------------------------------------*/ |
|
|
void pr_geometry() |
void |
|
pr_geometry() |
{ |
{ |
char *geometry = pr_GetR(db, ".geometry"); |
char *geometry = pr_GetR(db, ".geometry"); |
int x, y, flags; |
int x, y, flags; |
Line 1520 void pr_geometry() |
|
Line 1622 void pr_geometry() |
|
* pr_pointsize - determine size of points for 'points' plotting style |
* pr_pointsize - determine size of points for 'points' plotting style |
*---------------------------------------------------------------------------*/ |
*---------------------------------------------------------------------------*/ |
|
|
void pr_pointsize() |
void |
|
pr_pointsize() |
{ |
{ |
if (pr_GetR(db, ".pointsize")) { |
if (pr_GetR(db, ".pointsize")) { |
if (sscanf((char *) value.addr, "%lf", &pointsize) == 1) { |
if (sscanf((char *) value.addr, "%lf", &pointsize) == 1) { |
Line 1546 char width_keys[Nwidths][30] = { |
|
Line 1649 char width_keys[Nwidths][30] = { |
|
"line1", "line2", "line3", "line4", "line5", "line6", "line7", "line8" |
"line1", "line2", "line3", "line4", "line5", "line6", "line7", "line8" |
}; |
}; |
|
|
void pr_width() |
void |
|
pr_width() |
{ |
{ |
int n; |
int n; |
char option[20], *v; |
char option[20], *v; |
Line 1568 void pr_width() |
|
Line 1672 void pr_width() |
|
* pr_window - create window |
* pr_window - create window |
*---------------------------------------------------------------------------*/ |
*---------------------------------------------------------------------------*/ |
|
|
Window pr_window(flags, x, y, width, height) |
Window |
|
pr_window(flags, x, y, width, height) |
unsigned int flags; |
unsigned int flags; |
int x, y; |
int x, y; |
unsigned int width, height; |
unsigned int width, height; |
Line 1619 unsigned int width, height; |
|
Line 1724 unsigned int width, height; |
|
|
|
|
|
/***** pr_raise ***/ |
/***** pr_raise ***/ |
void pr_raise() |
void |
|
pr_raise() |
{ |
{ |
if (pr_GetR(db, ".raise")) |
if (pr_GetR(db, ".raise")) |
do_raise = (On(value.addr)); |
do_raise = (On(value.addr)); |
} |
} |
|
|
|
|
void pr_persist() |
void |
|
pr_persist() |
{ |
{ |
if (pr_GetR(db, ".persist")) |
if (pr_GetR(db, ".persist")) |
persist = (On(value.addr)); |
persist = (On(value.addr)); |
Line 1639 void pr_persist() |
|
Line 1746 void pr_persist() |
|
/* bit of a bodge, but ... */ |
/* bit of a bodge, but ... */ |
static struct plot_struct *exported_plot; |
static struct plot_struct *exported_plot; |
|
|
void export_graph(plot) |
void |
|
export_graph(plot) |
struct plot_struct *plot; |
struct plot_struct *plot; |
{ |
{ |
FPRINTF((stderr, "export_graph(0x%x)\n", plot)); |
FPRINTF((stderr, "export_graph(0x%x)\n", plot)); |
Line 1651 struct plot_struct *plot; |
|
Line 1759 struct plot_struct *plot; |
|
exported_plot = plot; |
exported_plot = plot; |
} |
} |
|
|
void handle_selection_event(event) |
void |
|
handle_selection_event(event) |
XEvent *event; |
XEvent *event; |
{ |
{ |
switch (event->type) { |
switch (event->type) { |
|
|
FPRINTF((stderr, "selection request\n")); |
FPRINTF((stderr, "selection request\n")); |
|
|
if (reply.xselection.target == XA_TARGETS) { |
if (reply.xselection.target == XA_TARGETS) { |
static Atom targets[] = {XA_PIXMAP, XA_COLORMAP}; |
static Atom targets[] = { XA_PIXMAP, XA_COLORMAP }; |
|
|
FPRINTF((stderr, "Targets request from %d\n", reply.xselection.requestor)); |
FPRINTF((stderr, "Targets request from %d\n", reply.xselection.requestor)); |
|
|
|
|
|
|
XChangeProperty(dpy, reply.xselection.requestor, |
XChangeProperty(dpy, reply.xselection.requestor, |
reply.xselection.property, reply.xselection.target, 32, PropModeReplace, |
reply.xselection.property, reply.xselection.target, 32, PropModeReplace, |
(unsigned char *) &(exported_plot->pixmap), 1); |
(unsigned char *) &(exported_plot->pixmap), 1); |
} else { |
} else { |
reply.xselection.property = None; |
reply.xselection.property = None; |
} |
} |