File: regis.trm

package info (click to toggle)
gnuplot 3.5beta6.340-5
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 4,792 kB
  • ctags: 4,205
  • sloc: ansic: 41,878; asm: 539; makefile: 498; objc: 379; csh: 297; sh: 277; pascal: 194; perl: 138; lisp: 88
file content (251 lines) | stat: -rw-r--r-- 6,056 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
/*
 * $Id: regis.trm,v 1.16 1997/04/10 02:34:33 drd Exp $
 *
 */

/* GNUPLOT - regis.trm */
/*
 * Copyright (C) 1990 - 1993, 1997
 *
 * Permission to use, copy, and distribute this software and its
 * documentation for any purpose with or without fee is hereby granted, 
 * provided that the above copyright notice appear in all copies and 
 * that both that copyright notice and this permission notice appear 
 * in supporting documentation.
 *
 * Permission to modify the software is granted, but not the right to
 * distribute the modified code.  Modifications are to be distributed 
 * as patches to released version.
 *  
 * This software  is provided "as is" without express or implied warranty.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  REGIS devices
 *
 * AUTHORS
 *  Colin Kelley, Thomas Williams
 * 
 * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
 * 
 */

#ifndef GOT_DRIVER_H
#include "driver.h"
#endif

#ifdef TERM_REGISTER
register_term(regis)
#endif


#ifdef TERM_PROTO
TERM_PUBLIC void REGISinit __PROTO((void));
TERM_PUBLIC void REGISgraphics __PROTO((void));
TERM_PUBLIC void REGISinit __PROTO((void));
TERM_PUBLIC void REGISgraphics __PROTO((void));
TERM_PUBLIC void REGIStext __PROTO((void));
TERM_PUBLIC void REGISlinetype __PROTO((int linetype));
TERM_PUBLIC void REGISmove __PROTO((unsigned int x, unsigned int y));
TERM_PUBLIC void REGISvector __PROTO((unsigned int x, unsigned int y));
TERM_PUBLIC void REGISput_text __PROTO((unsigned int x, unsigned int y, char *str));
TERM_PUBLIC int REGIStext_angle __PROTO((int ang));
TERM_PUBLIC void REGISreset __PROTO((void));
TERM_PUBLIC void REGISoptions __PROTO((void));

#define REGISXMAX 800             
#define REGISYMAX 440

#define REGISXLAST (REGISXMAX - 1)
#define REGISYLAST (REGISYMAX - 1)

#define REGISVCHAR		20  	
#define REGISHCHAR		9
#define REGISVTIC		8
#define REGISHTIC		6

/* is defined in plot.h
#define TRUE 1
#define FALSE 0
*/
#endif



#ifndef TERM_PROTO_ONLY
#ifdef TERM_BODY

static int REGIS16color=FALSE;

static int REGISang = 0;

TERM_PUBLIC void REGISinit()
{
	fprintf(outfile,"\033[r\033[24;1H");
/*                   1     2
	1. reset scrolling region
	2. locate cursor on bottom line
*/
}


/* thanks to calmasd!dko (Dan O'Neill) for adding S(E) for vt125s */
TERM_PUBLIC void REGISgraphics()
{
    fprintf(outfile,"\033[2J\033P1pS(C0)S(E)T(A0)\n");
/*                   1      2      3    4   5
        1. clear screen
        2. enter ReGIS graphics
        3. turn off graphics diamond cursor
        4. clear graphics screen
        5. character set option.
*/
        (void) REGIStext_angle(0); /* select text size and angle */
}


TERM_PUBLIC void REGIStext()
{
	fprintf(outfile,"\033\\\033[24;1H");
/*	                   1    2
	1. Leave ReGIS graphics mode
 	2. locate cursor on last line of screen
*/
}


