home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-03-25 | 48.7 KB | 1,817 lines |
- Newsgroups: comp.sources.misc
- organization: Pixar -- Marin County, California
- subject: v11i073: Gnuplot 2.0 - 8 of 14
- From: thaw@ucbvax.Berkeley.EDU@pixar.UUCP (Tom Williams)
- Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
-
- Posting-number: Volume 11, Issue 73
- Submitted-by: thaw@ucbvax.Berkeley.EDU@pixar.UUCP (Tom Williams)
- Archive-name: gnuplot2/part08
-
- This is gnuplot.sh08
-
- --- CUT HERE ---
- #! /bin/sh
- echo x - term.c
- sed 's/^X//' >term.c <<'*-*-END-of-term.c-*-*'
- X/* GNUPLOT - term.c */
- X/*
- X * Copyright (C) 1986, 1987, 1990 Thomas Williams, Colin Kelley
- X *
- X * Permission to use, copy, and distribute this software and its
- X * documentation for any purpose with or without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and
- X * that both that copyright notice and this permission notice appear
- X * in supporting documentation.
- X *
- X * Permission to modify the software is granted, but not the right to
- X * distribute the modified code. Modifications are to be distributed
- X * as patches to released version.
- X *
- X * This software is provided "as is" without express or implied warranty.
- X *
- X *
- X * AUTHORS
- X *
- X * Original Software:
- X * Thomas Williams, Colin Kelley.
- X *
- X * Gnuplot 2.0 additions:
- X * Russell Lang, Dave Kotz, John Campbell.
- X *
- X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
- X *
- X */
- X
- X#include <stdio.h>
- X#include "plot.h"
- X
- X/* for use by all drivers */
- X#define sign(x) ((x) >= 0 ? 1 : -1)
- X#define abs(x) ((x) >= 0 ? (x) : -(x))
- X#define max(a,b) ((a) > (b) ? (a) : (b))
- X#define min(a,b) ((a) < (b) ? (a) : (b))
- X
- XBOOLEAN term_init; /* true if terminal has been initialized */
- X
- Xextern FILE *outfile;
- Xextern char outstr[];
- Xextern BOOLEAN term_init;
- Xextern int term;
- Xextern float xsize, ysize;
- X
- Xextern char input_line[];
- Xextern struct lexical_unit token[];
- X
- Xextern BOOLEAN interactive;
- X
- X/*
- X * instead of <strings.h>
- X */
- Xextern char *strcpy();
- Xextern int strlen(), strcmp();
- X
- Xchar *getenv();
- X
- X#ifdef __TURBOC__
- Xchar *turboc_init();
- X#endif
- X
- X#ifdef vms
- X/* these are needed to sense a regis terminal and
- X * to do a SET TERM/NOWRAP */
- X#include <descrip.h>
- X#include <dvidef.h>
- X#include <iodef.h>
- X#include <ttdef.h>
- X#include <tt2def.h>
- Xstatic unsigned short chan;
- Xstatic int old_char_buf[3], new_char_buf[3];
- X$DESCRIPTOR(sysoutput_desc,"SYS$OUTPUT");
- Xchar *vms_init();
- X#endif
- X
- X
- X/* This is needed because the unixplot library only writes to stdout. */
- X#ifdef UNIXPLOT
- XFILE save_stdout;
- X#endif
- Xint unixplot=0;
- X
- X#define NICE_LINE 0
- X#define POINT_TYPES 6
- X
- X
- Xdo_point(x,y,number)
- Xint x,y;
- Xint number;
- X{
- Xregister int htic,vtic;
- Xregister struct termentry *t = &term_tbl[term];
- X
- X if (number < 0) { /* do dot */
- X (*t->move)(x,y);
- X (*t->vector)(x,y);
- X return;
- X }
- X
- X number %= POINT_TYPES;
- X htic = (t->h_tic/2); /* should be in term_tbl[] in later version */
- X vtic = (t->v_tic/2);
- X
- X switch(number) {
- X case 0: /* do diamond */
- X (*t->move)(x-htic,y);
- X (*t->vector)(x,y-vtic);
- X (*t->vector)(x+htic,y);
- X (*t->vector)(x,y+vtic);
- X (*t->vector)(x-htic,y);
- X (*t->move)(x,y);
- X (*t->vector)(x,y);
- X break;
- X case 1: /* do plus */
- X (*t->move)(x-htic,y);
- X (*t->vector)(x-htic,y);
- X (*t->vector)(x+htic,y);
- X (*t->move)(x,y-vtic);
- X (*t->vector)(x,y-vtic);
- X (*t->vector)(x,y+vtic);
- X break;
- X case 2: /* do box */
- X (*t->move)(x-htic,y-vtic);
- X (*t->vector)(x-htic,y-vtic);
- X (*t->vector)(x+htic,y-vtic);
- X (*t->vector)(x+htic,y+vtic);
- X (*t->vector)(x-htic,y+vtic);
- X (*t->vector)(x-htic,y-vtic);
- X (*t->move)(x,y);
- X (*t->vector)(x,y);
- X break;
- X case 3: /* do X */
- X (*t->move)(x-htic,y-vtic);
- X (*t->vector)(x-htic,y-vtic);
- X (*t->vector)(x+htic,y+vtic);
- X (*t->move)(x-htic,y+vtic);
- X (*t->vector)(x-htic,y+vtic);
- X (*t->vector)(x+htic,y-vtic);
- X break;
- X case 4: /* do triangle */
- X (*t->move)(x,y+(4*vtic/3));
- X (*t->vector)(x-(4*htic/3),y-(2*vtic/3));
- X (*t->vector)(x+(4*htic/3),y-(2*vtic/3));
- X (*t->vector)(x,y+(4*vtic/3));
- X (*t->move)(x,y);
- X (*t->vector)(x,y);
- X break;
- X case 5: /* do star */
- X (*t->move)(x-htic,y);
- X (*t->vector)(x-htic,y);
- X (*t->vector)(x+htic,y);
- X (*t->move)(x,y-vtic);
- X (*t->vector)(x,y-vtic);
- X (*t->vector)(x,y+vtic);
- X (*t->move)(x-htic,y-vtic);
- X (*t->vector)(x-htic,y-vtic);
- X (*t->vector)(x+htic,y+vtic);
- X (*t->move)(x-htic,y+vtic);
- X (*t->vector)(x-htic,y+vtic);
- X (*t->vector)(x+htic,y-vtic);
- X break;
- X }
- X}
- X
- X
- X/*
- X * general point routine
- X */
- Xline_and_point(x,y,number)
- Xint x,y,number;
- X{
- X /* temporary(?) kludge to allow terminals with bad linetypes
- X to make nice marks */
- X
- X (*term_tbl[term].linetype)(NICE_LINE);
- X do_point(x,y,number);
- X}
- X
- X/*
- X * general arrow routine
- X */
- X#define ROOT2 (1.41421) /* sqrt of 2 */
- X
- Xdo_arrow(sx, sy, ex, ey)
- X int sx,sy; /* start point */
- X int ex, ey; /* end point (point of arrowhead) */
- X{
- X register struct termentry *t = &term_tbl[term];
- X int len = (t->h_tic + t->v_tic)/2; /* arrowhead size = avg of tic sizes */
- X extern double sqrt();
- X
- X /* draw the line for the arrow. That's easy. */
- X (*t->move)(sx, sy);
- X (*t->vector)(ex, ey);
- X
- X /* now draw the arrow head. */
- X /* we put the arrowhead marks at 45 degrees to line */
- X if (sx == ex) {
- X /* vertical line, special case */
- X int delta = ((float)len / ROOT2 + 0.5);
- X if (sy < ey)
- X delta = -delta; /* up arrow goes the other way */
- X (*t->move)(ex - delta, ey + delta);
- X (*t->vector)(ex,ey);
- X (*t->vector)(ex + delta, ey + delta);
- X } else {
- X int dx = sx - ex;
- X int dy = sy - ey;
- X double coeff = len / sqrt(2.0*((double)dx*(double)dx
- X + (double)dy*(double)dy));
- X int x,y; /* one endpoint */
- X
- X x = (int)( ex + (dx + dy) * coeff );
- X y = (int)( ey + (dy - dx) * coeff );
- X (*t->move)(x,y);
- X (*t->vector)(ex,ey);
- X
- X x = (int)( ex + (dx - dy) * coeff );
- X y = (int)( ey + (dy + dx) * coeff );
- X (*t->vector)(x,y);
- X }
- X
- X}
- X
- X#ifdef PC
- X#ifndef __TURBOC__
- X#define FONT57
- X#endif
- X#endif
- X
- X#ifdef NEC
- X#ifndef EPSON
- X#define EPSON
- X#endif
- X#endif
- X
- X#ifdef PROPRINTER
- X#ifndef EPSON
- X#define EPSON
- X#endif
- X#endif
- X
- X#ifdef EPSON
- X#define FONT57
- X#endif
- X
- X#ifdef UNIXPC
- X#define FONT57
- X#endif
- X
- X#ifdef FONT57
- X#include "term/font5x7.trm"
- X#endif /* FONT57 */
- X
- X
- X#ifdef PC /* all PC types */
- X#include "term/pc.trm"
- X#endif
- X
- X/*
- X all TEK types (TEK,BITGRAPH,KERMIT,SELANAR) are ifdef'd in tek.trm,
- X but most require various TEK routines. Hence TEK must be defined for
- X the others to compile.
- X*/
- X#ifdef BITGRAPH
- X# ifndef TEK
- X# define TEK
- X# endif
- X#endif
- X
- X#ifdef SELENAR
- X# ifndef TEK
- X# define TEK
- X# endif
- X#endif
- X
- X#ifdef KERMIT
- X# ifndef TEK
- X# define TEK
- X# endif
- X#endif
- X
- X#ifdef TEK /* all TEK types, TEK, BBN, SELANAR, KERMIT */
- X#include "term/tek.trm"
- X#endif
- X
- X#ifdef EPSON /* all bit map types, EPSON, NEC, PROPRINTER */
- X#include "term/epson.trm"
- X#endif
- X
- X#ifdef FIG /* Fig 1.4FS Interactive graphics program */
- X#include "term/fig.trm"
- X#endif
- X
- X#ifdef IMAGEN /* IMAGEN printer */
- X#include "term/imagen.trm"
- X#endif
- X
- X#ifdef EEPIC /* EEPIC (LATEX) type */
- X#include "term/eepic.trm"
- X# ifndef LATEX
- X# define LATEX
- X# endif
- X#endif
- X
- X#ifdef LATEX /* LATEX type */
- X#include "term/latex.trm"
- X#endif
- X
- X#ifdef POSTSCRIPT /* POSTSCRIPT type */
- X#include "term/post.trm"
- X#endif
- X
- X#ifdef HPLJET /* hplaserjet */
- X#include "term/hpljet.trm"
- X#endif
- X
- X#ifdef UNIXPC /* unix-PC ATT 7300 or 3b1 machine */
- X#include "term/unixpc.trm"
- X#endif /* UNIXPC */
- X
- X#ifdef AED
- X#include "term/aed.trm"
- X#endif /* AED */
- X
- X#ifdef HP2648
- X/* also works for HP2647 */
- X#include "term/hp2648.trm"
- X#endif /* HP2648 */
- X
- X#ifdef HP26
- X#include "term/hp26.trm"
- X#endif /* HP26 */
- X
- X#ifdef HP75
- X#ifndef HPGL
- X#define HPGL
- X#endif
- X#endif
- X
- X/* HPGL - includes HP75 */
- X#ifdef HPGL
- X#include "term/hpgl.trm"
- X#endif /* HPGL */
- X
- X/* Roland DXY800A plotter driver by Martin Yii, eln557h@monu3.OZ
- X and Russell Lang, rjl@monu1.cc.monash.oz */
- X#ifdef DXY800A
- X#include "term/dxy.trm"
- X#endif /* DXY800A */
- X
- X#ifdef IRIS4D
- X#include "term/iris4d.trm"
- X#endif /* IRIS4D */
- X
- X#ifdef QMS
- X#include "term/qms.trm"
- X#endif /* QMS */
- X
- X#ifdef REGIS
- X#include "term/regis.trm"
- X#endif /* REGIS */
- X
- X#ifdef SUN
- X#include "term/sun.trm"
- X#endif /* SUN */
- X
- X#ifdef V384
- X#include "term/v384.trm"
- X#endif /* V384 */
- X
- X#ifdef UNIXPLOT
- X#include "term/unixplot.trm"
- X#endif /* UNIXPLOT */
- X
- X/* Dummy functions for unavailable features */
- X
- X/* change angle of text. 0 is horizontal left to right.
- X* 1 is vertical bottom to top (90 deg rotate)
- X*/
- Xint null_text_angle()
- X{
- Xreturn FALSE ; /* can't be done */
- X}
- X
- X/* change justification of text.
- X * modes are LEFT (flush left), CENTRE (centred), RIGHT (flush right)
- X */
- Xint null_justify_text()
- X{
- Xreturn FALSE ; /* can't be done */
- X}
- X
- X
- X/* Change scale of plot.
- X * Parameters are x,y scaling factors for this plot.
- X * Some terminals (eg latex) need to do scaling themselves.
- X */
- Xint null_scale()
- X{
- Xreturn FALSE ; /* can't be done */
- X}
- X
- X
- XUNKNOWN_null()
- X{
- X}
- X
- X
- X/*
- X * term_tbl[] contains an entry for each terminal. "unknown" must be the
- X * first, since term is initialized to 0.
- X */
- Xstruct termentry term_tbl[] = {
- X {"unknown", "Unknown terminal type - not a plotting device",
- X 100, 100, 1, 1,
- X 1, 1, UNKNOWN_null, UNKNOWN_null,
- X UNKNOWN_null, null_scale, UNKNOWN_null, UNKNOWN_null, UNKNOWN_null,
- X UNKNOWN_null, UNKNOWN_null, null_text_angle,
- X null_justify_text, UNKNOWN_null, UNKNOWN_null}
- X#ifdef PC
- X#ifdef __TURBOC__
- X
- X ,{"egalib", "IBM PC/Clone with EGA graphics board",
- X EGALIB_XMAX, EGALIB_YMAX, EGALIB_VCHAR, EGALIB_HCHAR,
- X EGALIB_VTIC, EGALIB_HTIC, EGALIB_init, EGALIB_reset,
- X EGALIB_text, null_scale, EGALIB_graphics, EGALIB_move, EGALIB_vector,
- X EGALIB_linetype, EGALIB_put_text, EGALIB_text_angle,
- X EGALIB_justify_text, do_point, do_arrow}
- X
- X ,{"vgalib", "IBM PC/Clone with VGA graphics board",
- X VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
- X VGA_VTIC, VGA_HTIC, VGA_init, VGA_reset,
- X VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector,
- X VGA_linetype, VGA_put_text, VGA_text_angle,
- X VGA_justify_text, do_point, do_arrow}
- X
- X ,{"vgamono", "IBM PC/Clone with VGA Monochrome graphics board",
- X VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
- X VGA_VTIC, VGA_HTIC, VGA_init, VGA_reset,
- X VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector,
- X VGAMONO_linetype, VGA_put_text, VGA_text_angle,
- X VGA_justify_text, line_and_point, do_arrow}
- X
- X ,{"mcga", "IBM PC/Clone with MCGA graphics board",
- X MCGA_XMAX, MCGA_YMAX, MCGA_VCHAR, MCGA_HCHAR,
- X MCGA_VTIC, MCGA_HTIC, MCGA_init, MCGA_reset,
- X MCGA_text, null_scale, MCGA_graphics, MCGA_move, MCGA_vector,
- X MCGA_linetype, MCGA_put_text, MCGA_text_angle,
- X MCGA_justify_text, line_and_point, do_arrow}
- X
- X ,{"cga", "IBM PC/Clone with CGA graphics board",
- X CGA_XMAX, CGA_YMAX, CGA_VCHAR, CGA_HCHAR,
- X CGA_VTIC, CGA_HTIC, CGA_init, CGA_reset,
- X CGA_text, null_scale, CGA_graphics, CGA_move, CGA_vector,
- X CGA_linetype, CGA_put_text, MCGA_text_angle,
- X CGA_justify_text, line_and_point, do_arrow}
- X
- X ,{"hercules", "IBM PC/Clone with Hercules graphics board",
- X HERC_XMAX, HERC_YMAX, HERC_VCHAR, HERC_HCHAR,
- X HERC_VTIC, HERC_HTIC, HERC_init, HERC_reset,
- X HERC_text, null_scale, HERC_graphics, HERC_move, HERC_vector,
- X HERC_linetype, HERC_put_text, MCGA_text_angle,
- X HERC_justify_text, line_and_point, do_arrow}
- X#else /* TURBO */
- X
- X ,{"cga", "IBM PC/Clone with CGA graphics board",
- X CGA_XMAX, CGA_YMAX, CGA_VCHAR, CGA_HCHAR,
- X CGA_VTIC, CGA_HTIC, CGA_init, CGA_reset,
- X CGA_text, null_scale, CGA_graphics, CGA_move, CGA_vector,
- X CGA_linetype, CGA_put_text, CGA_text_angle,
- X null_justify_text, line_and_point, do_arrow}
- X
- X ,{"egabios", "IBM PC/Clone with EGA graphics board (BIOS)",
- X EGA_XMAX, EGA_YMAX, EGA_VCHAR, EGA_HCHAR,
- X EGA_VTIC, EGA_HTIC, EGA_init, EGA_reset,
- X EGA_text, null_scale, EGA_graphics, EGA_move, EGA_vector,
- X EGA_linetype, EGA_put_text, EGA_text_angle,
- X null_justify_text, do_point, do_arrow}
- X
- X ,{"vgabios", "IBM PC/Clone with VGA graphics board (BIOS)",
- X VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
- X VGA_VTIC, VGA_HTIC, VGA_init, VGA_reset,
- X VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector,
- X VGA_linetype, VGA_put_text, VGA_text_angle,
- X null_justify_text, do_point, do_arrow}
- X
- X#ifdef EGALIB
- X ,{"egalib", "IBM PC/Clone with EGA graphics board (LIB)",
- X EGALIB_XMAX, EGALIB_YMAX, EGALIB_VCHAR, EGALIB_HCHAR,
- X EGALIB_VTIC, EGALIB_HTIC, EGALIB_init, EGALIB_reset,
- X EGALIB_text, null_scale, EGALIB_graphics, EGALIB_move, EGALIB_vector,
- X EGALIB_linetype, EGALIB_put_text, null_text_angle,
- X null_justify_text, do_point, do_arrow}
- X#endif
- X
- X#ifdef HERCULES
- X ,{"hercules", "IBM PC/Clone with Hercules graphics board",
- X HERC_XMAX, HERC_YMAX, HERC_VCHAR, HERC_HCHAR,
- X HERC_VTIC, HERC_HTIC, HERC_init, HERC_reset,
- X HERC_text, null_scale, HERC_graphics, HERC_move, HERC_vector,
- X HERC_linetype, HERC_put_text, HERC_text_angle,
- X null_justify_text, line_and_point, do_arrow}
- X#endif /* HERCULES */
- X
- X#ifdef ATT6300
- X ,{"att", "AT&T 6300 terminal ???",
- X ATT_XMAX, ATT_YMAX, ATT_VCHAR, ATT_HCHAR,
- X ATT_VTIC, ATT_HTIC, ATT_init, ATT_reset,
- X ATT_text, null_scale, ATT_graphics, ATT_move, ATT_vector,
- X ATT_linetype, ATT_put_text, ATT_text_angle,
- X null_justify_text, line_and_point, do_arrow}
- X#endif
- X
- X#ifdef CORONA
- X ,{"corona325", "Corona graphics ???",
- X COR_XMAX, COR_YMAX, COR_VCHAR, COR_HCHAR,
- X COR_VTIC, COR_HTIC, COR_init, COR_reset,
- X COR_text, null_scale, COR_graphics, COR_move, COR_vector,
- X COR_linetype, COR_put_text, COR_text_angle,
- X null_justify_text, line_and_point, do_arrow}
- X#endif /* CORONA */
- X#endif /* TURBO */
- X#endif /* PC */
- X
- X#ifdef AED
- X ,{"aed512", "AED 512 Terminal",
- X AED5_XMAX, AED_YMAX, AED_VCHAR, AED_HCHAR,
- X AED_VTIC, AED_HTIC, AED_init, AED_reset,
- X AED_text, null_scale, AED_graphics, AED_move, AED_vector,
- X AED_linetype, AED_put_text, null_text_angle,
- X null_justify_text, do_point, do_arrow}
- X ,{"aed767", "AED 767 Terminal",
- X AED_XMAX, AED_YMAX, AED_VCHAR, AED_HCHAR,
- X AED_VTIC, AED_HTIC, AED_init, AED_reset,
- X AED_text, null_scale, AED_graphics, AED_move, AED_vector,
- X AED_linetype, AED_put_text, null_text_angle,
- X null_justify_text, do_point, do_arrow}
- X#endif
- X
- X#ifdef BITGRAPH
- X ,{"bitgraph", "BBN Bitgraph Terminal",
- X BG_XMAX,BG_YMAX,BG_VCHAR, BG_HCHAR,
- X BG_VTIC, BG_HTIC, BG_init, BG_reset,
- X BG_text, null_scale, BG_graphics, BG_move, BG_vector,
- X BG_linetype, BG_put_text, null_text_angle,
- X null_justify_text, line_and_point, do_arrow}
- X#endif
- X
- X#ifdef DXY800A
- X ,{"dxy800a", "Roland DXY800A plotter",
- X DXY_XMAX, DXY_YMAX, DXY_VCHAR, DXY_HCHAR,
- X DXY_VTIC, DXY_HTIC, DXY_init, DXY_reset,
- X DXY_text, null_scale, DXY_graphics, DXY_move, DXY_vector,
- X DXY_linetype, DXY_put_text, DXY_text_angle,
- X null_justify_text, do_point, do_arrow}
- X#endif
- X
- X#ifdef EPSON
- X ,{"epson_lx800", "Epson LX-800, Star NL-10, NX-1000 and lots of others",
- X EPSONXMAX, EPSONYMAX, EPSONVCHAR, EPSONHCHAR,
- X EPSONVTIC, EPSONHTIC, EPSONinit, EPSONreset,
- X EPSONtext, null_scale, EPSONgraphics, EPSONmove, EPSONvector,
- X EPSONlinetype, EPSONput_text, EPSON_text_angle,
- X null_justify_text, line_and_point, do_arrow}
- X#endif
- X
- X#ifdef FIG
- X ,{"fig", "FIG graphics language: SunView or X graphics editor",
- X FIG_XMAX, FIG_YMAX, FIG_VCHAR, FIG_HCHAR,
- X FIG_VTIC, FIG_HTIC, FIG_init, FIG_reset,
- X FIG_text, null_scale, FIG_graphics, FIG_move, FIG_vector,
- X FIG_linetype, FIG_put_text, FIG_text_angle,
- X FIG_justify_text, do_point, FIG_arrow}
- X#endif
- X
- X#ifdef HP26
- X ,{"hp2623A", "HP2623A and maybe others",
- X HP26_XMAX, HP26_YMAX, HP26_VCHAR, HP26_HCHAR,
- X HP26_VTIC, HP26_HTIC, HP26_init, HP26_reset,
- X HP26_text, null_scale, HP26_graphics, HP26_move, HP26_vector,
- X HP26_linetype, HP26_put_text, null_text_angle,
- X null_justify_text, line_and_point, do_arrow}
- X#endif
- X
- X#ifdef HP2648
- X ,{"hp2648", "HP2648 and HP2647",
- X HP2648XMAX, HP2648YMAX, HP2648VCHAR, HP2648HCHAR,
- X HP2648VTIC, HP2648HTIC, HP2648init, HP2648reset,
- X HP2648text, null_scale, HP2648graphics, HP2648move, HP2648vector,
- X HP2648linetype, HP2648put_text, HP2648_text_angle,
- X null_justify_text, line_and_point, do_arrow}
- X#endif
- X
- X#ifdef HP75
- X ,{"hp7580B", "HP7580, and probably other HPs (4 pens)",
- X HPGL_XMAX, HPGL_YMAX, HPGL_VCHAR, HPGL_HCHAR,
- X HPGL_VTIC, HPGL_HTIC, HPGL_init, HPGL_reset,
- X HPGL_text, null_scale, HPGL_graphics, HPGL_move, HPGL_vector,
- X HP75_linetype, HPGL_put_text, HPGL_text_angle,
- X null_justify_text, do_point, do_arrow}
- X#endif
- X
- X#ifdef HPGL
- X ,{"hpgl", "HP7475 and (hopefully) lots of others (6 pens)",
- X HPGL_XMAX, HPGL_YMAX, HPGL_VCHAR, HPGL_HCHAR,
- X HPGL_VTIC, HPGL_HTIC, HPGL_init, HPGL_reset,
- X HPGL_text, null_scale, HPGL_graphics, HPGL_move, HPGL_vector,
- X HPGL_linetype, HPGL_put_text, HPGL_text_angle,
- X null_justify_text, do_point, do_arrow}
- X#endif
- X
- X#ifdef HPLJET
- X ,{"laserjet1", "HP Laserjet, smallest size",
- X HPLJETXMAX, HPLJETYMAX, HPLJET1VCHAR, HPLJET1HCHAR,
- X HPLJETVTIC, HPLJETHTIC, HPLJET1init, HPLJETreset,
- X HPLJETtext, null_scale, HPLJETgraphics, HPLJETmove, HPLJETvector,
- X HPLJETlinetype, HPLJETput_text, null_text_angle,
- X null_justify_text, line_and_point, do_arrow}
- X ,{"laserjet2", "HP Laserjet, medium size",
- X HPLJETXMAX, HPLJETYMAX, HPLJET2VCHAR, HPLJET2HCHAR,
- X HPLJETVTIC, HPLJETHTIC, HPLJET2init, HPLJETreset,
- X HPLJETtext, null_scale, HPLJETgraphics, HPLJETmove, HPLJETvector,
- X HPLJETlinetype, HPLJETput_text, null_text_angle,
- X null_justify_text, line_and_point, do_arrow}
- X ,{"laserjet3", "HP Laserjet, largest size",
- X HPLJETXMAX, HPLJETYMAX, HPLJET3VCHAR, HPLJET3HCHAR,
- X HPLJETVTIC, HPLJETHTIC, HPLJET3init, HPLJETreset,
- X HPLJETtext, null_scale, HPLJETgraphics, HPLJETmove, HPLJETvector,
- X HPLJETlinetype, HPLJETput_text, null_text_angle,
- X null_justify_text, line_and_point, do_arrow}
- X#endif
- X
- X#ifdef IMAGEN
- X ,{"imagen", "Imagen laser printer",
- X IMAGEN_XMAX, IMAGEN_YMAX, IMAGEN_VCHAR, IMAGEN_HCHAR,
- X IMAGEN_VTIC, IMAGEN_HTIC, IMAGEN_init, IMAGEN_reset,
- X IMAGEN_text, null_scale, IMAGEN_graphics, IMAGEN_move,
- X IMAGEN_vector, IMAGEN_linetype, IMAGEN_put_text, IMAGEN_text_angle,
- X IMAGEN_justify_text, line_and_point, do_arrow}
- X#endif
- X
- X#ifdef IRIS4D
- X ,{"iris4d", "Silicon Graphics IRIS 4D Series Computer",
- X IRIS4D_XMAX, IRIS4D_YMAX, IRIS4D_VCHAR, IRIS4D_HCHAR,
- X IRIS4D_VTIC, IRIS4D_HTIC, IRIS4D_init, IRIS4D_reset,
- X IRIS4D_text, null_scale, IRIS4D_graphics, IRIS4D_move, IRIS4D_vector,
- X IRIS4D_linetype, IRIS4D_put_text, null_text_angle,
- X null_justify_text, do_point, do_arrow}
- X#endif
- X
- X#ifdef KERMIT
- X ,{"kc_tek40xx", "Kermit-MS tek40xx terminal emulator - color",
- X TEK40XMAX,TEK40YMAX,TEK40VCHAR, KTEK40HCHAR,
- X TEK40VTIC, TEK40HTIC, TEK40init, KTEK40reset,
- X KTEK40Ctext, null_scale, KTEK40graphics, TEK40move, TEK40vector,
- X KTEK40Clinetype, TEK40put_text, null_text_angle,
- X null_justify_text, do_point, do_arrow}
- X ,{"km_tek40xx", "Kermit-MS tek40xx terminal emulator - monochrome",
- X TEK40XMAX,TEK40YMAX,TEK40VCHAR, KTEK40HCHAR,
- X TEK40VTIC, TEK40HTIC, TEK40init, KTEK40reset,
- X TEK40text, null_scale, KTEK40graphics, TEK40move, TEK40vector,
- X KTEK40Mlinetype, TEK40put_text, null_text_angle,
- X null_justify_text, line_and_point, do_arrow}
- X#endif
- X
- X#ifdef LATEX
- X ,{"latex", "LaTeX picture environment",
- X LATEX_XMAX, LATEX_YMAX, LATEX_VCHAR, LATEX_HCHAR,
- X LATEX_VTIC, LATEX_HTIC, LATEX_init, LATEX_reset,
- X LATEX_text, LATEX_scale, LATEX_graphics, LATEX_move, LATEX_vector,
- X LATEX_linetype, LATEX_put_text, LATEX_text_angle,
- X LATEX_justify_text, LATEX_point, LATEX_arrow}
- X#endif
- X
- X#ifdef EEPIC
- X ,{"eepic", "EEPIC -- extended LaTeX picture environment",
- X EEPIC_XMAX, EEPIC_YMAX, EEPIC_VCHAR, EEPIC_HCHAR,
- X EEPIC_VTIC, EEPIC_HTIC, EEPIC_init, EEPIC_reset,
- X EEPIC_text, EEPIC_scale, EEPIC_graphics, EEPIC_move, EEPIC_vector,
- X EEPIC_linetype, EEPIC_put_text, EEPIC_text_angle,
- X EEPIC_justify_text, EEPIC_point, EEPIC_arrow}
- X#endif
- X
- X#ifdef NEC
- X ,{"nec_cp6m", "NEC printer CP6 Monochrome",
- X NECXMAX, NECYMAX, NECVCHAR, NECHCHAR,
- X NECVTIC, NECHTIC, NECMinit, NECreset,
- X NECtext, null_scale, NECgraphics, NECmove, NECvector,
- X NECMlinetype, NECput_text, NEC_text_angle,
- X null_justify_text, line_and_point, do_arrow}
- X ,{"nec_cp6c", "NEC printer CP6 Color",
- X NECXMAX, NECYMAX, NECVCHAR, NECHCHAR,
- X NECVTIC, NECHTIC, NECCinit, NECreset,
- X NECtext, null_scale, NECgraphics, NECmove, NECvector,
- X NECClinetype, NECput_text, NEC_text_angle,
- X null_justify_text, do_point, do_arrow}
- X ,{"nec_cp6d", "NEC printer CP6 Draft monochrome",
- X NECXMAX, NECYMAX, NECVCHAR, NECHCHAR,
- X NECVTIC, NECHTIC, NECMinit, NECreset,
- X NECdraft_text, null_scale, NECgraphics, NECmove, NECvector,
- X NECMlinetype, NECput_text, NEC_text_angle,
- X null_justify_text, line_and_point, do_arrow}
- X#endif
- X
- X#ifdef POSTSCRIPT
- X ,{"postscript", "Postscript graphics language, small characters",
- X PS_XMAX, PS_YMAX, PS_VCHAR1, PS_HCHAR1,
- X PS_VTIC, PS_HTIC, PS1_init, PS_reset,
- X PS_text, null_scale, PS_graphics, PS_move, PS_vector,
- X PS_linetype, PS_put_text, PS_text_angle,
- X PS_justify_text, PS_point, do_arrow}
- X ,{"psbig", "Postscript graphics language, big characters",
- X PS_XMAX, PS_YMAX, PS_VCHAR2, PS_HCHAR2,
- X PS_VTIC, PS_HTIC, PS2_init, PS_reset,
- X PS_text, null_scale, PS_graphics, PS_move, PS_vector,
- X PS_linetype, PS_put_text, PS_text_angle,
- X PS_justify_text, PS_point, do_arrow}
- X ,{"epsf1", "Encapsulated Postscript graphics language, small characters",
- X PS_XMAX, PS_YMAX, PS_VCHAR1, PS_HCHAR1,
- X PS_VTIC, PS_HTIC, EPSF1_init, EPSF_reset,
- X EPSF_text, null_scale, EPSF_graphics, PS_move, PS_vector,
- X PS_linetype, PS_put_text, PS_text_angle,
- X PS_justify_text, PS_point, do_arrow}
- X ,{"epsf2", "Encapsulated Postscript graphics language, big characters",
- X PS_XMAX, PS_YMAX, PS_VCHAR2, PS_HCHAR2,
- X PS_VTIC, PS_HTIC, EPSF2_init, EPSF_reset,
- X EPSF_text, null_scale, EPSF_graphics, PS_move, PS_vector,
- X PS_linetype, PS_put_text, PS_text_angle,
- X PS_justify_text, PS_point, do_arrow}
- X#endif
- X
- X#ifdef PROPRINTER
- X ,{"proprinter", "IBM Proprinter",
- X EPSONXMAX, EPSONYMAX, EPSONVCHAR, EPSONHCHAR,
- X EPSONVTIC, EPSONHTIC, EPSONinit, EPSONreset,
- X PROPRINTERtext, null_scale, EPSONgraphics, EPSONmove, EPSONvector,
- X EPSONlinetype, EPSONput_text, EPSON_text_angle,
- X null_justify_text, line_and_point, do_arrow}
- X#endif
- X
- X#ifdef QMS
- X ,{"qms", "QMS/QUIC Laser printer (also Talaris 1200 and others)",
- X QMS_XMAX,QMS_YMAX, QMS_VCHAR, QMS_HCHAR,
- X QMS_VTIC, QMS_HTIC, QMS_init,QMS_reset,
- X QMS_text, null_scale, QMS_graphics, QMS_move, QMS_vector,
- X QMS_linetype,QMS_put_text, null_text_angle,
- X null_justify_text, line_and_point, do_arrow}
- X#endif
- X
- X#ifdef REGIS
- X ,{"regis", "REGIS graphics language",
- X REGISXMAX, REGISYMAX, REGISVCHAR, REGISHCHAR,
- X REGISVTIC, REGISHTIC, REGISinit, REGISreset,
- X REGIStext, null_scale, REGISgraphics, REGISmove, REGISvector,
- X REGISlinetype, REGISput_text, REGIStext_angle,
- X null_justify_text, line_and_point, do_arrow}
- X#endif
- X
- X
- X#ifdef SELANAR
- X ,{"selanar", "Selanar",
- X TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR,
- X TEK40VTIC, TEK40HTIC, SEL_init, SEL_reset,
- X SEL_text, null_scale, SEL_graphics, TEK40move, TEK40vector,
- X TEK40linetype, TEK40put_text, null_text_angle,
- X null_justify_text, line_and_point, do_arrow}
- X#endif
- X
- X#ifdef SUN
- X ,{"sun", "SunView window system",
- X SUN_XMAX, SUN_YMAX, SUN_VCHAR, SUN_HCHAR,
- X SUN_VTIC, SUN_HTIC, SUN_init, SUN_reset,
- X SUN_text, null_scale, SUN_graphics, SUN_move, SUN_vector,
- X SUN_linetype, SUN_put_text, null_text_angle,
- X SUN_justify_text, line_and_point, do_arrow}
- X#endif
- X
- X#ifdef TEK
- X ,{"tek40xx", "Tektronix 4010 and others; most TEK emulators",
- X TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR,
- X TEK40VTIC, TEK40HTIC, TEK40init, TEK40reset,
- X TEK40text, null_scale, TEK40graphics, TEK40move, TEK40vector,
- X TEK40linetype, TEK40put_text, null_text_angle,
- X null_justify_text, line_and_point, do_arrow}
- X#endif
- X
- X#ifdef UNIXPLOT
- X ,{"unixplot", "Unix plotting standard (see plot(1))",
- X UP_XMAX, UP_YMAX, UP_VCHAR, UP_HCHAR,
- X UP_VTIC, UP_HTIC, UP_init, UP_reset,
- X UP_text, null_scale, UP_graphics, UP_move, UP_vector,
- X UP_linetype, UP_put_text, null_text_angle,
- X null_justify_text, line_and_point, do_arrow}
- X#endif
- X
- X#ifdef UNIXPC
- X ,{"unixpc", "AT&T 3b1 or AT&T 7300 Unix PC",
- X uPC_XMAX, uPC_YMAX, uPC_VCHAR, uPC_HCHAR,
- X uPC_VTIC, uPC_HTIC, uPC_init, uPC_reset,
- X uPC_text, null_scale, uPC_graphics, uPC_move, uPC_vector,
- X uPC_linetype, uPC_put_text, uPC_text_angle,
- X null_justify_text, line_and_point, do_arrow}
- X#endif
- X
- X#ifdef V384
- X ,{"vx384", "Vectrix 384 and Tandy color printer",
- X V384_XMAX, V384_YMAX, V384_VCHAR, V384_HCHAR,
- X V384_VTIC, V384_HTIC, V384_init, V384_reset,
- X V384_text, null_scale, V384_graphics, V384_move, V384_vector,
- X V384_linetype, V384_put_text, null_text_angle,
- X null_justify_text, do_point, do_arrow}
- X#endif
- X};
- X
- X#define TERMCOUNT (sizeof(term_tbl)/sizeof(struct termentry))
- X
- X
- Xlist_terms()
- X{
- Xregister int i;
- X
- X fprintf(stderr,"\nAvailable terminal types:\n");
- X for (i = 0; i < TERMCOUNT; i++)
- X fprintf(stderr," %15s %s\n",
- X term_tbl[i].name, term_tbl[i].description);
- X (void) putc('\n',stderr);
- X}
- X
- X
- X/* set_term: get terminal number from name on command line */
- X/* will change 'term' variable if successful */
- Xint /* term number */
- Xset_term(c_token)
- Xint c_token;
- X{
- X register int t;
- X char *input_name;
- X
- X if (!token[c_token].is_token)
- X int_error("terminal name expected",c_token);
- X t = -1;
- X input_name = input_line + token[c_token].start_index;
- X t = change_term(input_name, token[c_token].length);
- X if (t == -1)
- X int_error("unknown terminal type; type just 'set terminal' for a list",
- X c_token);
- X if (t == -2)
- X int_error("ambiguous terminal name; type just 'set terminal' for a list",
- X c_token);
- X
- X /* otherwise the type was changed */
- X
- X return(t);
- X}
- X
- X/* change_term: get terminal number from name and set terminal type */
- X/* returns -1 if unknown, -2 if ambiguous, >=0 is terminal number */
- Xint
- Xchange_term(name, length)
- X char *name;
- X int length;
- X{
- X int i, t = -1;
- X
- X for (i = 0; i < TERMCOUNT; i++) {
- X if (!strncmp(name,term_tbl[i].name,length)) {
- X if (t != -1)
- X return(-2); /* ambiguous */
- X t = i;
- X }
- X }
- X
- X if (t == -1) /* unknown */
- X return(t);
- X
- X /* Success: set terminal type now */
- X
- X /* Special handling for unixplot term type */
- X if (!strncmp("unixplot",name,sizeof(unixplot))) {
- X UP_redirect (2); /* Redirect actual stdout for unixplots */
- X } else if (unixplot) {
- X UP_redirect (3); /* Put stdout back together again. */
- X }
- X
- X term = t;
- X term_init = FALSE;
- X name = term_tbl[term].name;
- X
- X if (interactive)
- X fprintf(stderr, "Terminal type set to '%s'\n", name);
- X
- X return(t);
- X}
- X
- X/*
- X Routine to detect what terminal is being used (or do anything else
- X that would be nice). One anticipated (or allowed for) side effect
- X is that the global ``term'' may be set.
- X The environment variable GNUTERM is checked first; if that does
- X not exist, then the terminal hardware is checked, if possible,
- X and finally, we can check $TERM for some kinds of terminals.
- X*/
- X/* thanks to osupyr!alden (Dave Alden) for the original GNUTERM code */
- Xinit_terminal()
- X{
- X char *term_name = NULL;
- X int t;
- X#ifdef SUN /* turbo C doesn't like unused variables */
- X char *term = NULL; /* from TERM environment var */
- X#endif
- X char *gnuterm = NULL;
- X
- X /* GNUTERM environment variable is primary */
- X gnuterm = getenv("GNUTERM");
- X if (gnuterm != (char *)NULL)
- X term_name = gnuterm;
- X else {
- X#ifdef __TURBOC__
- X term_name = turboc_init();
- X#endif
- X
- X#ifdef vms
- X term_name = vms_init();
- X#endif
- X
- X#ifdef SUN
- X term = getenv("TERM"); /* try $TERM */
- X if (term_name == (char *)NULL
- X && term != (char *)NULL && strcmp(term, "sun") == 0)
- X term_name = "sun";
- X#endif /* sun */
- X
- X#ifdef UNIXPC
- X if (iswind() == 0) {
- X term_name = "unixpc";
- X }
- X#endif /* unixpc */
- X }
- X
- X /* We have a name, try to set term type */
- X if (term_name != NULL && *term_name != '\0') {
- X t = change_term(term_name, strlen(term_name));
- X if (t == -1)
- X fprintf(stderr, "Unknown terminal name '%s'\n", term_name);
- X else if (t == -2)
- X fprintf(stderr, "Ambiguous terminal name '%s'\n", term_name);
- X else /* successful */
- X ;
- X }
- X}
- X
- X
- X#ifdef __TURBOC__
- Xchar *
- Xturboc_init()
- X{
- X int g_driver,g_mode;
- X char far *c1,*c2;
- X char *term_name = NULL;
- X
- X/* Some of this code including BGI drivers is copyright Borland Intl. */
- X g_driver=DETECT;
- X get_path();
- X initgraph(&g_driver,&g_mode,path);
- X c1=getdrivername();
- X c2=getmodename(g_mode);
- X switch (g_driver){
- X case -2: fprintf(stderr,"Graphics card not detected.\n");
- X break;
- X case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
- X break;
- X case -4: fprintf(stderr,"Invalid BGI driver file.\n");
- X break;
- X case -5: fprintf(stderr,"Insufficient memory to load ",
- X "graphics driver.");
- X break;
- X case 1 : term_name = "cga";
- X break;
- X case 2 : term_name = "mcga";
- X break;
- X case 3 :
- X case 4 : term_name = "egalib";
- X break;
- X case 7 : term_name = "hercules";
- X break;
- X case 9 : term_name = "vgalib";
- X break;
- X }
- X closegraph();
- X fprintf(stderr,"\tTC Graphics, driver %s mode %s\n",c1,c2);
- X return(term_name);
- X}
- X#endif /* __TURBOC__ */
- X
- X#ifdef vms
- X/*
- X * Determine if we have a regis terminal.
- X * and do a SET TERM/NOWRAP
- X*/
- Xchar *
- Xvms_init()
- X{
- Xchar *term_str="tt:";
- Xtypedef struct
- X {
- X short cond_value;
- X short count;
- X int info;
- X } status_block;
- Xtypedef struct
- X {
- X short buffer_len;
- X short item_code;
- X int buffer_addr;
- X int ret_len_addr;
- X } item_desc;
- Xstruct {
- X item_desc dev_type;
- X int terminator;
- X } dvi_list;
- X int status, dev_type, zero=0;
- X char buffer[255];
- X $DESCRIPTOR(term_desc, term_str);
- X
- X/* This does the equivalent of a SET TERM/NOWRAP command */
- X int i;
- X sys$assign(&sysoutput_desc,&chan,0,0);
- X sys$qiow(0,chan,IO$_SENSEMODE,0,0,0,old_char_buf,12,0,0,0,0);
- X for (i = 0 ; i < 3 ; ++i) new_char_buf[i] = old_char_buf[i];
- X new_char_buf[1] &= ~(TT$M_WRAP);
- X sys$qiow(0,chan,IO$_SETMODE,0,0,0,new_char_buf,12,0,0,0,0);
- X sys$dassgn(chan);
- X
- X/* set up dvi item list */
- X dvi_list.dev_type.buffer_len = 4;
- X dvi_list.dev_type.item_code = DVI$_TT_REGIS;
- X dvi_list.dev_type.buffer_addr = &dev_type;
- X dvi_list.dev_type.ret_len_addr = 0;
- X
- X dvi_list.terminator = 0;
- X
- X/* See what type of terminal we have. */
- X status = SYS$GETDVIW (0, 0, &term_desc, &dvi_list, 0, 0, 0, 0);
- X if ((status & 1) && dev_type) {
- X return("regis");
- X }
- X return(NULL);
- X}
- X
- X
- X
- X/*
- X * vms_reset
- X */
- Xvms_reset()
- X{
- X /* set wrap back to original state */
- X sys$assign(&sysoutput_desc,&chan,0,0);
- X sys$qiow(0,chan,IO$_SETMODE,0,0,0,old_char_buf,12,0,0,0,0);
- X sys$dassgn(chan);
- X}
- X#endif /* VMS */
- X
- X/*
- X This is always defined so we don't have to have command.c know if it
- X is there or not.
- X*/
- X#ifndef UNIXPLOT
- XUP_redirect(caller) int caller;
- X{
- X caller = caller; /* to stop Turbo C complaining
- X * about caller not being used */
- X}
- X#else
- XUP_redirect (caller)
- Xint caller;
- X/*
- X Unixplot can't really write to outfile--it wants to write to stdout.
- X This is normally ok, but the original design of gnuplot gives us
- X little choice. Originally users of unixplot had to anticipate
- X their needs and redirect all I/O to a file... Not very gnuplot-like.
- X
- X caller: 1 - called from SET OUTPUT "FOO.OUT"
- X 2 - called from SET TERM UNIXPLOT
- X 3 - called from SET TERM other
- X 4 - called from SET OUTPUT
- X*/
- X{
- X switch (caller) {
- X case 1:
- X /* Don't save, just replace stdout w/outfile (save was already done). */
- X if (unixplot)
- X *(stdout) = *(outfile); /* Copy FILE structure */
- X break;
- X case 2:
- X if (!unixplot) {
- X fflush(stdout);
- X save_stdout = *(stdout);
- X *(stdout) = *(outfile); /* Copy FILE structure */
- X unixplot = 1;
- X }
- X break;
- X case 3:
- X /* New terminal in use--put stdout back to original. */
- X closepl();
- X fflush(stdout);
- X *(stdout) = save_stdout; /* Copy FILE structure */
- X unixplot = 0;
- X break;
- X case 4:
- X /* User really wants to go to normal output... */
- X if (unixplot) {
- X fflush(stdout);
- X *(stdout) = save_stdout; /* Copy FILE structure */
- X }
- X break;
- X }
- X}
- X#endif
- X
- X
- X/* test terminal by drawing border and text */
- X/* called from command test */
- Xtest_term()
- X{
- X register struct termentry *t = &term_tbl[term];
- X char *str;
- X int x,y, xl,yl, i;
- X char label[MAX_ID_LEN];
- X
- X if (!term_init) {
- X (*t->init)();
- X term_init = TRUE;
- X }
- X screen_ok = FALSE;
- X (*t->graphics)();
- X /* border linetype */
- X (*t->linetype)(-2);
- X (*t->move)(0,0);
- X (*t->vector)(t->xmax-1,0);
- X (*t->vector)(t->xmax-1,t->ymax-1);
- X (*t->vector)(0,t->ymax-1);
- X (*t->vector)(0,0);
- X (void) (*t->justify_text)(LEFT);
- X (*t->put_text)(t->h_char*5,t->ymax-t->v_char*3,"Terminal Test");
- X /* axis linetype */
- X (*t->linetype)(-1);
- X (*t->move)(t->xmax/2,0);
- X (*t->vector)(t->xmax/2,t->ymax-1);
- X (*t->move)(0,t->ymax/2);
- X (*t->vector)(t->xmax-1,t->ymax/2);
- X /* test width and height of characters */
- X (*t->linetype)(-2);
- X (*t->move)( t->xmax/2-t->h_char*10,t->ymax/2+t->v_char/2);
- X (*t->vector)(t->xmax/2+t->h_char*10,t->ymax/2+t->v_char/2);
- X (*t->vector)(t->xmax/2+t->h_char*10,t->ymax/2-t->v_char/2);
- X (*t->vector)(t->xmax/2-t->h_char*10,t->ymax/2-t->v_char/2);
- X (*t->vector)(t->xmax/2-t->h_char*10,t->ymax/2+t->v_char/2);
- X (*t->put_text)(t->xmax/2-t->h_char*10,t->ymax/2,
- X "12345678901234567890");
- X /* test justification */
- X (void) (*t->justify_text)(LEFT);
- X (*t->put_text)(t->xmax/2,t->ymax/2+t->v_char*6,"left justified");
- X str = "centre+d text";
- X if ((*t->justify_text)(CENTRE))
- X (*t->put_text)(t->xmax/2,
- X t->ymax/2+t->v_char*5,str);
- X else
- X (*t->put_text)(t->xmax/2-strlen(str)*t->h_char/2,
- X t->ymax/2+t->v_char*5,str);
- X str = "right justified";
- X if ((*t->justify_text)(RIGHT))
- X (*t->put_text)(t->xmax/2,
- X t->ymax/2+t->v_char*4,str);
- X else
- X (*t->put_text)(t->xmax/2-strlen(str)*t->h_char,
- X t->ymax/2+t->v_char*4,str);
- X /* test text angle */
- X str = "rotated ce+ntred text";
- X if ((*t->text_angle)(1)) {
- X if ((*t->justify_text)(CENTRE))
- X (*t->put_text)(t->v_char,
- X t->ymax/2,str);
- X else
- X (*t->put_text)(t->v_char,
- X t->ymax/2-strlen(str)*t->h_char/2,str);
- X }
- X else {
- X (void) (*t->justify_text)(LEFT);
- X (*t->put_text)(t->h_char*2,t->ymax/2-t->v_char*2,"Can't rotate text");
- X }
- X (void) (*t->justify_text)(LEFT);
- X (void) (*t->text_angle)(0);
- X /* test tic size */
- X (*t->move)(t->xmax/2+t->h_tic*2,0);
- X (*t->vector)(t->xmax/2+t->h_tic*2,t->v_tic);
- X (*t->move)(t->xmax/2,t->v_tic*2);
- X (*t->vector)(t->xmax/2+t->h_tic,t->v_tic*2);
- X (*t->put_text)(t->xmax/2+t->h_tic*2,t->v_tic*2+t->v_char/2,"test tics");
- X /* test line and point types */
- X x = t->xmax - t->h_char*4 - t->h_tic*4;
- X y = t->ymax - t->v_char;
- X for ( i = -2; y > t->v_char; i++ ) {
- X (*t->linetype)(i);
- X (void) sprintf(label,"%d",i);
- X if ((*t->justify_text)(RIGHT))
- X (*t->put_text)(x,y,label);
- X else
- X (*t->put_text)(x-strlen(label)*t->h_char,y,label);
- X (*t->move)(x+t->h_char,y);
- X (*t->vector)(x+t->h_char*4,y);
- X if ( i >= -1 )
- X (*t->point)(x+t->h_char*4+t->h_tic*2,y,i);
- X y -= t->v_char;
- X }
- X /* test some arrows */
- X (*t->linetype)(0);
- X x = t->xmax/4;
- X y = t->ymax/4;
- X xl = t->h_tic*5;
- X yl = t->v_tic*5;
- X (*t->arrow)(x,y,x+xl,y);
- X (*t->arrow)(x,y,x+xl,y+yl);
- X (*t->arrow)(x,y,x,y+yl);
- X (*t->arrow)(x,y,x-xl,y+yl);
- X (*t->arrow)(x,y,x-xl,y);
- X (*t->arrow)(x,y,x-xl,y-yl);
- X (*t->arrow)(x,y,x,y-yl);
- X (*t->arrow)(x,y,x+xl,y-yl);
- X /* and back into text mode */
- X (*t->text)();
- X}
- *-*-END-of-term.c-*-*
- echo x - util.c
- sed 's/^X//' >util.c <<'*-*-END-of-util.c-*-*'
- X/* GNUPLOT - util.c */
- X/*
- X * Copyright (C) 1986, 1987, 1990 Thomas Williams, Colin Kelley
- X *
- X * Permission to use, copy, and distribute this software and its
- X * documentation for any purpose with or without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and
- X * that both that copyright notice and this permission notice appear
- X * in supporting documentation.
- X *
- X * Permission to modify the software is granted, but not the right to
- X * distribute the modified code. Modifications are to be distributed
- X * as patches to released version.
- X *
- X * This software is provided "as is" without express or implied warranty.
- X *
- X *
- X * AUTHORS
- X *
- X * Original Software:
- X * Thomas Williams, Colin Kelley.
- X *
- X * Gnuplot 2.0 additions:
- X * Russell Lang, Dave Kotz, John Campbell.
- X *
- X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
- X *
- X */
- X
- X#include <ctype.h>
- X#include <setjmp.h>
- X#include <stdio.h>
- X#include <errno.h>
- X#include "plot.h"
- X
- XBOOLEAN screen_ok;
- X /* TRUE if command just typed; becomes FALSE whenever we
- X send some other output to screen. If FALSE, the command line
- X will be echoed to the screen before the ^ error message. */
- X
- X#ifndef vms
- X#ifndef __ZTC__
- Xextern int errno;
- Xextern int sys_nerr;
- Xextern char *sys_errlist[];
- X#endif
- X#endif /* vms */
- X
- Xextern char input_line[];
- Xextern struct lexical_unit token[];
- Xextern jmp_buf env; /* from plot.c */
- Xextern int inline_num; /* from command.c */
- Xextern BOOLEAN interactive; /* from plot.c */
- Xextern char *infile_name; /* from plot.c */
- X
- X/*
- X * equals() compares string value of token number t_num with str[], and
- X * returns TRUE if they are identical.
- X */
- Xequals(t_num, str)
- Xint t_num;
- Xchar *str;
- X{
- Xregister int i;
- X
- X if (!token[t_num].is_token)
- X return(FALSE); /* must be a value--can't be equal */
- X for (i = 0; i < token[t_num].length; i++) {
- X if (input_line[token[t_num].start_index+i] != str[i])
- X return(FALSE);
- X }
- X /* now return TRUE if at end of str[], FALSE if not */
- X return(str[i] == '\0');
- X}
- X
- X
- X
- X/*
- X * almost_equals() compares string value of token number t_num with str[], and
- X * returns TRUE if they are identical up to the first $ in str[].
- X */
- Xalmost_equals(t_num, str)
- Xint t_num;
- Xchar *str;
- X{
- Xregister int i;
- Xregister int after = 0;
- Xregister start = token[t_num].start_index;
- Xregister length = token[t_num].length;
- X
- X if (!token[t_num].is_token)
- X return(FALSE); /* must be a value--can't be equal */
- X for (i = 0; i < length + after; i++) {
- X if (str[i] != input_line[start + i]) {
- X if (str[i] != '$')
- X return(FALSE);
- X else {
- X after = 1;
- X start--; /* back up token ptr */
- X }
- X }
- X }
- X
- X /* i now beyond end of token string */
- X
- X return(after || str[i] == '$' || str[i] == '\0');
- X}
- X
- X
- X
- Xisstring(t_num)
- Xint t_num;
- X{
- X
- X return(token[t_num].is_token &&
- X (input_line[token[t_num].start_index] == '\'' ||
- X input_line[token[t_num].start_index] == '\"'));
- X}
- X
- X
- Xisnumber(t_num)
- Xint t_num;
- X{
- X return(!token[t_num].is_token);
- X}
- X
- X
- Xisletter(t_num)
- Xint t_num;
- X{
- X return(token[t_num].is_token &&
- X (isalpha(input_line[token[t_num].start_index])));
- X}
- X
- X
- X/*
- X * is_definition() returns TRUE if the next tokens are of the form
- X * identifier =
- X * -or-
- X * identifier ( identifer ) =
- X */
- Xis_definition(t_num)
- Xint t_num;
- X{
- X return (isletter(t_num) &&
- X (equals(t_num+1,"=") || /* variable */
- X (equals(t_num+1,"(") && /* function */
- X isletter(t_num+2) &&
- X equals(t_num+3,")") &&
- X equals(t_num+4,"=") )
- X ));
- X}
- X
- X
- X
- X/*
- X * copy_str() copies the string in token number t_num into str, appending
- X * a null. No more than MAX_ID_LEN chars are copied.
- X */
- Xcopy_str(str, t_num)
- Xchar str[];
- Xint t_num;
- X{
- Xregister int i = 0;
- Xregister int start = token[t_num].start_index;
- Xregister int count;
- X
- X if ((count = token[t_num].length) > MAX_ID_LEN)
- X count = MAX_ID_LEN;
- X do {
- X str[i++] = input_line[start++];
- X } while (i != count);
- X str[i] = '\0';
- X}
- X
- X
- X/*
- X * quote_str() does the same thing as copy_str, except it ignores the
- X * quotes at both ends. This seems redundant, but is done for
- X * efficency.
- X */
- Xquote_str(str, t_num)
- Xchar str[];
- Xint t_num;
- X{
- Xregister int i = 0;
- Xregister int start = token[t_num].start_index + 1;
- Xregister int count;
- X
- X if ((count = token[t_num].length - 2) > MAX_ID_LEN)
- X count = MAX_ID_LEN;
- X if (count>0) {
- X do {
- X str[i++] = input_line[start++];
- X } while (i != count);
- X }
- X str[i] = '\0';
- X}
- X
- X
- X/*
- X * quotel_str() does the same thing as quote_str, except it uses
- X * MAX_LINE_LEN instead of MAX_ID_LEN.
- X */
- Xquotel_str(str, t_num)
- Xchar str[];
- Xint t_num;
- X{
- Xregister int i = 0;
- Xregister int start = token[t_num].start_index + 1;
- Xregister int count;
- X
- X if ((count = token[t_num].length - 2) > MAX_LINE_LEN)
- X count = MAX_LINE_LEN;
- X if (count>0) {
- X do {
- X str[i++] = input_line[start++];
- X } while (i != count);
- X }
- X str[i] = '\0';
- X}
- X
- X
- X/*
- X * capture() copies into str[] the part of input_line[] which lies between
- X * the begining of token[start] and end of token[end].
- X */
- Xcapture(str,start,end)
- Xchar str[];
- Xint start,end;
- X{
- Xregister int i,e;
- X
- X e = token[end].start_index + token[end].length;
- X for (i = token[start].start_index; i < e && input_line[i] != '\0'; i++)
- X *str++ = input_line[i];
- X *str = '\0';
- X}
- X
- X
- X/*
- X * m_capture() is similar to capture(), but it mallocs storage for the
- X * string.
- X */
- Xm_capture(str,start,end)
- Xchar **str;
- Xint start,end;
- X{
- Xregister int i,e;
- Xregister char *s;
- X
- X if (*str) /* previous pointer to malloc'd memory there */
- X free(*str);
- X e = token[end].start_index + token[end].length;
- X *str = alloc((unsigned int)(e - token[start].start_index + 1), "string");
- X s = *str;
- X for (i = token[start].start_index; i < e && input_line[i] != '\0'; i++)
- X *s++ = input_line[i];
- X *s = '\0';
- X}
- X
- X
- X/*
- X * m_quote_capture() is similar to m_capture(), but it removes
- X quotes from either end if the string.
- X */
- Xm_quote_capture(str,start,end)
- Xchar **str;
- Xint start,end;
- X{
- Xregister int i,e;
- Xregister char *s;
- X
- X if (*str) /* previous pointer to malloc'd memory there */
- X free(*str);
- X e = token[end].start_index + token[end].length-1;
- X *str = alloc((unsigned int)(e - token[start].start_index + 1), "string");
- X s = *str;
- X for (i = token[start].start_index + 1; i < e && input_line[i] != '\0'; i++)
- X *s++ = input_line[i];
- X *s = '\0';
- X}
- X
- X
- Xconvert(val_ptr, t_num)
- Xstruct value *val_ptr;
- Xint t_num;
- X{
- X *val_ptr = token[t_num].l_val;
- X}
- X
- X
- X
- Xdisp_value(fp,val)
- XFILE *fp;
- Xstruct value *val;
- X{
- X switch(val->type) {
- X case INT:
- X fprintf(fp,"%d",val->v.int_val);
- X break;
- X case CMPLX:
- X if (val->v.cmplx_val.imag != 0.0 )
- X fprintf(fp,"{%g, %g}",
- X val->v.cmplx_val.real,val->v.cmplx_val.imag);
- X else
- X fprintf(fp,"%g", val->v.cmplx_val.real);
- X break;
- X default:
- X int_error("unknown type in disp_value()",NO_CARET);
- X }
- X}
- X
- X
- Xdouble
- Xreal(val) /* returns the real part of val */
- Xstruct value *val;
- X{
- X switch(val->type) {
- X case INT:
- X return((double) val->v.int_val);
- X case CMPLX:
- X return(val->v.cmplx_val.real);
- X }
- X int_error("unknown type in real()",NO_CARET);
- X /* NOTREACHED */
- X}
- X
- X
- Xdouble
- Ximag(val) /* returns the imag part of val */
- Xstruct value *val;
- X{
- X switch(val->type) {
- X case INT:
- X return(0.0);
- X case CMPLX:
- X return(val->v.cmplx_val.imag);
- X }
- X int_error("unknown type in real()",NO_CARET);
- X /* NOTREACHED */
- X}
- X
- X
- X
- Xdouble
- Xmagnitude(val) /* returns the magnitude of val */
- Xstruct value *val;
- X{
- X double sqrt();
- X
- X switch(val->type) {
- X case INT:
- X return((double) abs(val->v.int_val));
- X case CMPLX:
- X return(sqrt(val->v.cmplx_val.real*
- X val->v.cmplx_val.real +
- X val->v.cmplx_val.imag*
- X val->v.cmplx_val.imag));
- X }
- X int_error("unknown type in magnitude()",NO_CARET);
- X /* NOTREACHED */
- X}
- X
- X
- X
- Xdouble
- Xangle(val) /* returns the angle of val */
- Xstruct value *val;
- X{
- X double atan2();
- X
- X switch(val->type) {
- X case INT:
- X return((val->v.int_val > 0) ? 0.0 : Pi);
- X case CMPLX:
- X if (val->v.cmplx_val.imag == 0.0) {
- X if (val->v.cmplx_val.real >= 0.0)
- X return(0.0);
- X else
- X return(Pi);
- X }
- X return(atan2(val->v.cmplx_val.imag,
- X val->v.cmplx_val.real));
- X }
- X int_error("unknown type in angle()",NO_CARET);
- X /* NOTREACHED */
- X}
- X
- X
- Xstruct value *
- Xcomplex(a,realpart,imagpart)
- Xstruct value *a;
- Xdouble realpart, imagpart;
- X{
- X a->type = CMPLX;
- X a->v.cmplx_val.real = realpart;
- X a->v.cmplx_val.imag = imagpart;
- X return(a);
- X}
- X
- X
- Xstruct value *
- Xinteger(a,i)
- Xstruct value *a;
- Xint i;
- X{
- X a->type = INT;
- X a->v.int_val = i;
- X return(a);
- X}
- X
- X
- X
- Xos_error(str,t_num)
- Xchar str[];
- Xint t_num;
- X{
- X#ifdef vms
- Xstatic status[2] = {1, 0}; /* 1 is count of error msgs */
- X#endif
- X
- Xregister int i;
- X
- X /* reprint line if screen has been written to */
- X
- X if (t_num != NO_CARET) { /* put caret under error */
- X if (!screen_ok)
- X fprintf(stderr,"\n%s%s\n", PROMPT, input_line);
- X
- X for (i = 0; i < sizeof(PROMPT) - 1; i++)
- X (void) putc(' ',stderr);
- X for (i = 0; i < token[t_num].start_index; i++) {
- X (void) putc((input_line[i] == '\t') ? '\t' : ' ',stderr);
- X }
- X (void) putc('^',stderr);
- X (void) putc('\n',stderr);
- X }
- X
- X for (i = 0; i < sizeof(PROMPT) - 1; i++)
- X (void) putc(' ',stderr);
- X fprintf(stderr,"%s\n",str);
- X
- X for (i = 0; i < sizeof(PROMPT) - 1; i++)
- X (void) putc(' ',stderr);
- X if (!interactive)
- X if (infile_name != NULL)
- X fprintf(stderr,"\"%s\", line %d: ", infile_name, inline_num);
- X else
- X fprintf(stderr,"line %d: ", inline_num);
- X
- X
- X#ifdef vms
- X status[1] = vaxc$errno;
- X sys$putmsg(status);
- X (void) putc('\n',stderr);
- X#else
- X#ifdef __ZTC__
- X fprintf(stderr,"error number %d\n\n",errno);
- X#else
- X if (errno >= sys_nerr)
- X fprintf(stderr, "unknown errno %d\n\n", errno);
- X else
- X fprintf(stderr,"(%s)\n\n",sys_errlist[errno]);
- X#endif
- X#endif
- X
- X longjmp(env, TRUE); /* bail out to command line */
- X}
- X
- X
- Xint_error(str,t_num)
- Xchar str[];
- Xint t_num;
- X{
- Xregister int i;
- X
- X /* reprint line if screen has been written to */
- X
- X if (t_num != NO_CARET) { /* put caret under error */
- X if (!screen_ok)
- X fprintf(stderr,"\n%s%s\n", PROMPT, input_line);
- X
- X for (i = 0; i < sizeof(PROMPT) - 1; i++)
- X (void) putc(' ',stderr);
- X for (i = 0; i < token[t_num].start_index; i++) {
- X (void) putc((input_line[i] == '\t') ? '\t' : ' ',stderr);
- X }
- X (void) putc('^',stderr);
- X (void) putc('\n',stderr);
- X }
- X
- X for (i = 0; i < sizeof(PROMPT) - 1; i++)
- X (void) putc(' ',stderr);
- X if (!interactive)
- X if (infile_name != NULL)
- X fprintf(stderr,"\"%s\", line %d: ", infile_name, inline_num);
- X else
- X fprintf(stderr,"line %d: ", inline_num);
- X fprintf(stderr,"%s\n\n", str);
- X
- X longjmp(env, TRUE); /* bail out to command line */
- X}
- X
- X/* Lower-case the given string (DFK) */
- X/* Done in place. */
- Xvoid
- Xlower_case(s)
- X char *s;
- X{
- X register char *p = s;
- X
- X while (*p != '\0') {
- X if (isupper(*p))
- X *p = tolower(*p);
- X p++;
- X }
- X}
- X
- X/* Squash spaces in the given string (DFK) */
- X/* That is, reduce all multiple white-space chars to single spaces */
- X/* Done in place. */
- Xvoid
- Xsquash_spaces(s)
- X char *s;
- X{
- X register char *r = s; /* reading point */
- X register char *w = s; /* writing point */
- X BOOLEAN space = FALSE; /* TRUE if we've already copied a space */
- X
- X for (w = r = s; *r != '\0'; r++) {
- X if (isspace(*r)) {
- X /* white space; only copy if we haven't just copied a space */
- X if (!space) {
- X space = TRUE;
- X *w++ = ' ';
- X } /* else ignore multiple spaces */
- X } else {
- X /* non-space character; copy it and clear flag */
- X *w++ = *r;
- X space = FALSE;
- X }
- X }
- X *w = '\0'; /* null terminate string */
- X}
- X
- *-*-END-of-util.c-*-*
- echo x - version.c
- sed 's/^X//' >version.c <<'*-*-END-of-version.c-*-*'
- Xchar version[] = "2.0";
- Xchar patchlevel[] = "0";
- Xchar date[] = "Wed Mar 7 22:18:59 EST 1990";
- X
- X/* override in Makefile */
- X#ifndef CONTACT
- X# define CONTACT "pixar!bug-gnuplot@sun.com";
- X#endif
- Xchar bug_email[] = CONTACT;
- *-*-END-of-version.c-*-*
- exit
-
-
-