xref: /original-bsd/lib/libplot/dumb/open.c (revision c3e32dec)
1 /*-
2  * Copyright (c) 1980, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.proprietary.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)open.c	8.1 (Berkeley) 06/04/93";
10 #endif /* not lint */
11 
12 /*
13  * This accepts plot file formats and produces the appropriate plots
14  * for dumb terminals.  It can also be used for printing terminals and
15  * lineprinter listings, although there is no way to specify number of
16  * lines and columns different from your terminal.  This would be easy
17  * to change, and is left as an exercise for the reader.
18  */
19 
20 #include <signal.h>
21 #include "dumb.h"
22 
23 int minX, rangeX;	/* min and range of x */
24 int minY, rangeY;	/* min and range of y */
25 int currentx,currenty;
26 int COLS,LINES;
27 
28 /* A very large screen! (probably should use malloc) */
29 char screenmat[MAXCOLS][MAXLINES];
30 
31 openpl()
32 {
33 	void closepl();
34 	int i, j;
35 	char *term, *getenv();
36 	char bp[1024];
37 
38 	term = getenv("TERM");
39 	tgetent(bp, term);
40 
41 	COLS = tgetnum("co");
42 	if (COLS > MAXCOLS)
43 		COLS = MAXCOLS;
44 	if (COLS < 0)
45 		COLS = 48;	/* lower bound on # of cols? */
46 	COLS--;				/* prevent auto wrap */
47 
48 	LINES = tgetnum("li");
49 	if (LINES > MAXLINES)
50 		LINES = MAXLINES;
51 	if (LINES < 0)
52 		LINES = 20;	/* lower bound on # of lines? */
53 
54 	for(i=0; i<COLS; i++)
55 		for(j=0; j<LINES; j++)
56 			screenmat[i][j] = ' ';
57 
58 	signal(SIGINT, closepl);
59 	currentx = currenty = 0;
60 }
61