xref: /csrg-svn/lib/libplot/dumb/open.c (revision 19971)
1*19971Sdist /*
2*19971Sdist  * Copyright (c) 1980 Regents of the University of California.
3*19971Sdist  * All rights reserved.  The Berkeley software License Agreement
4*19971Sdist  * specifies the terms and conditions for redistribution.
5*19971Sdist  */
6*19971Sdist 
715439Sralph #ifndef lint
8*19971Sdist static char sccsid[] = "@(#)open.c	5.1 (Berkeley) 05/07/85";
9*19971Sdist #endif not lint
1015439Sralph 
1115439Sralph /*
1215439Sralph  * This accepts plot file formats and produces the appropriate plots
1315439Sralph  * for dumb terminals.  It can also be used for printing terminals and
1415439Sralph  * lineprinter listings, although there is no way to specify number of
1515439Sralph  * lines and columns different from your terminal.  This would be easy
1615439Sralph  * to change, and is left as an exercise for the reader.
1715439Sralph  */
1815439Sralph 
1915439Sralph #include <signal.h>
2015439Sralph #include "dumb.h"
2115439Sralph 
2215439Sralph int minX, rangeX;	/* min and range of x */
2315439Sralph int minY, rangeY;	/* min and range of y */
2415439Sralph int currentx,currenty;
2515439Sralph int COLS,LINES;
2615439Sralph 
2715439Sralph /* A very large screen! (probably should use malloc) */
2815439Sralph char screenmat[MAXCOLS][MAXLINES];
2915439Sralph 
3015439Sralph openpl()
3115439Sralph {
3215439Sralph 	int closepl();
3315439Sralph 	int i, j;
3415439Sralph 	char *term, *getenv();
3515439Sralph 	char bp[1024];
3615439Sralph 
3715439Sralph 	term = getenv("TERM");
3815439Sralph 	tgetent(bp, term);
3915439Sralph 
4015439Sralph 	COLS = tgetnum("co");
4115439Sralph 	if (COLS > MAXCOLS)
4215439Sralph 		COLS = MAXCOLS;
4315439Sralph 	if (COLS < 0)
4415439Sralph 		COLS = 48;	/* lower bound on # of cols? */
4515439Sralph 	COLS--;				/* prevent auto wrap */
4615439Sralph 
4715439Sralph 	LINES = tgetnum("li");
4815439Sralph 	if (LINES > MAXLINES)
4915439Sralph 		LINES = MAXLINES;
5015439Sralph 	if (LINES < 0)
5115439Sralph 		LINES = 20;	/* lower bound on # of lines? */
5215439Sralph 
5315439Sralph 	for(i=0; i<COLS; i++)
5415439Sralph 		for(j=0; j<LINES; j++)
5515439Sralph 			screenmat[i][j] = ' ';
5615439Sralph 
5715439Sralph 	signal(SIGINT, closepl);
5815439Sralph 	currentx = currenty = 0;
5915439Sralph }
60