2 * $Id: term_api.h,v 1.59.2.1 2008/12/12 06:57:50 sfeam Exp $
5 /* GNUPLOT - term_api.h */
8 * Copyright 1999, 2004 Thomas Williams, Colin Kelley
10 * Permission to use, copy, and distribute this software and its
11 * documentation for any purpose with or without fee is hereby granted,
12 * provided that the above copyright notice appear in all copies and
13 * that both that copyright notice and this permission notice appear
14 * in supporting documentation.
16 * Permission to modify the software is granted, but not the right to
17 * distribute the complete modified source code. Modifications are to
18 * be distributed as patches to the released version. Permission to
19 * distribute binaries produced by compiling modified sources is granted,
21 * 1. distribute the corresponding source modifications from the
22 * released version in the form of a patch file along with the binaries,
23 * 2. add special version identification to distinguish your version
24 * in addition to the base release version number,
25 * 3. provide your name and address as the primary contact for the
26 * support of your modified version, and
27 * 4. retain our contact information in regard to use of the base
29 * Permission to distribute the released version of the source code along
30 * with corresponding source modifications in the form of a patch file is
31 * granted with same provisions 2 through 4 for binary distributions.
33 * This software is provided "as is" without express or implied warranty
34 * to the extent permitted by applicable law.
37 #ifndef GNUPLOT_TERM_API_H
38 # define GNUPLOT_TERM_API_H
40 /* #if... / #include / #define collection: */
50 /* Constants that are interpreted by terminal driver routines */
52 /* Default line type is LT_BLACK; reset to this after changing colors */
55 #define LT_NODRAW (-3)
56 #define LT_BACKGROUND (-4)
57 #define LT_UNDEFINED (-5)
58 #define LT_COLORFROMCOLUMN (-6) /* Used by hidden3d code */
59 #define LT_DEFAULT (-7)
61 /* Constant value passed to (term->text_angle)(ang) to generate vertical
62 * text. Current implementation has ang equal to rotation in degrees.
64 #define TEXT_VERTICAL (90)
67 /* Type definitions */
69 /* this order means we can use x-(just*strlen(text)*t->h_char)/2 if
72 typedef enum JUSTIFY {
78 /* we use a similar trick for vertical justification of multi-line labels */
79 typedef enum VERT_JUSTIFY {
86 typedef struct lp_style_type { /* contains all Line and Point properties */
87 int pointflag; /* 0 if points not used, otherwise 1 */
93 struct t_colorspec pm3d_color;
94 /* ... more to come ? */
97 #define DEFAULT_LP_STYLE_TYPE {0, -2, 0, 1.0, PTSZ_DEFAULT, FALSE, DEFAULT_COLORSPEC}
99 typedef enum e_arrow_head {
106 extern const char *arrow_head_names[4];
108 typedef struct arrow_style_type { /* contains all Arrow properties */
109 int layer; /* 0 = back, 1 = front */
110 struct lp_style_type lp_properties;
112 t_arrow_head head; /* arrow head choice */
113 /* struct position headsize; */ /* x = length, y = angle [deg] */
114 double head_length; /* length of head, 0 = default */
115 int head_lengthunit; /* unit (x1, x2, screen, graph) */
116 double head_angle; /* front angle / deg */
117 double head_backangle; /* back angle / deg */
118 unsigned int head_filled; /* filled heads: 0=not, 1=empty, 2=filled */
119 /* ... more to come ? */
122 /* Operations used by the terminal entry point term->layer(). */
123 typedef enum termlayer {
126 TERM_LAYER_FRONTTEXT,
130 typedef struct fill_style_type {
137 typedef enum t_fillstyle { FS_EMPTY, FS_SOLID, FS_PATTERN, FS_DEFAULT }
139 #define FS_OPAQUE (FS_SOLID + (100<<4))
142 /* Color construction for an image, palette lookup or rgb components.
144 typedef enum t_imagecolor { IC_PALETTE, IC_RGB }
148 /* values for the optional flags field - choose sensible defaults
149 * these aren't really very sensible names - multiplot attributes
150 * depend on whether stdout is redirected or not. Remember that
151 * the default is 0. Thus most drivers can do multiplot only if
152 * the output is redirected
154 #define TERM_CAN_MULTIPLOT 1 /* tested if stdout not redirected */
155 #define TERM_CANNOT_MULTIPLOT 2 /* tested if stdout is redirected */
156 #define TERM_BINARY 4 /* open output file with "b" */
157 #define TERM_INIT_ON_REPLOT 8 /* call term->init() on replot */
158 #define TERM_IS_POSTSCRIPT 16 /* post, next, pslatex, etc */
159 #define TERM_ENHANCED_TEXT 32 /* enhanced text mode is enabled */
160 #define TERM_NO_OUTPUTFILE 64 /* terminal doesnt write to a file */
161 #define TERM_CAN_CLIP 128 /* terminal does its own clipping */
163 /* The terminal interface structure --- heart of the terminal layer.
165 * It should go without saying that additional entries may be made
166 * only at the end of this structure. Any fields added must be
167 * optional - a value of 0 (or NULL pointer) means an older driver
168 * does not support that feature - gnuplot must still be able to
169 * function without that terminal feature
172 typedef struct TERMENTRY {
175 const char GPFAR description[80]; /* to make text go in FAR segment */
177 const char *description;
179 unsigned int xmax,ymax,v_char,h_char,v_tic,h_tic;
181 void (*options) __PROTO((void));
182 void (*init) __PROTO((void));
183 void (*reset) __PROTO((void));
184 void (*text) __PROTO((void));
185 int (*scale) __PROTO((double, double));
186 void (*graphics) __PROTO((void));
187 void (*move) __PROTO((unsigned int, unsigned int));
188 void (*vector) __PROTO((unsigned int, unsigned int));
189 void (*linetype) __PROTO((int));
190 void (*put_text) __PROTO((unsigned int, unsigned int, const char*));
191 /* the following are optional. set term ensures they are not NULL */
192 int (*text_angle) __PROTO((int));
193 int (*justify_text) __PROTO((enum JUSTIFY));
194 void (*point) __PROTO((unsigned int, unsigned int, int));
195 void (*arrow) __PROTO((unsigned int, unsigned int, unsigned int, unsigned int, int));
196 int (*set_font) __PROTO((const char *font));
197 void (*pointsize) __PROTO((double)); /* change pointsize */
199 void (*suspend) __PROTO((void)); /* called after one plot of multiplot */
200 void (*resume) __PROTO((void)); /* called before plots of multiplot */
201 void (*fillbox) __PROTO((int, unsigned int, unsigned int, unsigned int, unsigned int)); /* clear in multiplot mode */
202 void (*linewidth) __PROTO((double linewidth));
204 int (*waitforinput) __PROTO((void)); /* used for mouse input */
205 void (*put_tmptext) __PROTO((int, const char [])); /* draws temporary text; int determines where: 0=statusline, 1,2: at corners of zoom box, with \r separating text above and below the point */
206 void (*set_ruler) __PROTO((int, int)); /* set ruler location; x<0 switches ruler off */
207 void (*set_cursor) __PROTO((int, int, int)); /* set cursor style and corner of rubber band */
208 void (*set_clipboard) __PROTO((const char[])); /* write text into cut&paste buffer (clipboard) */
210 int (*make_palette) __PROTO((t_sm_palette *palette));
211 /* 1. if palette==NULL, then return nice/suitable
212 maximal number of colours supported by this terminal.
213 Returns 0 if it can make colours without palette (like
215 2. if palette!=NULL, then allocate its own palette
216 return value is undefined
217 3. available: some negative values of max_colors for whatever
220 void (*previous_palette) __PROTO((void));
221 /* release the palette that the above routine allocated and get
222 back the palette that was active before.
223 Some terminals, like displays, may draw parts of the figure
224 using their own palette. Those terminals that possess only
225 one palette for the whole plot don't need this routine.
227 void (*set_color) __PROTO((t_colorspec *));
228 /* EAM November 2004 - revised to take a pointer to struct rgb_color,
229 so that a palette gray value is not the only option for
232 void (*filled_polygon) __PROTO((int points, gpiPoint *corners));
234 void (*image) __PROTO((unsigned, unsigned, coordval *, gpiPoint *, t_imagecolor));
237 /* Enhanced text mode driver call-backs */
238 void (*enhanced_open) __PROTO((char * fontname, double fontsize,
239 double base, TBOOLEAN widthflag, TBOOLEAN showflag,
241 void (*enhanced_flush) __PROTO((void));
242 void (*enhanced_writec) __PROTO((int c));
244 /* Driver-specific synchronization or other layering commands.
245 * Introduced as an alternative to the ugly sight of
246 * driver-specific code strewn about in the core routines.
247 * As of this point (July 2005) used only by pslatex.trm
249 void (*layer) __PROTO((t_termlayer));
251 /* Begin/End path control.
252 * Needed by PostScript-like devices in order to join the endpoints of
255 void (*path) __PROTO((int p));
260 # define termentry TERMENTRY far
262 # define termentry TERMENTRY
265 enum set_encoding_id {
266 S_ENC_DEFAULT, S_ENC_ISO8859_1, S_ENC_ISO8859_2, S_ENC_ISO8859_15,
267 S_ENC_CP437, S_ENC_CP850, S_ENC_CP852, S_ENC_CP1250,
268 S_ENC_KOI8_R, S_ENC_KOI8_U,
272 /* HBB 20020225: this stuff used to be in a separate header, ipc.h,
273 * but I strongly disliked the way that was done */
276 * There are the following types of interprocess communication from
277 * (gnupmdrv, gnuplot_x11) => gnuplot:
278 * OS2_IPC ... the OS/2 shared memory + event semaphores approach
279 * PIPE_IPC ... communication by using bidirectional pipe
284 * OS2_IPC: gnuplot's terminals communicate with it by shared memory + event
285 * semaphores => the code in gpexecute.c is used, and nothing more from here.
290 enum { IPC_BACK_UNUSABLE = -2, IPC_BACK_CLOSED = -1 };
293 * Currently only used for PIPE_IPC, but in principle
294 * every term could use this file descriptor to write back
295 * commands to gnuplot. Note, that terminals using this fd
296 * should set it to a negative value when closing. (joze)
298 /* HBB 20020225: currently not used anywhere outside term.c --> make
300 /* extern int ipc_back_fd; */
302 # endif /* PIPE_IPC */
304 /* options handling */
305 enum { UNSET = -1, no = 0, yes = 1 };
307 /* Variables of term.c needed by other modules: */
309 /* the terminal info structure, being the heart of the whole module */
310 extern struct termentry *term;
311 /* Options string of the currently used terminal driver */
312 extern char term_options[];
313 /* access head length + angle without changing API */
314 extern int curr_arrow_headlength;
315 /* angle in degrees */
316 extern double curr_arrow_headangle;
317 extern double curr_arrow_headbackangle;
318 /* arrow head filled or not */
319 extern int curr_arrow_headfilled;
321 /* Current 'output' file: name and open filehandle */
323 extern FILE *gpoutfile;
325 /* Output file where the PostScript output goes to.
327 gppsfile == gpoutfile
328 for 'set term': postscript, pstex
329 gppsfile == PSLATEX_auxfile
330 for 'set term': pslatex
332 for all other terminals
333 It is non-zero for for the family of postscript terminals, thus making
334 this a unique check for postscript output (pm3d has some code optimized
335 for PS, for instance).
337 extern FILE *gppsfile;
339 extern TBOOLEAN multiplot;
341 /* 'set encoding' support: index of current encoding ... */
342 extern enum set_encoding_id encoding;
343 /* ... in table of encoding names: */
344 extern const char *encoding_names[];
345 /* parsing table for encodings */
346 extern const struct gen_table set_encoding_tbl[];
348 /* mouse module needs this */
349 extern TBOOLEAN term_initialised;
351 /* Support for enhanced text mode. */
352 extern char enhanced_text[];
353 extern char *enhanced_cur_text;
354 extern double enhanced_fontscale;
355 /* give array size to allow the use of sizeof */
356 extern char enhanced_escape_format[16];
357 extern double enhanced_max_height, enhanced_min_height;
358 extern TBOOLEAN ignore_enhanced_text;
361 /* Prototypes of functions exported by term.c */
363 void term_set_output __PROTO((char *));
364 void term_initialise __PROTO((void));
365 void term_start_plot __PROTO((void));
366 void term_end_plot __PROTO((void));
367 void term_start_multiplot __PROTO((void));
368 void term_end_multiplot __PROTO((void));
369 /* void term_suspend __PROTO((void)); */
370 void term_reset __PROTO((void));
371 void term_apply_lp_properties __PROTO((struct lp_style_type *lp));
372 void term_check_multiplot_okay __PROTO((TBOOLEAN));
374 void write_multiline __PROTO((unsigned int, unsigned int, char *, JUSTIFY, VERT_JUSTIFY, int, const char *));
375 int estimate_strlen __PROTO((char *));
377 int term_count __PROTO((void));
379 void list_terms __PROTO((void));
380 struct termentry *set_term __PROTO((int));
381 void init_terminal __PROTO((void));
382 void test_term __PROTO((void));
384 /* Support for enhanced text mode. */
385 char *enhanced_recursion __PROTO((char *p, TBOOLEAN brace,
386 char *fontname, double fontsize,
387 double base, TBOOLEAN widthflag,
388 TBOOLEAN showflag, int overprint));
389 void enh_err_check __PROTO((const char *str));
390 /* note: c is char, but must be declared int due to K&R compatibility. */
391 void do_enh_writec __PROTO((int c));
392 /* flag: don't use enhanced output methods --- for output of
393 * filenames, which usually looks bad using subscripts */
394 void ignore_enhanced __PROTO((TBOOLEAN flag));
396 /* Simple-minded test that point is with drawable area */
397 TBOOLEAN on_page __PROTO((int x, int y));
400 void LINUX_setup __PROTO((void));
404 void PC_setup __PROTO((void));
412 int PM_pause __PROTO((char *));
413 void PM_intc_cleanup __PROTO((void));
415 void PM_update_menu_items __PROTO((void));
416 void PM_set_gpPMmenu __PROTO((struct t_gpPMmenu * gpPMmenu));
420 /* in set.c (used in pm3d.c) */
421 void lp_use_properties __PROTO((struct lp_style_type *lp, int tag, int pointflag));
423 /* Wrappers for term->path() */
424 void newpath __PROTO((void));
425 void closepath __PROTO((void));
427 #endif /* GNUPLOT_TERM_API_H */