home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / k95source / ckotek.c < prev    next >
C/C++ Source or Header  |  2020-01-01  |  6KB  |  258 lines

  1. /* C K O T E K . C - Tektronix Emulation */
  2.  
  3. /*
  4.   Author: Jeffrey E Altman <jaltman@secure-endpoints.com>
  5.             Secure Endpoints Inc., New York City
  6.  
  7.   Copyright (C) 1985, 2004, Trustees of Columbia University in the City of
  8.   New York.  All rights reserved.  This copyright notice must not be removed,
  9.   altered, or obscured.
  10. */
  11.  
  12. #include "ckcdeb.h"             /* Typedefs, debug formats, etc */
  13. #ifndef NOTERM
  14. #include "ckcker.h"             /* Kermit definitions */
  15. #include "ckcasc.h"             /* ASCII character symbols */
  16. #include "ckcxla.h"             /* Character set translation */
  17. #include "ckcnet.h"             /* Network support */
  18. #include "ckuusr.h"             /* For terminal type definitions, etc. */
  19.  
  20. #include <ctype.h>              /* Character types */
  21. #include <io.h>                 /* File io function declarations */
  22. #include <process.h>            /* Process-control function declarations */
  23. #include <stdlib.h>             /* Standard library declarations */
  24. #include <sys/types.h>
  25. #include <sys/stat.h>
  26. #include <stdio.h>
  27. #include <string.h>
  28. #include <assert.h>
  29.  
  30. /*
  31.    if the following is defined, then Reverse Screen mode is handled not
  32.    by flipping the Vscrn mode but instead by reversing the attribute
  33. */
  34. #define OLDDECSCNM
  35. #define DECLED
  36.  
  37. #ifdef NT
  38. #include <windows.h>
  39. #else /* NT */
  40.  
  41. #ifdef OS2MOUSE
  42. #define INCL_MOU
  43. #endif /* OS2MOUSE */
  44.  
  45. #define INCL_NOPM
  46. #define INCL_VIO
  47. #define INCL_ERRORS
  48. #define INCL_DOSPROCESS
  49. #define INCL_DOSSEMAPHORES
  50. #define INCL_DOSDEVIOCTL
  51. #define INCL_WINCLIPBOARD
  52. #include <os2.h>
  53. #undef COMMENT                /* COMMENT is defined in os2.h */
  54. #endif /* NT */
  55.  
  56. #include "ckocon.h"             /* definitions common to console routines */
  57. #include "ckokey.h"
  58. #include "ckotek.h"
  59.  
  60. extern bool keyclick ;
  61. extern int  cursorena[], keylock, duplex, duplex_sav, screenon ;
  62. extern int  printon, aprint, cprint, uprint, xprint, seslog ;
  63. extern int  insertmode, tnlm ;
  64. extern int  escstate, debses, decscnm, tt_cursor ;
  65. extern int  tt_type, tt_type_mode, tt_max, tt_answer, tt_status[VNUM], tt_szchng[] ;
  66. extern int  tt_cols[], tt_rows[], tt_wrap ;
  67. extern int  wherex[], wherey[], margintop, marginbot ;
  68. extern int  marginbell, marginbellcol ;
  69. extern char answerback[], htab[] ;
  70. extern struct tt_info_rec tt_info[] ;
  71. extern vtattrib attrib ;
  72. extern unsigned char attribute;
  73.  
  74. extern int autoscroll, protect ;
  75.  
  76. int tekmode = FALSE ;
  77.  
  78. void
  79. settekmode( void )
  80. {
  81.    tekmode = TRUE ;
  82.    debug(F100,"Entering Tek mode","",0);
  83. }
  84.  
  85. void
  86. resettekmode( void )
  87. {
  88.    tekmode = FALSE ;
  89.    debug(F100,"Exiting Tek mode","",0);
  90. }
  91.  
  92. void
  93. tekescape( void )
  94. {
  95.  
  96. }
  97.  
  98. int
  99. tekinc(void)
  100. {
  101.     extern int cmask, pmask;
  102.     int ch = ttinc(0);
  103.     if ( !xprint ) {
  104. #ifndef NOXFER
  105.         autodown(ch);
  106. #endif /* NOXFER */
  107.         autoexitchk(ch);
  108.     }
  109.     if ( seslog )
  110.         logchar(ch);
  111.     ch = ch & pmask & cmask;
  112.     debugses(ch);
  113.     if (printon && (is_xprint() || is_uprint()))
  114.         prtchar(ch);
  115.     return ch;
  116. }
  117.  
  118. void
  119. tekctrl( int ch )
  120. {
  121.     int i,j;
  122.  
  123.     switch ( ch ) {
  124.     case SOH:
  125.         break;
  126.     case STX:
  127.         break;
  128.     case ETX:
  129.         break;
  130.     case EOT:
  131.         break;
  132.     case ENQ:
  133.         break;
  134.     case ACK:
  135.         break;
  136.     case BEL:
  137.         if ( debses )
  138.             break;
  139.         bleep(BP_BEL);
  140.         break;
  141.     case BS:
  142.         /* Cursor Left 8 dots, can be destructive */
  143.         if ( debses )
  144.             break;
  145.         break;
  146.     case HT:
  147.         /* treated as a single space */
  148.         break;
  149.     case LF:
  150.         /* Cursor Down 8 dots */
  151.         if ( debses )
  152.             break;
  153.         break;
  154.     case VT:
  155.         /* Cursor Down 8 dots */
  156.         break;
  157.     case FF:
  158.         /* Erase screen, Home cursor */
  159.         break;
  160.     case CR:
  161.         /* move cursor to column 1 */
  162.         if ( debses )
  163.             break;
  164.         break;
  165.     case SO:
  166.         break;
  167.     case SI:
  168.         break;
  169.     case DLE:
  170.         break;
  171.     case DC1:
  172.         /* XON flow control */
  173.         break;
  174.     case DC2:
  175.         break;
  176.     case DC3:
  177.         /* XOFF flow control */
  178.         break;
  179.     case DC4:
  180.         break;
  181.     case NAK:
  182.         break;
  183.     case SYN:
  184.         break;
  185.     case ETB:
  186.         break;
  187.     case CAN:
  188.         /* Return to text terminal mode if in sub-Tek mode */
  189.         /* else ignored if regular Tek terminal */
  190.         break;
  191.     case XEM:
  192.         break;
  193.     case SUB:
  194.         /* Same as CAN */
  195.         break;
  196.     case ESC:
  197.         /* Start ESCAPE sequence, cancel any others */
  198.         break;
  199.     case XFS:
  200.         /* Enter point plotting mode */
  201. #ifdef COMMENT
  202.         Draw a dot at the coordinate.  Point plotting
  203.         mode.  Like GS but does not join end points with lines.
  204.         Exit drawing upon reception of CR,LF,RS,US,FS,CAN.
  205. #endif /* COMMENT */
  206.         break;
  207.     case XGS:
  208.         /* Enter line drawing mode */
  209. #ifdef COMMENT
  210.         The first move will be with beam off (a moveto command), subsequent
  211.         coordinates will be reached with the beam on (a drawto command).
  212.         Note: this is also Kermit's Connect mode escape character so beware
  213.         if typing GS by hand; SET ESCAPE to something else before the test.
  214.         Exit drawing upon reception of CR,LF,RS,US,FS,CAN.
  215. #endif /* COMMENT */
  216.         break;
  217.     case XRS:
  218.         /* Enter incremental line drawing mode */
  219. #ifdef COMMENT
  220.         RS space        move with pen up (invisible)
  221.         RS P            move with pen down (write dots)
  222.         RS <letter>
  223.         letter  motion                  letter  motion
  224.           A     right (East)              B     left (West)
  225.           B     right and up (NE)         J     left and down (SW)
  226.           D     up (North)                H     down (South)
  227.           F     left and up (NW)          I     right and down (SE)
  228.         Exit drawing upon reception of CR,LF,RS,US,FS,CAN.
  229.   Example: RS <space> J J J  means move three Tek positions left and down
  230.         (three south west steps) with the pen up (move invisibly).
  231. #endif /* COMMENT */
  232.         break;
  233.     case US:
  234.         /* Enter Tek text mode (leave line/point drawing) */
  235.         break;
  236.     }
  237. }
  238.  
  239. void
  240. tekascii( int ch )
  241. {
  242.     int i,j,k,n,x,y,z;
  243.     vtattrib attr ;
  244.     viocell blankvcell;
  245.  
  246.     if (printon && (is_xprint() || is_uprint()))
  247.         prtchar(ch);
  248.  
  249.     if ( ch < SP )
  250.         tekctrl(ch) ;
  251.     else if ( !debses ) {
  252.         wrtch(ch);
  253.     }
  254.     VscrnIsDirty(VTERM) ;
  255. }
  256. #endif /* NOTERM */
  257.  
  258.