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

  1. /*  C K O V C . C  --  Volker Craig VC4404/404 Emulation  */
  2.  
  3. /*
  4.   Author: Jeffrey 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 New
  8.   York.
  9. */
  10.  
  11. #include "ckcdeb.h"
  12. #ifndef NOTERM
  13. #ifdef NT
  14. #include <windows.h>
  15. #else /* NT */
  16. #include <os2.h>
  17. #undef COMMENT
  18. #endif /* NT */
  19.  
  20. #include "ckcker.h"
  21. #include "ckcasc.h"
  22. #include "ckuusr.h"
  23. #include "ckocon.h"
  24. #include "ckovc.h"
  25.  
  26. extern bool keyclick ;
  27. extern int  cursorena[], keylock, duplex, duplex_sav, screenon ;
  28. extern int  printon, aprint, cprint, uprint, xprint, seslog ;
  29. extern int  insertmode, tnlm ;
  30. extern int  escstate, debses, decscnm, tt_cursor ;
  31. extern int  tt_type, tt_type_mode, tt_max, tt_answer, tt_status[VNUM], tt_szchng[] ;
  32. extern int  tt_cols[], tt_rows[], tt_wrap ;
  33. extern int  wherex[], wherey[], margintop, marginbot ;
  34. extern int  marginbell, marginbellcol ;
  35. extern char answerback[], htab[] ;
  36. extern struct tt_info_rec tt_info[] ;
  37. extern vtattrib attrib ;
  38. extern unsigned char attribute;
  39.  
  40. extern int autoscroll, protect ;
  41.  
  42. int
  43. vcinc(void)
  44. {
  45.     extern int pmask, cmask;
  46.     extern int tt_utf8;
  47.     int ch;
  48.  
  49.   loop:
  50.     ch = ttinc(0);
  51.     if ( ch < 0 )
  52.         return ch;
  53.  
  54.     if ( seslog )
  55.         logchar(ch);
  56.  
  57.     /* Handle the UTF8 conversion if we are in that mode */
  58.     if ( tt_utf8 ) {
  59.         USHORT * ucs2 = NULL;
  60.         int rc = utf8_to_ucs2( (CHAR)(ch & 0xFF), &ucs2 );
  61.         if ( rc > 0 )
  62.             goto loop;
  63.         else if ( rc < 0 )
  64.             ch = 0xfffd;
  65.         else
  66.             ch = *ucs2;
  67.     }
  68.  
  69.     if ( !xprint ) {
  70. #ifndef NOXFER
  71.         autodown(ch);
  72. #endif /* NOXFER */
  73.         autoexitchk(ch);
  74.     }
  75.     ch = ch & pmask & cmask;
  76.     debugses(ch);
  77.     if (printon && (is_xprint() || is_uprint()))
  78.         prtchar(ch);
  79.     return ch;
  80. }
  81.  
  82. void
  83. vcctrl( int ch )
  84. {
  85.     int i,j;
  86.  
  87.     switch ( ch ) {
  88.     case SOH:
  89.         break;
  90.     case STX:
  91.         break;
  92.     case ETX:
  93.         break;
  94.     case EOT:
  95.         break;
  96.     case ENQ:
  97.         break;
  98.     case ACK:
  99.         break;
  100.     case BEL:
  101.         if ( debses )
  102.             break;
  103.         bleep(BP_BEL);
  104.         break;
  105.     case BS:
  106.         /* Cursor Left */
  107.         if ( debses )
  108.             break;
  109.         cursorleft(0);
  110.         break;
  111.     case HT:
  112.         break;
  113.     case LF:
  114.         /* Cursor Down */
  115.         if ( debses )
  116.             break;
  117.         wrtch(LF);
  118.         break;
  119.     case VT:
  120.         break;
  121.     case FF:
  122.         break;
  123.     case CR:
  124.         if ( debses )
  125.             break;
  126.         wrtch(CR);
  127.         break;
  128.     case SO:
  129.         /* DIM */
  130.         if ( debses )
  131.             break;
  132.         attrib.bold = FALSE ;
  133.         break;
  134.     case SI:
  135.         /* BRIGHT */
  136.         if ( debses )
  137.             break;
  138.         attrib.bold = TRUE ;
  139.         break;
  140.     case DLE: {
  141.         /* Address cursor in current page */
  142.         int col, line ;
  143.         line = vcinc();
  144.         col  = vcinc();
  145.         if ( debses )
  146.             break;
  147.         lgotoxy(VTERM,col-SP+1,line-SP+1);
  148.         break;
  149.     }
  150.     case DC1:
  151.         break;
  152.     case DC2:
  153.         /* Peripheral Port ON */
  154.         if ( debses )
  155.             break;
  156.         cprint = TRUE ;
  157.         if ( !printon )
  158.             printeron() ;
  159.         break;
  160.     case DC3:
  161.         break;
  162.     case DC4:
  163.         /* Peripheral Port OFF */
  164.         if ( debses )
  165.             break;
  166.         cprint = FALSE ;
  167.         if ( !cprint && !uprint && !xprint && !aprint && printon )
  168.             printeroff();
  169.         break;
  170.     case NAK:
  171.         /* Cursor Right */
  172.         if ( debses )
  173.             break;
  174.         cursorright(0);
  175.         break;
  176.     case SYN:
  177.         /* Erase to EOL */
  178.         if ( debses )
  179.             break;
  180.         clrtoeoln(VTERM,SP);
  181.         break;
  182.     case ETB:
  183.         /* Erase to EOS */
  184.         if ( debses )
  185.             break;
  186.         clreoscr_escape(VTERM,SP);
  187.         break;
  188.     case CAN:
  189.         /* Clear */
  190.         if ( debses )
  191.             break;
  192.         cleartermscreen(VTERM);
  193.         break;
  194.     case XEM:
  195.         /* Cursor Home */
  196.         if ( debses )
  197.             break;
  198.         lgotoxy(VTERM,1,1);
  199.         break;
  200.     case SUB:
  201.         /* Cursor Up */
  202.         if ( debses )
  203.             break;
  204.         cursorup(0);
  205.         break;
  206.     case ESC:
  207.         break;
  208.     case XFS:
  209.         break;
  210.     case XGS:
  211.         break;
  212.     case XRS:
  213.         break;
  214.     case US:
  215.         break;
  216.     }
  217. }
  218.  
  219. void
  220. vcascii( int ch )
  221. {
  222.     int i,j,k,n,x,y,z;
  223.     vtattrib attr ;
  224.     viocell blankvcell;
  225.  
  226.     if (printon && (is_xprint() || is_uprint()))
  227.         prtchar(ch);
  228.  
  229.     if ( ch < SP )
  230.         vcctrl(ch) ;
  231.     else if ( !debses ) {
  232.         wrtch(ch);
  233.     }
  234.     VscrnIsDirty(VTERM) ;
  235. }
  236. #endif /* NOTERM */
  237.