1/* Hello, Emacs, this is -*-C-*- */
2
3/* GNUPLOT - xlib.trm */
4
5/*
6 * xlib.trm - inboard terminal driver for X11 (dumps gnuplot_x11 commands)
7 *
8 * New implementation November 2003
9 * Xlib_init() sets up the output channels, but otherwise all work is done
10 * by the main x11.trm driver routines.
11 * Ethan A Merritt <merritt@u.washington.edu>
12 */
13
14#include "driver.h"
15
16#ifdef TERM_REGISTER
17register_term(xlib)
18#endif
19
20#ifdef TERM_PROTO
21TERM_PUBLIC void Xlib_init(void);
22TERM_PUBLIC void Xlib_text(void);
23TERM_PUBLIC void Xlib_reset(void);
24#define GOT_XLIB_PROTO
25#endif
26
27#ifndef TERM_PROTO_ONLY
28#ifdef TERM_BODY
29
30static FILE *X11_save_ipc = NULL;
31#ifndef PIPE_IPC
32    int ipc_back_fd = IPC_BACK_UNUSABLE;
33#endif
34
35TERM_PUBLIC void
36Xlib_init()
37{
38    /* x11.trm thinks it is writing to a private pipe, but here we */
39    /* set it to use the channel opened by 'set output <file>'     */
40    X11_save_ipc = X11_ipc;
41    X11_ipc = gpoutfile;
42
43    /* There is, of course, no mouse feedback */
44    ipc_back_fd = IPC_BACK_UNUSABLE;
45    term_initialised = TRUE;
46}
47
48TERM_PUBLIC void
49Xlib_text()
50{
51    ipc_back_fd = 1;	/* Force scaling info to be appended */
52    X11_text();
53    ipc_back_fd = IPC_BACK_UNUSABLE;
54}
55
56TERM_PUBLIC void
57Xlib_reset()
58{
59    X11_ipc = X11_save_ipc;
60}
61
62#endif
63
64#ifdef TERM_TABLE
65TERM_TABLE_START(xlib_driver)
66    "xlib", "X11 Window System (dump of gnuplot_x11 command stream)",
67    X11_XMAX, X11_YMAX, X11_VCHAR, X11_HCHAR,
68    X11_VTIC, X11_HTIC, X11_options, Xlib_init, Xlib_reset,
69    Xlib_text, null_scale, X11_graphics, X11_move, X11_vector,
70    X11_linetype, X11_put_text, X11_text_angle,
71    X11_justify_text, X11_point, do_arrow, X11_set_font,
72    X11_pointsize, TERM_CAN_MULTIPLOT|TERM_INIT_ON_REPLOT|TERM_CAN_DASH,
73    X11_text /* suspend can use same routine */ , 0 /* resume */ ,
74    X11_fillbox, X11_linewidth
75#ifdef USE_MOUSE
76    , NULL, NULL, NULL, NULL, NULL
77#endif
78    , X11_make_palette, 0 /* X11_previous_palette */ ,
79    X11_set_color, X11_filled_polygon
80    , X11_image
81    , ENHX11_OPEN, ENHX11_FLUSH, do_enh_writec
82    , NULL	/* layering */
83    , NULL	/* path */
84    , 0.0	/* tscale */
85    , NULL	/* hypertext */
86    , ENHX11_boxed_text
87    , NULL	/* modify_plots */
88    , X11_dashtype
89TERM_TABLE_END(xlib_driver)
90
91#undef LAST_TERM
92#define LAST_TERM xlib_driver
93
94#endif /* TERM_TABLE */
95#endif /* TERM_PROTO_ONLY */
96
97#ifdef TERM_HELP
98START_HELP(xlib)
99"1 xlib",
100"?commands set terminal xlib",
101"?set terminal xlib",
102"?set term xlib",
103"?terminal xlib",
104"?term xlib",
105"?xlib",
106" The `xlib` terminal driver supports the X11 Windows System.  It generates",
107" gnuplot_x11 commands, but sends them to the output file specified by",
108" `set output '<filename>'`. `set term x11` is equivalent to",
109" `set output \"|gnuplot_x11 -noevents\"; set term xlib`.",
110" `xlib` takes the same set of options as `x11`."
111END_HELP(xlib)
112#endif
113