1 /* Hello, Emacs, this is -*-C-*-
2 * $Id: tek.trm,v 1.18.2.1 2009/08/14 01:23:06 sfeam Exp $
6 /* GNUPLOT - tek.trm */
9 * Copyright 1990 - 1993, 1998, 2004
11 * Permission to use, copy, and distribute this software and its
12 * documentation for any purpose with or without fee is hereby granted,
13 * provided that the above copyright notice appear in all copies and
14 * that both that copyright notice and this permission notice appear
15 * in supporting documentation.
17 * Permission to modify the software is granted, but not the right to
18 * distribute the complete modified source code. Modifications are to
19 * be distributed as patches to the released version. Permission to
20 * distribute binaries produced by compiling modified sources is granted,
22 * 1. distribute the corresponding source modifications from the
23 * released version in the form of a patch file along with the binaries,
24 * 2. add special version identification to distinguish your version
25 * in addition to the base release version number,
26 * 3. provide your name and address as the primary contact for the
27 * support of your modified version, and
28 * 4. retain our contact information in regard to use of the base
30 * Permission to distribute the released version of the source code along
31 * with corresponding source modifications in the form of a patch file is
32 * granted with same provisions 2 through 4 for binary distributions.
34 * This software is provided "as is" without express or implied warranty
35 * to the extent permitted by applicable law.
39 * This file is included by ../term.c.
41 * This terminal driver supports:
42 * tek40xx, bitgraph, kermit_color_tek40xx, kermit_mono_tek40xx, selanar
46 * Colin Kelley, Thomas Williams, Russell Lang
48 * send your comments or suggestions to (gnuplot-info@lists.sourceforge.net).
53 * Modified June 1995 Ian MacPhedran to support newterm format
71 register_term(kc_tek40)
72 register_term(km_tek40)
75 register_term(selanar)
78 register_term(bitgraph)
83 #endif /* TERM_REGISTER */
86 TERM_PUBLIC void TEK40init __PROTO((void));
87 TERM_PUBLIC void TEK40graphics __PROTO((void));
88 TERM_PUBLIC void TEK40text __PROTO((void));
89 TERM_PUBLIC void TEK40linetype __PROTO((int linetype));
90 TERM_PUBLIC void TEK40move __PROTO((unsigned int x, unsigned int y));
91 TERM_PUBLIC void TEK40vector __PROTO((unsigned int x, unsigned int y));
92 TERM_PUBLIC void TEK40put_text __PROTO((unsigned int x, unsigned int y, const char str[]));
93 TERM_PUBLIC void TEK40reset __PROTO((void));
94 TERM_PUBLIC void BG_text __PROTO((void));
95 TERM_PUBLIC void BG_put_text __PROTO((unsigned int x, unsigned int y, const char str[]));
96 TERM_PUBLIC void KTEK40graphics __PROTO((void));
97 TERM_PUBLIC void KTEK40Ctext __PROTO((void));
98 TERM_PUBLIC void KTEK40Clinetype __PROTO((int linetype));
99 TERM_PUBLIC void KTEK40Mlinetype __PROTO((int linetype));
100 TERM_PUBLIC void KTEK40reset __PROTO((void));
101 TERM_PUBLIC void SEL_init __PROTO((void));
102 TERM_PUBLIC void SEL_graphics __PROTO((void));
103 TERM_PUBLIC void SEL_text __PROTO((void));
104 TERM_PUBLIC void SEL_reset __PROTO((void));
105 TERM_PUBLIC void VTTEK40init __PROTO((void));
106 TERM_PUBLIC void VTTEK40reset __PROTO((void));
107 TERM_PUBLIC void VTTEK40linetype __PROTO((int linetype));
108 TERM_PUBLIC void VTTEK40put_text __PROTO((unsigned int x, unsigned int y, const char str[]));
109 TERM_PUBLIC void CTEK_linetype __PROTO((int linetype));
110 TERM_PUBLIC void CTEK_move __PROTO((unsigned int x, unsigned int y));
111 TERM_PUBLIC void CTEK_vector __PROTO((unsigned int x, unsigned int y));
112 TERM_PUBLIC void XTERM_graphics __PROTO((void));
113 TERM_PUBLIC void XTERM_resume __PROTO((void));
114 TERM_PUBLIC void XTERM_text __PROTO((void));
115 TERM_PUBLIC int XTERM_set_font __PROTO((const char * fontname));
117 #endif /* TERM_PROTO */
119 #ifndef TERM_PROTO_ONLY
124 #define TEK40XMAX 1024
125 #define TEK40YMAX 780
127 #define TEK40XLAST (TEK40XMAX - 1)
128 #define TEK40YLAST (TEK40YMAX - 1)
130 #define TEK40VCHAR 25
131 #define TEK40HCHAR 14
135 #define HX 0x20 /* bit pattern to OR over 5-bit data */
141 #define UPPER5 (31<<5)
156 fputs("\033\014", gpoutfile);
160 (void) fflush(gpoutfile);
162 /* sleep 1 second to allow screen time to clear on real
163 tektronix terminals */
170 (void) fflush(gpoutfile); /* finish the graphics */
173 fputs("\037", gpoutfile);
175 1. into alphanumerics
184 TEK40linetype(int linetype)
190 TEK40move(unsigned int x, unsigned int y)
192 (void) putc('\035', gpoutfile); /* into graphics */
198 TEK40vector(unsigned int x, unsigned int y)
200 (void) putc((HY | (y & UPPER5) >> 5), gpoutfile);
201 (void) putc((LY | (y & LOWER5)), gpoutfile);
202 (void) putc((HX | (x & UPPER5) >> 5), gpoutfile);
203 (void) putc((LX | (x & LOWER5)), gpoutfile);
208 TEK40put_text(unsigned int x, unsigned int y, const char str[])
210 TEK40move(x, y - 11);
211 fprintf(gpoutfile, "\037%s\n", str);
223 /* thanks to dukecdu!evs (Ed Simpson) for the BBN BitGraph driver */
227 #define BG_XMAX 768 /* width of plot area */
228 #define BG_YMAX 768 /* height of plot area */
229 #define BG_SCREEN_HEIGHT 1024 /* full screen height */
231 #define BG_XLAST (BG_XMAX - 1)
232 #define BG_YLAST (BG_YMAX - 1)
240 #define BG_init TEK40init
242 #define BG_graphics TEK40graphics
245 #define BG_linetype TEK40linetype
247 #define BG_move TEK40move
249 #define BG_vector TEK40vector
256 (void) fflush(gpoutfile); /* finish the graphics */
258 BG_move(0, BG_SCREEN_HEIGHT - 2 * BG_VCHAR);
259 fputs("\037", gpoutfile);
261 1. into alphanumerics
267 BG_put_text(unsigned int x, unsigned int y, const char str[])
270 fprintf(gpoutfile, "\037%s\n", str);
274 #define BG_reset TEK40reset
276 #endif /* BITGRAPH */
279 /* Color and Monochrome specials for the MS-DOS Kermit Tektronix Emulator
280 by Russell Lang, eln272v@monu1.cc.monash.oz */
284 #define KTEK40HCHAR 13
293 fputs("\033\014", gpoutfile);
297 /* kermit tektronix emulation doesn't need to wait */
304 KTEK40Clinetype(0); /* change to green */
310 /* special color linetypes for MS-DOS Kermit v2.31 tektronix emulator */
311 /* 0 = normal, 1 = bright
312 foreground color (30-37) = 30 + colors
313 where colors are 1=red, 2=green, 4=blue */
314 static const char *kermit_color[15] =
315 {"\033[0;37m", "\033[1;30m",
316 "\033[0;32m", "\033[0;36m", "\033[0;31m", "\033[0;35m",
317 "\033[1;34m", "\033[1;33m", "\033[1;31m", "\033[1;37m",
318 "\033[1;35m", "\033[1;32m", "\033[1;36m", "\033[0;34m",
322 KTEK40Clinetype(int linetype)
328 fprintf(gpoutfile, "%s", kermit_color[linetype + 2]);
332 /* linetypes for MS-DOS Kermit v2.30 tektronix emulator */
333 /* `=solid, a=fine dots, b=short dashes, c=dash dot,
334 d=long dash dot, e=dash dot dot */
335 static const char *kerm_linetype = "`a`abcde";
338 KTEK40Mlinetype(int linetype)
344 fprintf(gpoutfile, "\033%c", kerm_linetype[linetype + 2]);
350 fputs("\030\n", gpoutfile); /* turn off Tek emulation */
359 /* thanks to sask!macphed (Geoff Coleman and Ian Macphedran) for the
367 fputs("\033\062", gpoutfile);
377 fputs("\033[H\033[J\033\061\033\014", gpoutfile);
393 (void) fflush(gpoutfile); /* finish the graphics */
396 fputs("\033\062", gpoutfile);
408 fputs("\033\061\033\012\033\062\033[H\033[J", gpoutfile);
424 fputs("\033[?38h", gpoutfile);
427 /* sleep 1 second to allow screen time to clear on some terminals */
436 fputs("\033[?38l", gpoutfile);
439 /* sleep 1 second to allow screen time to clear on some terminals */
445 /* linetypes for VT-type terminals in tektronix emulator mode */
446 /* `=solid, a=fine dots, b=short dashes, c=dash dot,
447 d=long dash dot, h=bold solid, i=bold fine dots, j=bold short dashes,
448 k=bold dash dot, l=bold long dash dot */
449 static const char *vt_linetype = "`a`abcdhijkl";
450 static int last_vt_linetype = 0;
453 VTTEK40linetype(int linetype)
459 fprintf(gpoutfile, "\033%c", vt_linetype[linetype + 2]);
460 last_vt_linetype = linetype;
464 VTTEK40put_text(unsigned int x, unsigned int y, const char str[])
467 linetype = last_vt_linetype;
469 TEK40put_text(x, y, str);
470 VTTEK40linetype(linetype);
480 fputs("\033[?38h", gpoutfile);
486 fputs("\033[?38l", gpoutfile);
493 /* tek40xx (monochrome) with linetype support by Jay I. Choe */
496 /*#define ABS(A) (((A)>=0)? (A):-(A))*/
497 #define SIGN(A) (((A) >= 0)? 1:-1)
499 static void CT_solid_vector __PROTO((int x, int y));
500 static void CT_draw_vpoint __PROTO((int x, int y, int last));
501 static void CT_pattern_vector __PROTO((int x1, int y1));
503 /* CT_lines are line types defined as bit pattern */
504 static unsigned long CT_lines[] =
505 {~(unsigned long)0, /* solid line */
506 0x000fffff, /* long dash */
507 0x00ff00ff, /* short dash */
508 0x00f00fff, /* dash-dot */
509 0x00f07fff, /* long dash - dot */
514 /* current line pattern */
515 static unsigned long *CT_pattern = &CT_lines[0];
517 /* we need to keep track of tek cursor location */
518 static int CT_last_linetype = 0, CT_last_x, CT_last_y;
521 CTEK_linetype(int linetype)
525 linetype %= (sizeof(CT_lines) / sizeof(unsigned long));
526 CT_pattern = &CT_lines[linetype];
527 CT_last_linetype = linetype;
531 CTEK_move(unsigned int x, unsigned int y)
539 CT_solid_vector(int x, int y)
547 simulate pixel draw using tek vector draw.
548 delays actual line drawing until maximum line segment is determined
549 (or first/last point is defined)
551 static int CT_penon = 0; /* is Pen on? */
554 CT_draw_vpoint(int x, int y, int last)
556 static int xx0, yy0, xx1, yy1;
558 if ((*CT_pattern) & 1) {
559 if (CT_penon) { /* This point is a continuation of current line */
562 } else { /* beginning of new line */
567 *CT_pattern = ((*CT_pattern) >> 1) | ((unsigned long)1 << 31); /* rotate the pattern */
568 if (last) { /* draw the line anyway if this is the last point */
570 TEK40vector(xx1, yy1);
573 } else { /* do not draw this pixel */
574 if (CT_penon) { /* last line segment ended at the previous pixel. */
577 TEK40vector(xx1, yy1);
580 *CT_pattern = (*CT_pattern) >> 1; /* rotate the current pattern */
585 draw vector line with pattern
589 CT_pattern_vector(int x1, int y1)
591 int op; /* order parameter */
596 int ax = ABS(dx) << 1;
597 int ay = ABS(dy) << 1;
602 for (op = ay - (ax >> 1); x0 != x1; x0 += sx, op += ay) {
603 CT_draw_vpoint(x0, y0, 0);
604 if (op > 0 || (op == 0 && sx == 1)) {
609 } else { /* ax < ay */
610 for (op = ax - (ay >> 1); y0 != y1; y0 += sy, op += ax) {
611 CT_draw_vpoint(x0, y0, 0);
612 if (op > 0 || (op == 0 && sy == 1)) {
618 CT_draw_vpoint(x0, y0, 1); /* last point */
624 CTEK_vector(unsigned int x, unsigned int y)
626 if (CT_last_linetype <= 0)
627 CT_solid_vector(x, y);
629 CT_pattern_vector(x, y);
636 #define XT_TEK_ESC "\033"
637 #define XT_TEK_GFX XT_TEK_ESC "[?38h"
638 #define XT_TEK_ANSI XT_TEK_ESC "\003"
639 #define XT_TEK_CLR XT_TEK_ESC "\014"
640 #define XT_TEK_ALPHA "\037"
642 static const char *xt_tek_fontsize = "89:;";
648 fputs(XT_TEK_CLR, gpoutfile);
655 fputs(XT_TEK_GFX, gpoutfile);
662 fputs(XT_TEK_ALPHA XT_TEK_ANSI, gpoutfile);
667 XTERM_set_font(const char *fontname)
671 size_t lp = strlen(fontname);
672 if (lp>0) size = fontname[lp-1]-'1';
674 fprintf(gpoutfile, XT_TEK_ESC "%c",
675 xt_tek_fontsize[size>0&&size<4?size:0]);
681 #endif /* TERM_BODY */
685 TERM_TABLE_START(tek40_driver)
687 "tek40xx", "Tektronix 4010 and others; most TEK emulators",
688 TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR,
689 TEK40VTIC, TEK40HTIC, options_null, TEK40init, TEK40reset,
690 TEK40text, null_scale, TEK40graphics, TEK40move, TEK40vector,
691 TEK40linetype, TEK40put_text, null_text_angle,
692 null_justify_text, line_and_point, do_arrow, set_font_null
694 "tek40xx", "Tektronix 4010 and others; most TEK emulators",
695 TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR,
696 TEK40VTIC, TEK40HTIC, options_null, TEK40init, TEK40reset,
697 TEK40text, null_scale, TEK40graphics, CTEK_move, CTEK_vector,
698 CTEK_linetype, TEK40put_text, null_text_angle,
699 null_justify_text, line_and_point, do_arrow, set_font_null
701 TERM_TABLE_END(tek40_driver)
704 #define LAST_TERM tek40_driver
707 TERM_TABLE_START(vttek_driver)
708 "vttek", "VT-like tek40xx terminal emulator",
709 TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR,
710 TEK40VTIC, TEK40HTIC, options_null, VTTEK40init, VTTEK40reset,
711 TEK40text, null_scale, TEK40graphics, TEK40move, TEK40vector,
712 VTTEK40linetype, VTTEK40put_text, null_text_angle,
713 null_justify_text, line_and_point, do_arrow, set_font_null
714 TERM_TABLE_END(vttek_driver)
717 #define LAST_TERM vttek_driver
722 TERM_TABLE_START(kc_tek40_driver)
723 "kc_tek40xx", "MS-DOS Kermit Tek4010 terminal emulator - color",
724 TEK40XMAX, TEK40YMAX, TEK40VCHAR, KTEK40HCHAR,
725 TEK40VTIC, TEK40HTIC, options_null, TEK40init, KTEK40reset,
726 KTEK40Ctext, null_scale, KTEK40graphics, TEK40move, TEK40vector,
727 KTEK40Clinetype, TEK40put_text, null_text_angle,
728 null_justify_text, do_point, do_arrow, set_font_null
729 TERM_TABLE_END(kc_tek40_driver)
732 #define LAST_TERM kc_tek40_driver
734 TERM_TABLE_START(km_tek40_driver)
735 "km_tek40xx", "MS-DOS Kermit Tek4010 terminal emulator - monochrome",
736 TEK40XMAX, TEK40YMAX, TEK40VCHAR, KTEK40HCHAR,
737 TEK40VTIC, TEK40HTIC, options_null, TEK40init, KTEK40reset,
738 TEK40text, null_scale, KTEK40graphics, TEK40move, TEK40vector,
739 KTEK40Mlinetype, TEK40put_text, null_text_angle,
740 null_justify_text, line_and_point, do_arrow, set_font_null
741 TERM_TABLE_END(km_tek40_driver)
744 #define LAST_TERM km_tek40_driver
749 TERM_TABLE_START(selanar_driver)
750 "selanar", "Selanar",
751 TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR,
752 TEK40VTIC, TEK40HTIC, options_null, SEL_init, SEL_reset,
753 SEL_text, null_scale, SEL_graphics, TEK40move, TEK40vector,
754 TEK40linetype, TEK40put_text, null_text_angle,
755 null_justify_text, line_and_point, do_arrow, set_font_null
756 TERM_TABLE_END(selanar_driver)
759 #define LAST_TERM selanar_driver
764 TERM_TABLE_START(bitgraph_driver)
765 "bitgraph", "BBN Bitgraph Terminal",
766 BG_XMAX, BG_YMAX, BG_VCHAR, BG_HCHAR,
767 BG_VTIC, BG_HTIC, options_null, BG_init, BG_reset,
768 BG_text, null_scale, BG_graphics, BG_move, BG_vector,
769 BG_linetype, BG_put_text, null_text_angle,
770 null_justify_text, line_and_point, do_arrow, set_font_null
771 TERM_TABLE_END(bitgraph_driver)
774 #define LAST_TERM bitgraph_driver
776 #endif /* BITGRAPH */
779 TERM_TABLE_START(xterm_driver)
780 "xterm", "Xterm Tektronix 4014 Mode",
781 TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR,
782 TEK40VTIC, TEK40HTIC, options_null, TEK40init, TEK40reset,
783 XTERM_text, null_scale, XTERM_graphics, TEK40move, TEK40vector,
784 VTTEK40linetype, VTTEK40put_text, null_text_angle,
785 null_justify_text, line_and_point, do_arrow, XTERM_set_font, 0,
786 TERM_CAN_MULTIPLOT|TERM_NO_OUTPUTFILE, XTERM_text, XTERM_resume
787 TERM_TABLE_END(xterm_driver)
790 #define LAST_TERM xterm_driver
794 #endif /* TERM_TABLE */
796 #endif /* TERM_PROTO_ONLY */
801 "?commands set terminal tek40xx",
802 "?set terminal tek40xx",
807 "?commands set terminal vttek",
808 "?set terminal vttek",
813 "?commands set terminal kc-tek40xx",
814 "?set terminal kc-tek40xx",
815 "?set term kc-tek40xx",
816 "?terminal kc-tek40xx",
819 "?commands set terminal km-tek40xx",
820 "?set terminal km-tek40xx",
821 "?set term km-tek40xx",
822 "?terminal km-tek40xx",
825 "?commands set terminal selanar",
826 "?set terminal selanar",
831 "?commands set terminal bitgraph",
832 "?set terminal bitgraph",
833 "?set term bitgraph",
834 "?terminal bitgraph",
837 "?commands set terminal xterm",
838 "?set terminal xterm",
843 " This family of terminal drivers supports a variety of VT-like terminals.",
844 " `tek40xx` supports Tektronix 4010 and others as well as most TEK emulators;",
845 " `vttek` supports VT-like tek40xx terminal emulators; `kc-tek40xx` supports",
846 " MS-DOS Kermit Tek4010 terminal emulators in color: `km-tek40xx` supports them",
847 " in monochrome; `selanar` supports Selanar graphics; and `bitgraph` supports",
848 " BBN Bitgraph terminals. None have any options."
850 #endif /* TERM_HELP */