7 #if defined ( PLD_xterm ) || \
8 defined ( PLD_tek4010 ) || \
9 defined ( PLD_tek4010f ) || \
10 defined ( PLD_tek4107 ) || \
11 defined ( PLD_tek4107f ) || \
12 defined ( PLD_mskermit ) || \
13 defined ( PLD_versaterm ) || \
14 defined ( PLD_vlt ) || \
15 defined ( PLD_conex ) // conex emulator 4010/4014/4105
27 #if defined ( PLD_conex )
28 "conex:Conex vt320/tek emulator:1:tek:24:conex\n"
30 #if defined ( PLD_mskermit )
31 "mskermit:MS-Kermit emulator:1:tek:21:mskermit\n"
33 #if defined ( PLD_tek4107t )
34 "tek4107t:Tektronix Terminal (4105/4107):1:tek:20:tek4107t\n"
36 #if defined ( PLD_tek4107f )
37 "tek4107f:Tektronix File (4105/4107):0:tek:28:tek4107f\n"
39 #if defined ( PLD_tekt )
40 "tekt:Tektronix Terminal (4010):1:tek:19:tekt\n"
42 #if defined ( PLD_tekf )
43 "tekf:Tektronix File (4010):0:tek:27:tekf\n"
45 #if defined ( PLD_versaterm )
46 "versaterm:Versaterm vt100/tek emulator:1:tek:22:versaterm\n"
48 #if defined ( PLD_vlt )
49 "vlt:VLT vt100/tek emulator:1:tek:23:vlt\n"
51 #if defined ( PLD_xterm )
52 "xterm:Xterm Window:1:tek:18:xterm\n"
62 void plD_init_tek4107t(
PLStream * );
63 void plD_init_tek4107f(
PLStream * );
64 void plD_init_mskermit(
PLStream * );
65 void plD_init_versaterm(
PLStream * );
71 void plD_line_tek(
PLStream *,
short,
short,
short,
short );
81 static void WaitForPage(
PLStream *pls );
82 static void tek_init(
PLStream *pls );
83 static void tek_text(
PLStream *pls );
84 static void tek_graph(
PLStream *pls );
87 static void encode_int(
char *c,
int i );
88 static void encode_vector(
char *c,
int x,
int y );
90 static void tek_vector(
PLStream *pls,
int x,
int y );
91 static void scolor(
PLStream *pls,
int icol,
int r,
int g,
int b );
92 static void setcmap(
PLStream *pls );
94 static void LookupEvent(
PLStream *pls );
95 static void InputEH(
PLStream *pls );
96 static void LocateEH(
PLStream *pls );
100 #ifdef HAVE_TERMIOS_H
103 static struct termios termios_cbreak, termios_reset;
104 static enum { RESET, CBREAK } ttystate = RESET;
105 static void tty_setup(
void );
106 static int tty_cbreak(
void );
107 static int tty_reset(
void );
108 static void tty_atexit(
void );
110 static void tty_setup(
void )
113 static int tty_cbreak(
void )
117 static int tty_reset(
void )
121 static void tty_atexit(
void )
133 #define RING_BELL "\007" // ^G = 7
134 #define CLEAR_VIEW "\033\f" // clear the view = ESC FF
136 #define ALPHA_MODE "\037" // Enter Alpha mode: US
137 #define VECTOR_MODE "\035" // Enter Vector mode: GS
138 #define GIN_MODE "\033\032" // Enter GIN mode: ESC SUB
139 #define BYPASS_MODE "\033\030" // Enter Bypass mode: ESC CAN
140 #define XTERM_VTMODE "\033\003" // End xterm-Tek mode: ESC ETX
141 #define CANCEL "\033KC" // Cancel
145 enum { tek4010, tek4105, tek4107, xterm, mskermit, vlt, versaterm };
164 static char *kermit_color[15] = {
166 "0;32",
"0;36",
"0;31",
"0;35",
167 "1;34",
"1;33",
"1;31",
"1;37",
168 "1;35",
"1;32",
"1;36",
"0;34",
174 char *menustr,
char *devnam,
177 #ifndef ENABLE_DYNDRIVERS
195 tek_dispatch_init_helper( pdt,
196 "Xterm Window",
"xterm",
203 tek_dispatch_init_helper( pdt,
204 "Tektronix Terminal (4010)",
"tekt",
211 tek_dispatch_init_helper( pdt,
212 "Tektronix Terminal (4105/4107)",
"tek4107t",
219 tek_dispatch_init_helper( pdt,
220 "MS-Kermit emulator",
"mskermit",
227 tek_dispatch_init_helper( pdt,
228 "Versaterm vt100/tek emulator",
"versaterm",
235 tek_dispatch_init_helper( pdt,
236 "VLT vt100/tek emulator",
"vlt",
243 tek_dispatch_init_helper( pdt,
244 "Conex vt320/tek emulator",
"conex",
251 tek_dispatch_init_helper( pdt,
252 "Tektronix File (4010)",
"tekf",
259 tek_dispatch_init_helper( pdt,
260 "Tektronix File (4105/4107)",
"tek4107f",
297 plD_init_tekf( pls );
311 plD_init_tek4107f( pls );
384 pls->
dev = calloc( 1, (
size_t)
sizeof ( TekDev ) );
385 if ( pls->
dev == NULL )
386 plexit(
"tek_init: Out of memory." );
388 dev = (TekDev *) pls->
dev;
415 fprintf( pls->
OutFile,
"\033%%!0" );
416 fprintf( pls->
OutFile,
"\033KN1" );
417 fprintf( pls->
OutFile,
"\033LZ" );
418 fprintf( pls->
OutFile,
"\033ML1" );
420 #endif // PLD_tek4107
431 encode_int( fillcol, 0 );
432 fprintf( pls->
OutFile,
"\033MP%s\033LE", fillcol );
443 if ( pls->
color & 0x01 )
445 printf(
"\033TM111" );
451 fprintf( pls->
OutFile, VECTOR_MODE );
453 fprintf( pls->
OutFile, CLEAR_VIEW );
465 plD_line_tek(
PLStream *pls,
short x1,
short y1,
short x2,
short y2 )
467 TekDev *dev = (TekDev *) pls->
dev;
473 if ( x1 != dev->xold || y1 != dev->yold )
476 tek_vector( pls, x1, y1 );
481 tek_vector( pls, x2, y2 );
494 plD_polyline_tek(
PLStream *pls,
short *xa,
short *ya,
PLINT npts )
497 TekDev *dev = (TekDev *) pls->
dev;
498 short x = xa[0],
y = ya[0];
504 if (
x != dev->xold ||
y != dev->yold )
507 tek_vector( pls,
x,
y );
512 for ( i = 1; i < npts; i++ )
513 tek_vector( pls, xa[i], ya[i] );
515 dev->xold = xa[npts - 1];
516 dev->yold = ya[npts - 1];
535 fprintf( pls->
OutFile, CLEAR_VIEW );
549 TekDev *dev = (TekDev *) pls->
dev;
559 fprintf( pls->
OutFile, CLEAR_VIEW );
571 if ( pls->
color & 0x01 )
602 tek_color(
PLStream *pls,
int icol )
606 #ifdef PLD_mskermit // Is this really necessary?
608 printf(
"\033[%sm", kermit_color[icol % 14] );
626 TekDev *dev = (TekDev *) pls->
dev;
636 int icol0 = pls->
icol0;
640 dev->curcolor = icol0;
641 tek_color( pls, icol0 );
654 icol1 = pls->
ncol0 + ( pls->
icol1 * ( ncol1 - 1 ) ) / ( pls->
ncol1 - 1 );
655 dev->curcolor = icol1;
656 tek_color( pls, icol1 );
662 if ( pls->
color & 0x01 )
709 char input_string[MAX_GIN];
725 while ( ++i < MAX_GIN && ( input_string[i - 1] = getchar() ) !=
'\n' )
728 input_string[i - 1] =
'\0';
729 ptr->
keysym = input_string[0];
730 decode_gin( &input_string[1], ptr );
734 printf( VECTOR_MODE );
747 TekDev *dev = (TekDev *) pls->
dev;
749 char fillcol[4], firstpoint[5];
756 encode_int( fillcol, -dev->curcolor );
757 encode_vector( firstpoint, pls->
dev_x[0], pls->
dev_y[0] );
774 for ( i = 1; i < pls->
dev_npts; i++ )
775 tek_vector( pls, pls->
dev_x[i], pls->
dev_y[i] );
810 printf(
"\033\003" );
815 printf(
"\033[?38l" );
819 printf(
"\033%%!2" );
824 printf(
"\033%%!1" );
828 printf( ALPHA_MODE );
853 printf(
"\033[?38h" );
857 printf(
"\033%%!0" );
861 printf(
"\033%%!0" );
862 printf( CLEAR_VIEW );
878 encode_int(
char *c,
int i )
885 *c++ = ( ( i >> 10 ) & 0x1F ) | 0x40;
887 *c++ = ( ( i >> 4 ) & 0x3F ) | 0x40;
896 *c = ( i & 0x0F ) | 0x20;
923 int x,
y, lc = strlen( c );
927 x = ( ( c[0] & 0x1f ) << 5 ) +
930 y = ( ( c[2] & 0x1f ) << 5 ) +
935 gin->
dX = x / (double) TEKX;
936 gin->
dY = y / (double) TEKY;
940 y = ( ( c[0] & 0x1f ) << 7 ) +
941 ( ( c[2] & 0x1f ) << 2 ) +
942 ( ( c[1] & 0x06 ) >> 2 );
944 x = ( ( c[3] & 0x1f ) << 7 ) +
945 ( ( c[4] & 0x1f ) << 2 ) +
950 gin->
dX = x / (double) ( TEKX << 2 );
951 gin->
dY = y / (double) ( TEKY << 2 );
971 encode_vector(
char *c,
int x,
int y )
973 c[0] = ( y >> 5 ) + 0x20;
974 c[1] = ( y & 0x1f ) + 0x60;
975 c[2] = ( x >> 5 ) + 0x20;
976 c[3] = ( x & 0x1f ) + 0x40;
988 tek_vector(
PLStream *pls,
int x,
int y )
992 encode_vector( c, x, y );
1004 scolor(
PLStream *pls,
int icol,
int r,
int g,
int b )
1006 char tek_col[4], tek_r[4], tek_g[4], tek_b[4];
1008 encode_int( tek_col, icol );
1009 encode_int( tek_r, ( 100 * r ) / 255 );
1010 encode_int( tek_g, ( 100 * g ) / 255 );
1011 encode_int( tek_b, ( 100 * b ) / 255 );
1014 tek_col, tek_r, tek_g, tek_b );
1033 for ( i = 0; i < pls->
ncol0; i++ )
1038 for ( i = 0; i < ncol1; i++ )
1041 scolor( pls, i + pls->
ncol0, cmap1col.
r, cmap1col.
g, cmap1col.
b );
1055 TekDev *dev = (TekDev *) pls->
dev;
1057 printf( ALPHA_MODE );
1058 printf( RING_BELL );
1059 printf( VECTOR_MODE );
1062 while ( !dev->exit_eventloop )
1065 if ( dev->locate_mode )
1070 dev->exit_eventloop =
FALSE;
1082 TekDev *dev = (TekDev *) pls->
dev;
1085 if ( dev->locate_mode )
1087 GetCursor( pls, gin );
1095 if ( isprint( gin->
keysym ) )
1105 pldebug(
"LookupEvent",
1106 "Keycode %x, string: %s\n", gin->
keysym, gin->
string );
1141 TekDev *dev = (TekDev *) pls->
dev;
1148 dev->locate_mode = 0;
1168 if ( isprint( gin->
keysym ) )
1169 printf(
"%f %f %c\n", gin->
wX, gin->
wY, gin->
keysym );
1171 printf(
"%f %f\n", gin->
wX, gin->
wY );
1179 dev->locate_mode = 0;
1199 TekDev *dev = (TekDev *) pls->
dev;
1206 if ( pls->
KeyEH != NULL )
1215 dev->exit_eventloop =
TRUE;
1226 dev->locate_mode = 1;
1238 #ifdef HAVE_TERMIOS_H
1243 if ( tcgetattr( STDIN_FILENO, &termios_reset ) < 0 )
1245 fprintf( stderr,
"Unable to set up cbreak mode.\n" );
1249 termios_cbreak = termios_reset;
1251 termios_cbreak.c_lflag &= ~( ICANON );
1252 termios_cbreak.c_cc[VMIN] = 1;
1253 termios_cbreak.c_cc[VTIME] = 0;
1256 if ( atexit( tty_atexit ) )
1257 fprintf( stderr,
"Unable to set up atexit handler.\n" );
1265 if ( ttystate != CBREAK )
1267 if ( tcsetattr( STDIN_FILENO, TCSAFLUSH, &termios_cbreak ) < 0 )
1278 if ( ttystate != RESET )
1280 if ( tcsetattr( STDIN_FILENO, TCSAFLUSH, &termios_reset ) < 0 )
1294 #endif // HAVE_TERMIOS_H
1302 #endif // defined(PLD_xterm) || ...