5 #if defined ( PLD_xterm ) || \
6 defined ( PLD_tek4010 ) || \
7 defined ( PLD_tek4010f ) || \
8 defined ( PLD_tek4107 ) || \
9 defined ( PLD_tek4107f ) || \
10 defined ( PLD_mskermit ) || \
11 defined ( PLD_versaterm ) || \
12 defined ( PLD_vlt ) || \
13 defined ( PLD_conex ) // conex emulator 4010/4014/4105
25 #if defined ( PLD_conex )
26 "conex:Conex vt320/tek emulator:1:tek:24:conex\n"
28 #if defined ( PLD_mskermit )
29 "mskermit:MS-Kermit emulator:1:tek:21:mskermit\n"
31 #if defined ( PLD_tek4107t )
32 "tek4107t:Tektronix Terminal (4105/4107):1:tek:20:tek4107t\n"
34 #if defined ( PLD_tek4107f )
35 "tek4107f:Tektronix File (4105/4107):0:tek:28:tek4107f\n"
37 #if defined ( PLD_tekt )
38 "tekt:Tektronix Terminal (4010):1:tek:19:tekt\n"
40 #if defined ( PLD_tekf )
41 "tekf:Tektronix File (4010):0:tek:27:tekf\n"
43 #if defined ( PLD_versaterm )
44 "versaterm:Versaterm vt100/tek emulator:1:tek:22:versaterm\n"
46 #if defined ( PLD_vlt )
47 "vlt:VLT vt100/tek emulator:1:tek:23:vlt\n"
49 #if defined ( PLD_xterm )
50 "xterm:Xterm Window:1:tek:18:xterm\n"
60 void plD_init_tek4107t(
PLStream * );
61 void plD_init_tek4107f(
PLStream * );
62 void plD_init_mskermit(
PLStream * );
63 void plD_init_versaterm(
PLStream * );
69 void plD_line_tek(
PLStream *,
short,
short,
short,
short );
79 static void WaitForPage(
PLStream *pls );
80 static void tek_init(
PLStream *pls );
81 static void tek_text(
PLStream *pls );
82 static void tek_graph(
PLStream *pls );
85 static void encode_int(
char *c,
int i );
86 static void encode_vector(
char *c,
int x,
int y );
88 static void tek_vector(
PLStream *pls,
int x,
int y );
89 static void scolor(
PLStream *pls,
int icol,
int r,
int g,
int b );
90 static void setcmap(
PLStream *pls );
92 static void LookupEvent(
PLStream *pls );
93 static void InputEH(
PLStream *pls );
94 static void LocateEH(
PLStream *pls );
101 static struct termios termios_cbreak, termios_reset;
102 static enum { RESET, CBREAK } ttystate = RESET;
103 static void tty_setup(
void );
104 static int tty_cbreak(
void );
105 static int tty_reset(
void );
106 static void tty_atexit(
void );
108 static void tty_setup(
void )
111 static int tty_cbreak(
void )
115 static int tty_reset(
void )
119 static void tty_atexit(
void )
131 #define RING_BELL "\007" // ^G = 7
132 #define CLEAR_VIEW "\033\f" // clear the view = ESC FF
134 #define ALPHA_MODE "\037" // Enter Alpha mode: US
135 #define VECTOR_MODE "\035" // Enter Vector mode: GS
136 #define GIN_MODE "\033\032" // Enter GIN mode: ESC SUB
137 #define BYPASS_MODE "\033\030" // Enter Bypass mode: ESC CAN
138 #define XTERM_VTMODE "\033\003" // End xterm-Tek mode: ESC ETX
139 #define CANCEL "\033KC" // Cancel
143 enum { tek4010, tek4105, tek4107, xterm, mskermit, vlt, versaterm };
162 static char *kermit_color[15] = {
164 "0;32",
"0;36",
"0;31",
"0;35",
165 "1;34",
"1;33",
"1;31",
"1;37",
166 "1;35",
"1;32",
"1;36",
"0;34",
172 char *menustr,
char *devnam,
175 #ifndef ENABLE_DYNDRIVERS
193 tek_dispatch_init_helper( pdt,
194 "Xterm Window",
"xterm",
201 tek_dispatch_init_helper( pdt,
202 "Tektronix Terminal (4010)",
"tekt",
209 tek_dispatch_init_helper( pdt,
210 "Tektronix Terminal (4105/4107)",
"tek4107t",
217 tek_dispatch_init_helper( pdt,
218 "MS-Kermit emulator",
"mskermit",
225 tek_dispatch_init_helper( pdt,
226 "Versaterm vt100/tek emulator",
"versaterm",
233 tek_dispatch_init_helper( pdt,
234 "VLT vt100/tek emulator",
"vlt",
241 tek_dispatch_init_helper( pdt,
242 "Conex vt320/tek emulator",
"conex",
249 tek_dispatch_init_helper( pdt,
250 "Tektronix File (4010)",
"tekf",
257 tek_dispatch_init_helper( pdt,
258 "Tektronix File (4105/4107)",
"tek4107f",
295 plD_init_tekf( pls );
309 plD_init_tek4107f( pls );
382 pls->
dev = calloc( 1, (
size_t)
sizeof ( TekDev ) );
383 if ( pls->
dev == NULL )
384 plexit(
"tek_init: Out of memory." );
386 dev = (TekDev *) pls->
dev;
413 fprintf( pls->
OutFile,
"\033%%!0" );
414 fprintf( pls->
OutFile,
"\033KN1" );
415 fprintf( pls->
OutFile,
"\033LZ" );
416 fprintf( pls->
OutFile,
"\033ML1" );
418 #endif // PLD_tek4107
429 encode_int( fillcol, 0 );
430 fprintf( pls->
OutFile,
"\033MP%s\033LE", fillcol );
441 if ( pls->
color & 0x01 )
443 printf(
"\033TM111" );
449 fprintf( pls->
OutFile, VECTOR_MODE );
451 fprintf( pls->
OutFile, CLEAR_VIEW );
463 plD_line_tek(
PLStream *pls,
short x1,
short y1,
short x2,
short y2 )
465 TekDev *dev = (TekDev *) pls->
dev;
471 if ( x1 != dev->xold || y1 != dev->yold )
474 tek_vector( pls, x1, y1 );
479 tek_vector( pls, x2, y2 );
492 plD_polyline_tek(
PLStream *pls,
short *xa,
short *ya,
PLINT npts )
495 TekDev *dev = (TekDev *) pls->
dev;
496 short x = xa[0], y = ya[0];
502 if ( x != dev->xold || y != dev->yold )
505 tek_vector( pls, x, y );
510 for ( i = 1; i < npts; i++ )
511 tek_vector( pls, xa[i], ya[i] );
513 dev->xold = xa[npts - 1];
514 dev->yold = ya[npts - 1];
533 fprintf( pls->
OutFile, CLEAR_VIEW );
547 TekDev *dev = (TekDev *) pls->
dev;
557 fprintf( pls->
OutFile, CLEAR_VIEW );
569 if ( pls->
color & 0x01 )
600 tek_color(
PLStream *pls,
int icol )
604 #ifdef PLD_mskermit // Is this really necessary?
606 printf(
"\033[%sm", kermit_color[icol % 14] );
624 TekDev *dev = (TekDev *) pls->
dev;
634 int icol0 = pls->
icol0;
638 dev->curcolor = icol0;
639 tek_color( pls, icol0 );
652 icol1 = pls->
ncol0 + ( pls->
icol1 * ( ncol1 - 1 ) ) / ( pls->
ncol1 - 1 );
653 dev->curcolor = icol1;
654 tek_color( pls, icol1 );
660 if ( pls->
color & 0x01 )
707 char input_string[MAX_GIN];
723 while ( ++i < MAX_GIN && ( input_string[i - 1] = getchar() ) !=
'\n' )
726 input_string[i - 1] =
'\0';
727 ptr->
keysym = input_string[0];
728 decode_gin( &input_string[1], ptr );
732 printf( VECTOR_MODE );
745 TekDev *dev = (TekDev *) pls->
dev;
747 char fillcol[4], firstpoint[5];
754 encode_int( fillcol, -dev->curcolor );
755 encode_vector( firstpoint, pls->
dev_x[0], pls->
dev_y[0] );
772 for ( i = 1; i < pls->
dev_npts; i++ )
773 tek_vector( pls, pls->
dev_x[i], pls->
dev_y[i] );
808 printf(
"\033\003" );
813 printf(
"\033[?38l" );
817 printf(
"\033%%!2" );
822 printf(
"\033%%!1" );
826 printf( ALPHA_MODE );
851 printf(
"\033[?38h" );
855 printf(
"\033%%!0" );
859 printf(
"\033%%!0" );
860 printf( CLEAR_VIEW );
876 encode_int(
char *c,
int i )
883 *c++ = ( ( i >> 10 ) & 0x1F ) | 0x40;
885 *c++ = ( ( i >> 4 ) & 0x3F ) | 0x40;
894 *c = ( i & 0x0F ) | 0x20;
921 int x, y, lc = strlen( c );
925 x = ( ( c[0] & 0x1f ) << 5 ) +
928 y = ( ( c[2] & 0x1f ) << 5 ) +
933 gin->
dX = x / (double) TEKX;
934 gin->
dY = y / (double) TEKY;
938 y = ( ( c[0] & 0x1f ) << 7 ) +
939 ( ( c[2] & 0x1f ) << 2 ) +
940 ( ( c[1] & 0x06 ) >> 2 );
942 x = ( ( c[3] & 0x1f ) << 7 ) +
943 ( ( c[4] & 0x1f ) << 2 ) +
948 gin->
dX = x / (double) ( TEKX << 2 );
949 gin->
dY = y / (double) ( TEKY << 2 );
969 encode_vector(
char *c,
int x,
int y )
971 c[0] = ( y >> 5 ) + 0x20;
972 c[1] = ( y & 0x1f ) + 0x60;
973 c[2] = ( x >> 5 ) + 0x20;
974 c[3] = ( x & 0x1f ) + 0x40;
986 tek_vector(
PLStream *pls,
int x,
int y )
990 encode_vector( c, x, y );
1002 scolor(
PLStream *pls,
int icol,
int r,
int g,
int b )
1004 char tek_col[4], tek_r[4], tek_g[4], tek_b[4];
1006 encode_int( tek_col, icol );
1007 encode_int( tek_r, ( 100 * r ) / 255 );
1008 encode_int( tek_g, ( 100 * g ) / 255 );
1009 encode_int( tek_b, ( 100 * b ) / 255 );
1012 tek_col, tek_r, tek_g, tek_b );
1031 for ( i = 0; i < pls->
ncol0; i++ )
1036 for ( i = 0; i < ncol1; i++ )
1039 scolor( pls, i + pls->
ncol0, cmap1col.
r, cmap1col.
g, cmap1col.
b );
1053 TekDev *dev = (TekDev *) pls->
dev;
1055 printf( ALPHA_MODE );
1056 printf( RING_BELL );
1057 printf( VECTOR_MODE );
1060 while ( !dev->exit_eventloop )
1063 if ( dev->locate_mode )
1068 dev->exit_eventloop =
FALSE;
1080 TekDev *dev = (TekDev *) pls->
dev;
1083 if ( dev->locate_mode )
1085 GetCursor( pls, gin );
1093 if ( isprint( gin->
keysym ) )
1103 pldebug(
"LookupEvent",
1104 "Keycode %x, string: %s\n", gin->
keysym, gin->
string );
1139 TekDev *dev = (TekDev *) pls->
dev;
1146 dev->locate_mode = 0;
1166 if ( isprint( gin->
keysym ) )
1167 printf(
"%f %f %c\n", gin->
wX, gin->
wY, gin->
keysym );
1169 printf(
"%f %f\n", gin->
wX, gin->
wY );
1177 dev->locate_mode = 0;
1197 TekDev *dev = (TekDev *) pls->
dev;
1204 if ( pls->
KeyEH != NULL )
1213 dev->exit_eventloop =
TRUE;
1224 dev->locate_mode = 1;
1236 #ifdef HAVE_TERMIOS_H
1241 if ( tcgetattr( STDIN_FILENO, &termios_reset ) < 0 )
1243 fprintf( stderr,
"Unable to set up cbreak mode.\n" );
1247 termios_cbreak = termios_reset;
1249 termios_cbreak.c_lflag &= ~( ICANON );
1250 termios_cbreak.c_cc[VMIN] = 1;
1251 termios_cbreak.c_cc[VTIME] = 0;
1254 if ( atexit( tty_atexit ) )
1255 fprintf( stderr,
"Unable to set up atexit handler.\n" );
1263 if ( ttystate != CBREAK )
1265 if ( tcsetattr( STDIN_FILENO, TCSAFLUSH, &termios_cbreak ) < 0 )
1276 if ( ttystate != RESET )
1278 if ( tcsetattr( STDIN_FILENO, TCSAFLUSH, &termios_reset ) < 0 )
1292 #endif // HAVE_TERMIOS_H
1300 #endif // defined(PLD_xterm) || ...