TERM_PUBLIC void REGISlinetype(linetype)
int     linetype;
{
      /* This will change color in order G,R,B,G-dot,R-dot,B-dot */

static int in_16_map[15+2] = {7,7,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
static int lt_16_map[15+2] = {1,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
static int in_map[9 + 2] = {2, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1};
static int lt_map[9 + 2] = {1, 4, 1, 1, 1, 4, 4, 4, 6, 6, 6};
   
   	if(!REGIS16color)
   	{	if (linetype >= 9)
   			linetype %= 9;
   		fprintf(outfile, "W(I%d)\n", in_map[linetype + 2]);
   		fprintf(outfile, "W(P%d)\n", lt_map[linetype + 2]);
   	}
   	else
   	{	if(linetype >=15)
   			linetype %= 15;
   		fprintf(outfile, "W(I%d)\n", in_16_map[linetype + 2]);
   		fprintf(outfile, "W(P%d)\n", lt_16_map[linetype + 2]);
   	}
}



/*
** The \n was added in the functions below (and above) in order to not cause
** a buffer overflow in devices that can't deal with long line lengths.
** The DEC vt-340 doesn't need this, but Reflection 4, a vt-340 emulator
** for PC's under MS-DOS and Microsoft Windows does need it.
** Also needed for DECterm, a vt-340 emulator for use with Motif 1.0
** on Open/VMS.
** NGB 9/13/93
*/

TERM_PUBLIC void REGISmove(x,y)
unsigned int x,y;
{
	fprintf(outfile,"P[%d,%d]\n",x,REGISYLAST-y);
}


TERM_PUBLIC void REGISvector(x,y)
unsigned int x,y;
{
	fprintf(outfile,"v[]v[%d,%d]\n",x,REGISYLAST - y);
/* the initial v[] is needed to get the first pixel plotted */
}


/* put_text and text_angle by rjl */
TERM_PUBLIC void REGISput_text(x,y,str)
unsigned int x, y;
char *str;
{
	if (REGISang==1)
		REGISmove(x-REGISVCHAR/2-1,y);
	else
		REGISmove(x,y+REGISVCHAR/2-1);
	(void) putc('T',outfile); (void) putc('\'',outfile);
	while (*str) {
		(void) putc(*str,outfile);
		if (*str == '\'')
			(void) putc('\'',outfile);	/* send out another one */
		str++;
	}
	(void) putc('\'',outfile);
	(void) putc('\n',outfile);
}


TERM_PUBLIC int REGIStext_angle(ang)
int ang;
{
	REGISang = ang;
	if (ang == 1)
		fputs("T(D90,S1)\n",outfile);
	else
		fputs("T(D0,S1)\n",outfile);
	return TRUE;
}


TERM_PUBLIC void REGISreset()
{
	fprintf(outfile,"\033[2J\033[24;1H");
}

TERM_PUBLIC void REGISoptions()
{	int i=0;
   	struct value a;

   	if(!END_OF_COMMAND)
   	{	i=(int)real(const_express(&a));
   	}
   	REGIS16color= (i==16);
   	sprintf(term_options,"%s",REGIS16color?"16":"4");
}

#endif


#ifdef TERM_TABLE

TERM_TABLE_START(regis_driver)

      "regis", "REGIS graphics language",
	   REGISXMAX, REGISYMAX, REGISVCHAR, REGISHCHAR, 
	   REGISVTIC, REGISHTIC, REGISoptions, REGISinit, REGISreset, 
	   REGIStext, null_scale, REGISgraphics, REGISmove, REGISvector,
	   REGISlinetype, REGISput_text, REGIStext_angle, 
	   null_justify_text, line_and_point, do_arrow, set_font_null}

#undef LAST_TERM
#define LAST_TERM regis_driver
#endif
#endif /* TERM_PROTO_ONLY */

#ifdef TERM_HELP
START_HELP(regis)
"1 regis",
"?set terminal regis",
"?set term regis",
"?terminal regis",
"?term regis",
"?regis",
" The `regis` terminal device generates output in the REGIS graphics language.",
" It has the option of using 4 (the default) or 16 colors.",
"",
" Syntax:",
"       set terminal regis {4 | 16}"
END_HELP(regis)
#endif