148505Sbostic /*-
2*61363Sbostic * Copyright (c) 1980, 1993
3*61363Sbostic * The Regents of the University of California. All rights reserved.
448505Sbostic *
548505Sbostic * %sccs.include.proprietary.c%
619971Sdist */
719971Sdist
815439Sralph #ifndef lint
9*61363Sbostic static char sccsid[] = "@(#)open.c 8.1 (Berkeley) 06/04/93";
1048505Sbostic #endif /* not lint */
1115439Sralph
1215439Sralph /*
1315439Sralph * This accepts plot file formats and produces the appropriate plots
1415439Sralph * for dumb terminals. It can also be used for printing terminals and
1515439Sralph * lineprinter listings, although there is no way to specify number of
1615439Sralph * lines and columns different from your terminal. This would be easy
1715439Sralph * to change, and is left as an exercise for the reader.
1815439Sralph */
1915439Sralph
2015439Sralph #include <signal.h>
2115439Sralph #include "dumb.h"
2215439Sralph
2315439Sralph int minX, rangeX; /* min and range of x */
2415439Sralph int minY, rangeY; /* min and range of y */
2515439Sralph int currentx,currenty;
2615439Sralph int COLS,LINES;
2715439Sralph
2815439Sralph /* A very large screen! (probably should use malloc) */
2915439Sralph char screenmat[MAXCOLS][MAXLINES];
3015439Sralph
openpl()3115439Sralph openpl()
3215439Sralph {
3346635Sbostic void closepl();
3415439Sralph int i, j;
3515439Sralph char *term, *getenv();
3615439Sralph char bp[1024];
3715439Sralph
3815439Sralph term = getenv("TERM");
3915439Sralph tgetent(bp, term);
4015439Sralph
4115439Sralph COLS = tgetnum("co");
4215439Sralph if (COLS > MAXCOLS)
4315439Sralph COLS = MAXCOLS;
4415439Sralph if (COLS < 0)
4515439Sralph COLS = 48; /* lower bound on # of cols? */
4615439Sralph COLS--; /* prevent auto wrap */
4715439Sralph
4815439Sralph LINES = tgetnum("li");
4915439Sralph if (LINES > MAXLINES)
5015439Sralph LINES = MAXLINES;
5115439Sralph if (LINES < 0)
5215439Sralph LINES = 20; /* lower bound on # of lines? */
5315439Sralph
5415439Sralph for(i=0; i<COLS; i++)
5515439Sralph for(j=0; j<LINES; j++)
5615439Sralph screenmat[i][j] = ' ';
5715439Sralph
5815439Sralph signal(SIGINT, closepl);
5915439Sralph currentx = currenty = 0;
6015439Sralph }
61