Initial release of Maemo 5 port of gnuplot
[gnuplot] / term / unixplot.trm
1 /* Hello, Emacs, this is -*-C-*-
2  * $Id: unixplot.trm,v 1.16 2006/07/21 02:35:48 sfeam Exp $
3  *
4  */
5
6 /* GNUPLOT -- unixplot.trm */
7
8 /*[
9  * Copyright 1990 - 1993, 1998, 2004
10  *
11  * Permission to use, copy, and distribute this software and its
12  * documentation for any purpose with or without fee is hereby granted,
13  * provided that the above copyright notice appear in all copies and
14  * that both that copyright notice and this permission notice appear
15  * in supporting documentation.
16  *
17  * Permission to modify the software is granted, but not the right to
18  * distribute the complete modified source code.  Modifications are to
19  * be distributed as patches to the released version.  Permission to
20  * distribute binaries produced by compiling modified sources is granted,
21  * provided you
22  *   1. distribute the corresponding source modifications from the
23  *    released version in the form of a patch file along with the binaries,
24  *   2. add special version identification to distinguish your version
25  *    in addition to the base release version number,
26  *   3. provide your name and address as the primary contact for the
27  *    support of your modified version, and
28  *   4. retain our contact information in regard to use of the base
29  *    software.
30  * Permission to distribute the released version of the source code along
31  * with corresponding source modifications in the form of a patch file is
32  * granted with same provisions 2 through 4 for binary distributions.
33  *
34  * This software is provided "as is" without express or implied warranty
35  * to the extent permitted by applicable law.
36 ]*/
37
38 /*
39  * This file is included by ../term.c.
40  *
41  * This terminal driver supports:
42  *  Unix plot(5) graphics language
43  *
44  * AUTHORS
45  *  Colin Kelley, Thomas Williams, Russell Lang
46  *
47  * send your comments or suggestions to (gnuplot-info@lists.sourceforge.net).
48  *
49  */
50
51 /*
52  * Unixplot library writes to stdout.  A fix was put in place by
53  * ..!arizona!naucse!jdc to let set term and set output redirect
54  * stdout.  All other terminals write to gpoutfile.
55 */
56
57 /*
58  * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
59  */
60
61 #include "driver.h"
62
63 #ifdef TERM_REGISTER
64 register_term(unixplot)
65 #endif
66
67 #ifdef TERM_PROTO
68 TERM_PUBLIC void UP_init __PROTO((void));
69 TERM_PUBLIC void UP_graphics __PROTO((void));
70 TERM_PUBLIC void UP_text __PROTO((void));
71 TERM_PUBLIC void UP_linetype __PROTO((int linetype));
72 TERM_PUBLIC void UP_move __PROTO((unsigned int x, unsigned int y));
73 TERM_PUBLIC void UP_vector __PROTO((unsigned int x, unsigned int y));
74 TERM_PUBLIC void UP_put_text __PROTO((unsigned int x, unsigned int y, const char str[]));
75 TERM_PUBLIC void UP_reset __PROTO((void));
76
77 #define UP_XMAX 4096
78 #define UP_YMAX 4096
79
80 #define UP_XLAST (UP_XMAX - 1)
81 #define UP_YLAST (UP_YMAX - 1)
82
83 #define UP_VCHAR (UP_YMAX/30)   /* just a guess--no way to know this! */
84 #define UP_HCHAR (UP_XMAX/60)   /* just a guess--no way to know this! */
85 #define UP_VTIC (UP_YMAX/80)
86 #define UP_HTIC (UP_XMAX/80)
87 #endif /* TERM_PROTO */
88
89 #ifndef TERM_PROTO_ONLY
90 #ifdef TERM_BODY
91
92 TERM_PUBLIC void
93 UP_init()
94 {
95     openpl();
96     space(0, 0, UP_XMAX, UP_YMAX);
97 }
98
99
100 TERM_PUBLIC void
101 UP_graphics()
102 {
103     erase();
104 }
105
106
107 TERM_PUBLIC void
108 UP_text()
109 {
110     /* empty */
111 }
112
113
114 TERM_PUBLIC void
115 UP_linetype(int linetype)
116 {
117     static char *lt[2 + 5] = {"solid", "longdashed", "solid", "dotted",
118      "shortdashed", "dotdashed", "longdashed"};
119
120     if (linetype < -2)
121         linetype = LT_BLACK;
122
123     if (linetype >= 5)
124         linetype %= 5;
125
126     linemod(lt[linetype + 2]);
127 }
128
129
130 TERM_PUBLIC void
131 UP_move(unsigned int x, unsigned int y)
132 {
133     move(x, y);
134 }
135
136
137 TERM_PUBLIC void
138 UP_vector(unsigned int x, unsigned int y)
139 {
140     cont(x, y);
141 }
142
143
144 TERM_PUBLIC void
145 UP_put_text(unsigned int x, unsigned int y, const char str[])
146 {
147     UP_move(x + UP_HCHAR / 2, y + UP_VCHAR / 5);
148     label(str);
149 }
150
151 TERM_PUBLIC void
152 UP_reset()
153 {
154     closepl();
155 }
156
157 #endif /* TERM_BODY */
158
159 #ifdef TERM_TABLE
160 TERM_TABLE_START(unixplot_driver)
161     "unixplot", "Unix plotting standard (see plot(1))",
162     UP_XMAX, UP_YMAX, UP_VCHAR, UP_HCHAR,
163     UP_VTIC, UP_HTIC, options_null, UP_init, UP_reset,
164     UP_text, null_scale, UP_graphics, UP_move, UP_vector,
165     UP_linetype, UP_put_text, null_text_angle,
166     null_justify_text, line_and_point, do_arrow, set_font_null
167 TERM_TABLE_END(unixplot_driver)
168
169 #undef LAST_TERM
170 #define LAST_TERM unixplot_driver
171
172 #endif /* TERM_TABLE */
173 #endif /* TERM_PROTO_ONLY */
174
175
176 #ifdef TERM_HELP
177 #ifndef TERM_HELP_GNUGRAPH
178 START_HELP(unixplot)
179 "1 unixplot",
180 "?commands set terminal unixplot",
181 "?set terminal unixplot",
182 "?set term unixplot",
183 "?terminal unixplot",
184 "?term unixplot",
185 "?unixplot",
186 " The `unixplot` terminal driver generates output in the Unix \"plot\" graphics",
187 " language.  It has no options.",
188 "",
189 " This terminal cannot be compiled if the GNU version of plot is to be used;",
190 " in that case, use the `gnugraph` terminal instead."
191 END_HELP(unixplot)
192 #endif
193 #endif