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

  1. /*  C K O W Y S . C  --  Wyse 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. /*
  12.    the WYSE 160 manual describes additional keys that we don't support yet
  13. */
  14. /*    Prg               KeyName            */
  15.  
  16. /*      #    ESC W      Delete             */
  17. /*      (    ESC R      Shift Delete       */
  18. /*      X    ESC P      Shift Print Screen */
  19. /*      :    ESC J      PgUp               */
  20. /*      ;               Shift PgUp         */
  21. /*      \    ESC T      End                */
  22. /*      ]    ESC Y      Shift End          */
  23.  
  24. #ifdef NT
  25. #include <windows.h>
  26. #else /* NT */
  27. #include <os2.h>
  28. #undef COMMENT
  29. #endif /* NT */
  30.  
  31. #include "ckcdeb.h"
  32. #ifndef NOTERM
  33. #include "ckcker.h"
  34. #include "ckcasc.h"
  35. #include "ckuusr.h"
  36. #include "ckcuni.h"
  37. #include "ckocon.h"
  38. #include "ckokey.h"
  39. #include "ckowys.h"
  40. #include "ckctel.h"
  41.  
  42. extern bool keyclick ;
  43. extern int  cursorena[], keylock, duplex, duplex_sav, screenon ;
  44. extern int  printon, aprint, cprint, uprint, xprint, seslog ;
  45. extern int  insertmode, tnlm, ttmdm, decssdt, cmask;
  46. extern int  escstate, debses, decscnm, tt_cursor ;
  47. #ifdef PCTERM
  48. extern int tt_pcterm;
  49. #endif /* PCTERM */
  50. extern int  tt_type, tt_type_mode, tt_max, tt_answer, tt_status[VNUM], tt_szchng[] ;
  51. extern int  tt_modechg ;
  52. extern int  tt_cols[], tt_rows[], tt_wrap ;
  53. extern int  wherex[], wherey[], margintop, marginbot ;
  54. extern int  marginbell, marginbellcol ;
  55. extern char answerback[], htab[] ;
  56. extern struct tt_info_rec tt_info[] ;
  57. extern vtattrib attrib ;
  58. extern unsigned char attribute, colorstatus;
  59. extern char * udkfkeys[];
  60. extern int tt_senddata ;
  61. extern int tt_hidattr;
  62. extern int tt_sac;
  63. extern bool xprintff; /* Print formfeed */
  64. extern int tcsl;
  65.  
  66. extern struct _vtG G[];
  67. extern struct _vtG *GL, *GR;
  68.  
  69. #ifdef TCPSOCKET
  70. #ifdef CK_NAWS
  71. extern int tn_snaws();
  72. #endif /* CK_NAWS */
  73. #endif /* TCPSOCKET */
  74.  
  75. int protect = FALSE ;
  76. int autoscroll = TRUE ;
  77. int writeprotect = FALSE ;
  78. int linelock = FALSE ;
  79. int wysegraphics = FALSE ;
  80. int wyse8bit = FALSE;
  81. int attrmode = ATTR_CHAR_MODE ;
  82. int wy_keymode = FALSE ;
  83. int wy_enhanced = TRUE ;
  84. int wy_widthclr = FALSE ;
  85. int wy_autopage = FALSE ;
  86. int wy_nullsuppress = TRUE;
  87. int wy_monitor  = FALSE ;
  88. int wy_blockend = EOB_US_CR ;
  89. int wy_block = FALSE;                           /* Wyse/TVI Block Mode */
  90.  
  91. static char wy_labelmsg[MAXTERMCOL+1] ;
  92. static char wy_labelline[MAXTERMCOL+1] ;
  93. static char wy_shiftlabelline[MAXTERMCOL+1] ;
  94.  
  95. extern char fkeylabel[16][32];
  96.  
  97. vtattrib WPattrib   ={0,0,0,0,0,1,0,1,0,0,0} ;/* Dim, and Protected */
  98. vtattrib defWPattrib={0,0,0,0,0,1,0,1,0,0,0} ;/* Dim, and Protected */
  99.  
  100. int
  101. wyinc(void)
  102. {
  103.     extern int pmask, cmask;
  104.     extern int tt_utf8;
  105.     int ch;
  106.  
  107.   loop:
  108.     ch = ttinc(0);
  109.     if ( ch < 0 )
  110.         return ch;
  111.  
  112.     if ( seslog )
  113.         logchar(ch);
  114.  
  115.     /* Handle the UTF8 conversion if we are in that mode */
  116.     if ( tt_utf8 ) {
  117.         USHORT * ucs2 = NULL;
  118.         int rc = utf8_to_ucs2( (CHAR)(ch & 0xFF), &ucs2 );
  119.         if ( rc > 0 )
  120.             goto loop;
  121.         else if ( rc < 0 )
  122.             ch = 0xfffd;
  123.         else
  124.             ch = *ucs2;
  125.     }
  126.  
  127.     if ( !xprint ) {
  128. #ifndef NOXFER
  129.         autodown(ch);
  130. #endif /* NOXFER */
  131.         autoexitchk(ch);
  132.     }
  133.     ch = ch & pmask & cmask;
  134.     debugses(ch);
  135.     if (printon && (is_xprint() || is_uprint()))
  136.         prtchar(ch);
  137.     return ch;
  138. }
  139.  
  140. USHORT
  141. xlwygrph( CHAR c ) {
  142.     USHORT cx = 0 ;
  143.     extern struct _vtG *GNOW;
  144.     extern int win95lucida, win95hsl;
  145.  
  146.     if ( isunicode() ) {
  147.         cx = (*xl_u[TX_WYSE60G_N])(c) ;
  148.         if ( win95hsl && cx >= 0x23BA && cx <= 0x23BD )
  149.             cx = tx_hslsub(cx);
  150.         else if ( cx >= 0xE000 && cx <= 0xF8FF )
  151.             cx = tx_usub(cx);
  152.         if (win95lucida && cx > 0x017f)
  153.             cx = tx_lucidasub(cx);
  154.     }
  155.     else
  156.     {
  157.         cx = (*xl_u[TX_WYSE60G_N])(c) ;
  158.         if ( GNOW->itol )
  159.             cx = (*GNOW->itol)(cx);
  160.     }
  161.     return(cx);
  162. }
  163.  
  164. void
  165. wyse_tab( VOID )
  166. {
  167.     int i;
  168.  
  169.     if ( !protect ) {               /* Typewriter tabs */
  170.         i = wherex[VTERM];
  171.         if (i < VscrnGetWidth(VTERM))
  172.         {
  173.             do {
  174.                 i++;
  175.                 cursorright(0);
  176.             } while ((htab[i] != 'T') &&
  177.                       (i <= VscrnGetWidth(VTERM)-1));
  178.         }
  179.     } else {                        /* Field tabs */
  180.         int w = VscrnGetWidth(VTERM);
  181.         int h = VscrnGetHeight(VTERM)-(tt_status[VTERM]?1:0);
  182.         int x = wherex[VTERM]-1;
  183.         int y = wherey[VTERM]-1;
  184.         int field_found = 0;
  185.         vtattrib vta = {0,0,0,0,0,1,0,0,0,0,0}; /* Protected */
  186.  
  187.         for ( ; y < h ; y++,x=0 ) {
  188.             for (  ; x < w ; x++ ) {
  189.                 vta = VscrnGetVtCharAttr( VTERM, x, y ) ;
  190.                 if ( !field_found ) {
  191.                     if (vta.unerasable)
  192.                         field_found = 1;
  193.                 } else {
  194.                     if ( !vta.unerasable )
  195.                         goto nextstep;
  196.                 }
  197.             }
  198.         }
  199.  
  200.       nextstep:
  201.         if ( y == h ) {
  202.             y = 0;
  203.             x = 0;
  204.             for ( ; y <= wherey[VTERM]-1 ; y++, x=0 ) {
  205.                 for ( ; y == wherey[VTERM]-1 ? x < wherex[VTERM]-1 : x < w ;
  206.                       x++ ) {
  207.                     vta = VscrnGetVtCharAttr( VTERM, x, y ) ;
  208.                     if ( !field_found ) {
  209.                         if (vta.unerasable)
  210.                             field_found = 1;
  211.                     } else {
  212.                         if ( !vta.unerasable )
  213.                             goto nextstep2;
  214.                     }
  215.                 }
  216.             }
  217.         }
  218.  
  219. nextstep2:
  220.         if ( field_found )
  221.             lgotoxy(VTERM,x+1,y+1);
  222.     }
  223.     VscrnIsDirty(VTERM);
  224.  
  225. }
  226.  
  227. void
  228. wyse_backtab( VOID )
  229. {
  230.     int i;
  231.  
  232.     if ( !protect ) {       /* Typewriter tabs */
  233.         i = wherex[VTERM];
  234.         if (i > 1) {
  235.             do {
  236.                 i--;
  237.                 cursorleft(0);
  238.             } while ((htab[i] != 'T') &&
  239.                       (i >= 2));
  240.  
  241.             /*
  242.             if the current cell is a protected cell, we must move
  243.             the current cursor to the first unprotected position.
  244.             */
  245.  
  246.             VscrnIsDirty(VTERM);
  247.         }
  248.     } else {    /* Field tabs */
  249.         /* This code, because it uses Vscrn...() functions, uses 0-based
  250.         * offsets instead of 1-based offsets as in where[xy] vars.
  251.         */
  252.  
  253.         int w = VscrnGetWidth(VTERM);
  254.         int h = VscrnGetHeight(VTERM)-(tt_status[VTERM]?1:0);
  255.         int x = wherex[VTERM]-1;
  256.         int y = wherey[VTERM]-1;
  257.         int field_found = 0;
  258.         vtattrib vta = {0,0,0,0,0,1,0,0,0,0,0}; /* Protected */
  259.  
  260.         /* First, we must find the beginning of the current field that we are on. */
  261.         /* Then we must find the end of the previous field. */
  262.         /* And finally we must find the beginning of that field and position the cursor. */
  263.  
  264.         for ( ; y >= 0 ; y--,x=w-1 ) {
  265.             for (  ; x >= 0 ; x-- ) {
  266.                 vta = VscrnGetVtCharAttr( VTERM, x, y );
  267.                 if ( field_found == 1 ) {
  268.                     if (!vta.unerasable)
  269.                         field_found = 2;
  270.                 } else {
  271.                     if (vta.unerasable) {
  272.                         if ( field_found == 2 ) {
  273.                             field_found = 3;
  274.                             goto nextstep1;
  275.                         }
  276.                         else
  277.                             field_found = 1;
  278.                     }
  279.                 }
  280.             }
  281.         }
  282.  
  283.       nextstep1:
  284.         if ( y == -1 ) {
  285.             y = h-1;
  286.             x = w-1;
  287.             for ( ; y >= wherey[VTERM]-1 ; y--, x=w-1 ) {
  288.                 for ( ; y == wherey[VTERM]-1 ? (x > wherex[VTERM]-1) : (x >= 0);
  289.                       x-- ) {
  290.                     vta = VscrnGetVtCharAttr( VTERM, x, y ) ;
  291.                     if ( field_found == 1 ) {
  292.                         if (!vta.unerasable)
  293.                             field_found = 2;
  294.                     } else {
  295.                         if (vta.unerasable) {
  296.                             if ( field_found == 2 ) {
  297.                                 field_found = 3;
  298.                                 goto nextstep2;
  299.                             } else
  300.                                 field_found = 1;
  301.                         }
  302.                     }
  303.                 }
  304.             }
  305.         }
  306.  
  307.       nextstep2:
  308.         if ( field_found == 3 ) {
  309.             x++;
  310.             if ( x == w ) {
  311.                 x = 0;
  312.                 y++;
  313.                 if ( y == h )
  314.                     y = 0;
  315.             }
  316.             lgotoxy(VTERM,x+1,y+1);
  317.             VscrnIsDirty(VTERM);
  318.         }
  319.     }
  320. }
  321.  
  322. void
  323. wysectrl( int ch )
  324. {
  325.     int i,j;
  326.  
  327.     if ( !xprint ) {
  328.     switch ( ch ) {
  329.     case ETX:
  330.         debug(F110,"Wyse Ctrl","keylock off",0);
  331.         if ( debses )
  332.             break;
  333.         if ( wy_enhanced )
  334.             keylock = FALSE ;
  335.         break;
  336.     case EOT:
  337.         debug(F110,"Wyse Ctrl","keylock on",0);
  338.         if ( debses )
  339.             break;
  340.         if ( wy_enhanced )
  341.             keylock = TRUE ;
  342.         break;
  343.     case ENQ:
  344.         debug(F110,"Wyse Ctrl","Request Answerback String",0);
  345.         if ( debses )
  346.             break;
  347.         if (tt_answer)
  348.             sendchars(answerback,strlen(answerback)) ;
  349.         break;
  350.     case ACK:
  351.         debug(F110,"Wyse Ctrl","Cursor Right",0);
  352.         if ( debses )
  353.             break;
  354.         if ( wy_enhanced )
  355.             cursorright(0);
  356.         break;
  357.     case BEL:
  358.         debug(F110,"Wyse Ctrl","Ring Bell",0);
  359.         if ( debses )
  360.             break;
  361.         bleep(BP_BEL);
  362.         break;
  363.     case BS:
  364.         debug(F110,"Wyse Ctrl","Cursor Left",0);
  365.         if ( debses )
  366.             break;
  367.         cursorleft(0) ;
  368.         break;
  369.     case HT:
  370.         debug(F110,"Wyse Ctrl","Horizontal Tab",0);
  371.         if ( debses )
  372.             break;
  373.         wyse_tab();
  374.         break;
  375.     case LF:
  376.         debug(F110,"Wyse Ctrl","Line Feed",0);
  377.         if ( debses )
  378.             break;
  379.         if ( autoscroll && !protect || wherey[VTERM] < marginbot )
  380.             wrtch((char) LF);
  381.         break;
  382.     case VT:
  383.         debug(F110,"Wyse Ctrl","Cursor Up",0);
  384.         if ( debses )
  385.             break;
  386.         cursorup(0) ;
  387.         break;
  388.     case FF:
  389.         debug(F110,"Wyse Ctrl","Cursor Right",0);
  390.         if ( debses )
  391.             break;
  392.         cursorright(0) ;
  393.         break;
  394.     case CR:
  395.         debug(F110,"Wyse Ctrl","Carriage Return",0);
  396.         if ( debses )
  397.             break;
  398.         wrtch((char) CR);
  399.         break;
  400.     case SO:
  401.         debug(F110,"Wyse Ctrl","keylock off",0);
  402.         if ( debses )
  403.             break;
  404.         keylock = FALSE ;
  405.         break;
  406.     case SI:
  407.         debug(F110,"Wyse Ctrl","keylock on",0);
  408.         if ( debses )
  409.             break;
  410.         keylock = TRUE ;
  411.         break;
  412.     case DLE:
  413.         if ( !ISWY60(tt_type_mode) ) {
  414.             if ( wy_enhanced ) {
  415.                 /* Address cursor to column */
  416.                 int col = wyinc() ;
  417.                 debug(F111,"Wyse Ctrl","Address cursor to column",col);
  418.  
  419.                 if ( debses )
  420.                     break;
  421.                 lgotoxy(VTERM,col-31,wherey[VTERM]);
  422.             }
  423.         } else {
  424.             CHAR ch;
  425.             ch = wyinc() ;
  426.  
  427.             debug(F111,"Wyse Ctrl","Print single char (not implemented)",ch);
  428.  
  429.             if ( debses )
  430.                 break;
  431.         }
  432.         break;
  433.     case DC1:
  434.         /* Enable transmission */
  435.         debug(F110,"Wyse Ctrl","Enable transmission",0);
  436.         break;
  437.     case DC2:
  438.         /* WY30 defines this as Copy Print */
  439.         /* transparent printer with screen display */
  440.         debug(F110,"Wyse Ctrl","Copy Print On",0);
  441.         if ( debses )
  442.             break;
  443.         cprint = TRUE ;
  444.         if ( !printon )
  445.             printeron() ;
  446.         break;
  447.     case DC3:
  448.         /* Disable transmission */
  449.         debug(F110,"Wyse Ctrl","Disable Transmission",0);
  450.         break;
  451.     case DC4:
  452.         /* Turn all print modes off */
  453.         debug(F110,"Wyse Ctrl","Print Off",0);
  454.         if ( debses )
  455.             break;
  456.         xprint = cprint = FALSE ;
  457.         setaprint(FALSE);
  458.         if ( !uprint && !xprint && !cprint && !aprint && printon )
  459.             printeroff();
  460.         break;
  461.     case NAK:
  462.         debug(F110,"Wyse Ctrl","Cursor Left",0);
  463.         if ( debses )
  464.             break;
  465.         if ( wy_enhanced )
  466.             cursorleft(0) ;
  467.         break;
  468.     case SYN:
  469.         /* Cursordown - no scroll */
  470.         debug(F110,"Wyse Ctrl","Cursor Down",0);
  471.         if ( debses )
  472.             break;
  473.         cursordown(0) ;
  474.         break;
  475.     case ETB:
  476.         /* Cursor Off */
  477.         debug(F110,"Wyse Ctrl","Cursor Off",0);
  478.         if ( debses )
  479.             break;
  480.         if ( wy_enhanced )
  481.             cursorena[VTERM] = FALSE;
  482.         break;
  483.     case CAN:
  484.         /* Transparent print on */
  485.         debug(F110,"Wyse Ctrl","Transparent Print On",0);
  486.         if ( debses )
  487.             break;
  488.         if ( wy_enhanced ) {
  489.             xprint = TRUE ;
  490.             if ( !printon )
  491.                 printeron() ;
  492.         }
  493.         break;
  494.     case SUB:
  495.         /* Clear unprotected page to spaces */
  496.         debug(F110,"Wyse Ctrl","Clear unprotected page to spaces",0);
  497.         if ( debses )
  498.             break;
  499.         if ( protect )
  500.             selclrscreen( VTERM, SP ) ;
  501.         else
  502.             clrscreen( VTERM, SP ) ;
  503.         lgotoxy(VTERM,1,1);
  504.         break;
  505.     case ESC:
  506.         debug(F110,"Wyse Ctrl","Initiate Escape Sequence",0);
  507.         /* initiate escape sequence */
  508.         escstate = ES_GOTESC ;
  509.         break;
  510.     case XRS:
  511.         /* Home cursor */
  512.         debug(F110,"Wyse Ctrl","Home Cursor",0);
  513.         if ( debses )
  514.             break;
  515.         lgotoxy(VTERM,1,1) ;
  516.         break;
  517.     case US:
  518.         /* Cursor to start on next line */
  519.         debug(F110,"Wyse Ctrl","Cursor to Next Line",0);
  520.         if ( debses )
  521.             break;
  522.         if (autoscroll && !protect) {
  523.             wrtch((CHAR)CR);
  524.             wrtch((CHAR)LF);
  525.         }
  526.         break;
  527.     }
  528.     }
  529.     else {      /* xprint */
  530.         switch ( ch ) {
  531.         case DC4:
  532.             /* Turn all print modes off */
  533.             debug(F110,"Wyse Ctrl","Print Off",0);
  534.             if ( debses )
  535.                 break;
  536.             xprint = cprint = FALSE ;
  537.             setaprint(FALSE);
  538.             if ( !uprint && !xprint && !cprint && !aprint && printon )
  539.                 printeroff();
  540.             break;
  541.         case ESC:
  542.             /* initiate escape sequence */
  543.             debug(F110,"Wyse Ctrl","Initiate Escape Sequence",0);
  544.             escstate = ES_GOTESC ;
  545.             break;
  546.         }
  547.     }
  548. }
  549.  
  550. vtattrib
  551. wysecharattr( int ch )
  552. {
  553.     vtattrib a ;
  554.  
  555.     a.blinking = FALSE;                 /* No blink */
  556.     a.bold = FALSE;                     /* No bold */
  557.     a.dim = FALSE;                      /* No dim */
  558.     a.invisible = FALSE;                /* Visible */
  559.     a.underlined = FALSE;               /* No underline */
  560.     a.reversed = FALSE;                 /* No reverse video */
  561.     a.unerasable = attrib.unerasable ;  /* Erasable */
  562.     a.graphic = FALSE ;                 /* Not graphic character */
  563.     a.wyseattr = FALSE ;                /* WYSE attribute */
  564.  
  565.     debug(F111,"Wyse","Character Attribute",ch);
  566.  
  567.     switch ( ch ) {
  568.     case '0':
  569.         /* Normal */
  570.         break;
  571.     case '1':
  572.         /* Blank (no display) */
  573.         a.invisible = TRUE ;
  574.         break;
  575.     case '2':
  576.         /* Blink */
  577.         a.blinking = TRUE ;
  578.         break;
  579.     case '3':
  580.         /* Blank */
  581.         a.invisible = TRUE ;
  582.         break;
  583.     case '4':
  584.         /* Reverse */
  585.         a.reversed = TRUE ;
  586.         break;
  587.     case '5':
  588.         /* Reverse and Blank */
  589.         a.reversed = TRUE ;
  590.         a.invisible = TRUE ;
  591.         break;
  592.     case '6':
  593.         /* Reverse and Blink */
  594.         a.reversed = TRUE ;
  595.         a.blinking = TRUE ;
  596.         break;
  597.     case '7':
  598.         /* Reverse, blink?, and blank */
  599.         a.reversed = TRUE ;
  600.         a.blinking = TRUE ;
  601.         a.invisible = TRUE ;
  602.         break;
  603.     case '8':
  604.         /* Underscore */
  605.         a.underlined = TRUE ;
  606.         break;
  607.     case '9':
  608.         /* Underscore and blank */
  609.         a.underlined = TRUE ;
  610.         a.invisible = TRUE ;
  611.         break;
  612.     case ':':
  613.       /* Underscore and blink */
  614.         a.underlined = TRUE ;
  615.         a.blinking = TRUE ;
  616.         break;
  617.     case ';':
  618.       /* Underscore, blink, and blank */
  619.         a.underlined = TRUE ;
  620.         a.blinking = TRUE ;
  621.         a.invisible = TRUE ;
  622.         break;
  623.     case '<':
  624.       /* Underscore and Reverse */
  625.         a.underlined = TRUE ;
  626.         a.reversed = TRUE ;
  627.         break;
  628.     case '=':
  629.       /* Underscore, Reverse, and blank */
  630.         a.underlined = TRUE ;
  631.         a.reversed = TRUE ;
  632.         a.invisible = TRUE;
  633.         break;
  634.     case '>':
  635.       /* Underscore, Reverse, and blink */
  636.         a.underlined = TRUE ;
  637.         a.reversed = TRUE ;
  638.         a.blinking = TRUE ;
  639.         break;
  640.     case '?':
  641.       /* Underscore, Reverse, Blink, and Blank */
  642.         a.underlined = TRUE ;
  643.         a.reversed = TRUE ;
  644.         a.blinking = TRUE ;
  645.         a.invisible = TRUE ;
  646.         break;
  647.     case 'p':
  648.       /* Dim */
  649.         a.dim = TRUE ;
  650.         break;
  651.     case 'q':
  652.       /* Dim and Blank */
  653.         a.dim = TRUE ;
  654.         a.invisible = TRUE ;
  655.         break;
  656.     case 'r':
  657.       /* Dim and Blink */
  658.         a.dim = TRUE ;
  659.         a.blinking = TRUE ;
  660.         break;
  661.     case 's':
  662.       /* Dim, Blink?, and Blank */
  663.         a.dim = TRUE ;
  664.         a.blinking = TRUE ;
  665.         a.invisible = TRUE ;
  666.         break;
  667.     case 't':
  668.       /* Dim and Reverse */
  669.         a.dim = TRUE ;
  670.         a.reversed = TRUE ;
  671.         break;
  672.     case 'u':
  673.       /* Dim, Reverse, and Blank */
  674.         a.dim = TRUE ;
  675.         a.reversed = TRUE ;
  676.         a.invisible = TRUE ;
  677.         break;
  678.     case 'v':
  679.       /* Dim, Reverse, and Blink */
  680.         a.dim = TRUE ;
  681.         a.reversed = TRUE ;
  682.         a.blinking = TRUE ;
  683.         break;
  684.     case 'w':
  685.       /* Dim, Reverse, Blink?, and Blank */
  686.         a.dim = TRUE ;
  687.         a.reversed = TRUE ;
  688.         a.blinking = TRUE ;
  689.         a.invisible = TRUE ;
  690.         break;
  691.     case 'x':
  692.       /* Dim and Underscore */
  693.         a.dim = TRUE ;
  694.         a.underlined = TRUE ;
  695.         break;
  696.     case 'y':
  697.       /* Dim, Underscore, and Blank */
  698.         a.dim = TRUE ;
  699.         a.underlined = TRUE ;
  700.         a.invisible = TRUE ;
  701.         break;
  702.     case 'z':
  703.       /* Dim, Underscore, and Blink */
  704.         a.dim = TRUE ;
  705.         a.underlined = TRUE ;
  706.         a.blinking = TRUE ;
  707.         break;
  708.     case '{':
  709.       /* Dim, Underscore, Blink, and Blank */
  710.         a.dim = TRUE ;
  711.         a.underlined = TRUE ;
  712.         a.blinking = TRUE ;
  713.         a.invisible = TRUE ;
  714.         break;
  715.     case '|':
  716.       /* Dim, Underscore, and Reverse */
  717.         a.dim = TRUE ;
  718.         a.underlined = TRUE ;
  719.         a.reversed = TRUE ;
  720.         break;
  721.     case '}':
  722.       /* Dim, Underscore, Reverse, and Blank */
  723.         a.dim = TRUE ;
  724.         a.underlined = TRUE ;
  725.         a.reversed = TRUE ;
  726.         a.invisible = TRUE ;
  727.         break;
  728.     case '~':
  729.       /* Dim, Underscore, Reverse, and Blink */
  730.         a.dim = TRUE ;
  731.         a.underlined = TRUE ;
  732.         a.reversed = TRUE ;
  733.         a.blinking = TRUE ;
  734.         break;
  735.     }
  736.     return a;
  737. }
  738.  
  739. USHORT
  740. wyselineattr( int ch )
  741. {
  742.     USHORT lineattr = 0 ;
  743.  
  744.     debug(F111,"Wyse","Line Attribute",ch);
  745.  
  746.     switch ( ch ) {
  747.     case '@':
  748.         lineattr = VT_LINE_ATTR_NORMAL ;
  749.         break;
  750.     case 'A':
  751.         lineattr = VT_LINE_ATTR_DOUBLE_WIDE ;
  752.         break;
  753.     case 'B':
  754.         lineattr = VT_LINE_ATTR_DOUBLE_HIGH | VT_LINE_ATTR_UPPER_HALF ;
  755.         break;
  756.     case 'C':
  757.         lineattr = VT_LINE_ATTR_DOUBLE_HIGH | VT_LINE_ATTR_LOWER_HALF ;
  758.         break;
  759.     case 'D':
  760.         lineattr = VT_LINE_ATTR_DOUBLE_HIGH | VT_LINE_ATTR_UPPER_HALF
  761.             | VT_LINE_ATTR_DOUBLE_WIDE ;
  762.         break;
  763.     case 'E':
  764.         lineattr = VT_LINE_ATTR_DOUBLE_HIGH | VT_LINE_ATTR_LOWER_HALF
  765.             | VT_LINE_ATTR_DOUBLE_WIDE ;
  766.         break;
  767.     }
  768.  
  769.     return lineattr ;
  770. }
  771.  
  772. USHORT
  773. wyselinebg( int ch )
  774. {
  775.     USHORT linebg = 0;
  776.  
  777.     debug(F111,"Wyse","Line Background",ch);
  778.  
  779.     switch ( ch ) {
  780.     case 'G':
  781.         linebg = WY_LINE_ATTR_BG_NORMAL ;
  782.         break;
  783.     case 'H':
  784.         linebg = WY_LINE_ATTR_BG_BOLD ;
  785.         break;
  786.     case 'I':
  787.         linebg = WY_LINE_ATTR_BG_INVISIBLE ;
  788.         break;
  789.     case 'J':
  790.         linebg = WY_LINE_ATTR_BG_DIM ;
  791.         break;
  792.     }
  793.     return linebg;
  794. }
  795.  
  796. void
  797. ApplyPageAttribute( int vmode, int x, int y, vtattrib vta )
  798. {
  799.     vtattrib oldvta, prevvta ;
  800.     int rc ;
  801.  
  802.     RequestVscrnMutex( vmode, SEM_INDEFINITE_WAIT ) ;
  803.     prevvta = VscrnGetVtCharAttr( vmode, x-1, y-1 ) ;
  804.  
  805.     if ( !tt_hidattr  || ISHP(tt_type_mode) )
  806.         vta.wyseattr = TRUE ;
  807.     VscrnSetVtCharAttr( vmode, x-1, y-1, vta ) ;
  808.     vta.wyseattr = FALSE ;
  809.  
  810.     oldvta = prevvta ;
  811.     while ( TRUE ) {
  812.         if ( ++x > VscrnGetWidth(vmode) ) {
  813.             if ( ++y > marginbot ) {
  814.                 break  ;                /* we are done */
  815.             }
  816.             x = 1 ;
  817.         }
  818.  
  819.         /* Retrieve the attributes of the new position */
  820.         oldvta = VscrnGetVtCharAttr( vmode, x-1, y-1 ) ;
  821.         if ( (!tt_hidattr || ISHP(tt_type_mode)) && oldvta.wyseattr)
  822.             break;
  823.         if ( oldvta.unerasable && protect)
  824.             continue;
  825.         if ( tt_hidattr &&
  826.              (oldvta.reversed != prevvta.reversed ||
  827.                oldvta.blinking != prevvta.blinking ||
  828.                oldvta.underlined != prevvta.underlined ||
  829.                oldvta.bold != prevvta.bold ||
  830.                oldvta.invisible != prevvta.invisible ||
  831.                oldvta.dim != prevvta.dim))
  832.             break;
  833.         vta.unerasable = oldvta.unerasable;
  834.         VscrnSetVtCharAttr( vmode, x-1, y-1, vta ) ;
  835.     }
  836.     ReleaseVscrnMutex( vmode ) ;
  837. }
  838.  
  839. void
  840. ApplyLineAttribute( int vmode, int x, int y, vtattrib vta )
  841. {
  842.     vtattrib oldvta, prevvta ;
  843.  
  844.     RequestVscrnMutex( vmode, SEM_INDEFINITE_WAIT ) ;
  845.     prevvta = VscrnGetVtCharAttr( vmode, x-1, y-1 ) ;
  846.  
  847.     if ( !tt_hidattr || ISHP(tt_type_mode) )
  848.         vta.wyseattr = TRUE ;
  849.     VscrnSetVtCharAttr( vmode, x-1, y-1, vta ) ;
  850.     vta.wyseattr = FALSE ;
  851.  
  852.     oldvta = prevvta ;
  853.     for ( x++ ; x <= VscrnGetWidth(vmode); x++ ) {
  854.         /* Retrieve the attributes of the new position */
  855.         oldvta = VscrnGetVtCharAttr( vmode, x-1, y-1 ) ;
  856.         if ( (!tt_hidattr || ISHP(tt_type_mode)) && oldvta.wyseattr)
  857.             break;
  858.         if ( oldvta.unerasable )
  859.             continue;
  860.         if ( tt_hidattr &&
  861.              (oldvta.reversed != prevvta.reversed ||
  862.                oldvta.blinking != prevvta.blinking ||
  863.                oldvta.underlined != prevvta.underlined ||
  864.                oldvta.bold != prevvta.bold ||
  865.                oldvta.invisible != prevvta.invisible ||
  866.                oldvta.dim != prevvta.dim))
  867.             break;
  868.         vta.unerasable = oldvta.unerasable;
  869.         VscrnSetVtCharAttr( vmode, x-1, y-1, vta ) ;
  870.     }
  871.     ReleaseVscrnMutex( vmode ) ;
  872. }
  873.  
  874. char *
  875. wysedefkey( int key )
  876. {
  877.     debug(F111,"Wyse","Define Key to Default",key);
  878. #ifndef NOKVERBS
  879.     switch ( key + K_WYF01 ) {
  880.     case K_WYF01: return strdup("\01@\r");    /* F1 */
  881.     case K_WYF02: return strdup("\01A\r");
  882.     case K_WYF03: return strdup("\01B\r");
  883.     case K_WYF04: return strdup("\01C\r");
  884.     case K_WYF05: return strdup("\01D\r");
  885.     case K_WYF06: return strdup("\01E\r");
  886.     case K_WYF07: return strdup("\01F\r");
  887.     case K_WYF08: return strdup("\01G\r");
  888.     case K_WYF09: return strdup("\01H\r");
  889.     case K_WYF10: return strdup("\01I\r");
  890.     case K_WYF11: return strdup("\01J\r");
  891.     case K_WYF12: return strdup("\01K\r");
  892.     case K_WYF13: return strdup("\01L\r");
  893.     case K_WYF14: return strdup("\01M\r");
  894.     case K_WYF15: return strdup("\01N\r");
  895.     case K_WYF16: return strdup("\01O\r");
  896.     case K_WYF17: return strdup("\01P\r");
  897.     case K_WYF18: return strdup("\01Q\r");
  898.     case K_WYF19: return strdup("\01R\r");
  899.     case K_WYF20: return strdup("\01S\r");   /* F20 */
  900.     case K_WYSF01: return strdup("\01`\r");   /* Shift-F1 */
  901.     case K_WYSF02: return strdup("\01a\r");
  902.     case K_WYSF03: return strdup("\01b\r");
  903.     case K_WYSF04: return strdup("\01c\r");
  904.     case K_WYSF05: return strdup("\01d\r");
  905.     case K_WYSF06: return strdup("\01e\r");
  906.     case K_WYSF07: return strdup("\01f\r");
  907.     case K_WYSF08: return strdup("\01g\r");
  908.     case K_WYSF09: return strdup("\01h\r");
  909.     case K_WYSF10: return strdup("\01i\r");
  910.     case K_WYSF11: return strdup("\01j\r");
  911.     case K_WYSF12: return strdup("\01k\r");
  912.     case K_WYSF13: return strdup("\01l\r");
  913.     case K_WYSF14: return strdup("\01m\r");
  914.     case K_WYSF15: return strdup("\01n\r");
  915.     case K_WYSF16: return strdup("\01o\r");
  916.     case K_WYSF17: return strdup("\01p\r");
  917.     case K_WYSF18: return strdup("\01q\r");
  918.     case K_WYSF19: return strdup("\01r\r");
  919.     case K_WYSF20: return strdup("\01s\r");   /* Shift-F20 */
  920.     case K_WYBS     : return strdup("\x08");      /* Backspace */
  921.     case K_WYCLRLN  : return strdup("\x1BT");     /* Clr Line */
  922.     case K_WYSCLRLN : return strdup("\x1Bt");     /* Shift Clr Line */
  923.     case K_WYCLRPG  : return strdup("\x1BY");     /* Clr Page */
  924.     case K_WYSCLRPG : return strdup("\x1By");     /* Shift Clr Page */
  925.     case K_WYDELCHAR: return strdup("\x1BW");     /* Del Char */
  926.     case K_WYDELLN  : return strdup("\x1BR");     /* Del Line */
  927.     case K_WYENTER  : return strdup("\x0D");      /* Enter */
  928.     case K_WYESC    : return strdup("\x1B");      /* Escape */
  929.     case K_WYHOME   : return strdup("\x1E");      /* Home */
  930.     case K_WYSHOME  : return strdup("\x1B{");     /* Shift Home */
  931.     case K_WYINSERT : return strdup("\x1Bq");     /* Insert */
  932.     case K_WYINSCHAR: return strdup("\x1BQ");     /* Ins Char */
  933.     case K_WYINSLN  : return strdup("\x1B\x45");  /* Ins Line */
  934.     case K_WYPGNEXT : return strdup("\x1BK");     /* Page Next*/
  935.     case K_WYPGPREV : return strdup("\x1BJ");     /* Page Prev*/
  936.     case K_WYREPLACE: return strdup("\x1Br");     /* Replace */
  937.     case K_WYRETURN: return strdup("\x0D");       /* Return */
  938.     case K_WYTAB   : return strdup("\x09");       /* Tab */
  939.     case K_WYSTAB  : return strdup("\x1BI");      /* Shift Tab */
  940.     case K_WYPRTSCN: return strdup("\x1BP");      /* Print Screen */
  941.     case K_WYSESC   : return NULL;                /* Shift Esc */
  942.     case K_WYSBS    : return strdup("\x08");      /* Shift BS */
  943.     case K_WYSENTER : return NULL ;               /* Shift Enter */
  944.     case K_WYSRETURN: return NULL ;               /* Shift Return */
  945.     case K_WYUPARR : return strdup("\x0b");       /* Up Arrow - VT */
  946.     case K_WYDNARR : return strdup("\x0a");       /* Dn Arrow - LF */
  947.     case K_WYLFARR : return strdup("\x08");       /* Left Arrow - BS */
  948.     case K_WYRTARR : return strdup("\x0c");       /* Right Arrow - NL */
  949.     case K_WYSUPARR: return NULL ;                /* Shift Up Arrow */
  950.     case K_WYSDNARR: return NULL ;                /* Shift Dn Arrow */
  951.     case K_WYSLFARR: return NULL ;                /* Shift Left Arrow */
  952.     case K_WYSRTARR: return NULL ;                /* Shift Right Arrow */
  953.     case K_WYSEND : return strdup("\x1B\x37");    /* Send */
  954.     case K_WYSSEND: return NULL ;                 /* Shift Send */
  955.     default:
  956.         debug(F111,"Wyse","Key undefined",key);
  957.         return NULL ;
  958.     }
  959. #else
  960.     return(NULL);
  961. #endif /* NOKVERBS */
  962. }
  963.  
  964. void
  965. wyseascii( int ch )
  966. {
  967.     int i,j,k,n,x,y,z;
  968.     vtattrib attr ;
  969.     viocell blankvcell;
  970.  
  971.     if (printon && (is_xprint() || is_uprint()))
  972.         prtchar(ch);
  973.  
  974.     if ( escstate == ES_GOTESC )/* Process character as part of an escstate sequence */
  975.     {
  976.         if ( ch < SP ) {
  977.             escstate = ES_NORMAL ;
  978.             wysectrl(ch) ;
  979.         }
  980.         else
  981.         {
  982.             escstate = ES_ESCSEQ ;
  983.             if ( !xprint ) {
  984.             switch ( ch ) {
  985.             case SP:
  986.                 /* Reports the terminal identification to the */
  987.                 /* Host computer */
  988.                 debug(F110,"Wyse Escape","Terminal ID Request",0);
  989.                 if ( !debses )
  990.                     sendchars( tt_info[tt_type].x_id,
  991.                                strlen(tt_info[tt_type].x_id) ) ;
  992.                 break;
  993.             case '!':
  994.                 if ( !ISWY60(tt_type_mode) ) {
  995.                     /* Writes all unprotected character positions with   */
  996.                     /* a specified attribute code.  This has a format of */
  997.                     /* ESC ! ATTR where ATTR = attribute code.           */
  998.                     /* This is not supported by the Wyse 60              */
  999.                     int xs = VscrnGetWidth(VTERM);
  1000.                     int ys = VscrnGetHeight(VTERM)-(tt_status[VTERM]?1:0);
  1001.                     vtattrib vta ;
  1002.                     debug(F110,"Wyse Escape","Write Unprotected with Attribute",0);
  1003.                     ch = wyinc();
  1004.                     switch ( ch ) {
  1005.                     case SP: {
  1006.                         if ( debses )
  1007.                              break;
  1008.                         if ( protect )
  1009.                             selclrscreen( VTERM, SP ) ;
  1010.                         else
  1011.                             clrscreen( VTERM, SP );
  1012.                         lgotoxy(VTERM,1,1);       /* and home the cursor */
  1013.                         break;
  1014.                     }
  1015.                     case '0':
  1016.                     case '1':
  1017.                     case '2':
  1018.                     case '3':
  1019.                     case '4':
  1020.                     case '5':
  1021.                     case '6':
  1022.                     case '7':
  1023.                     case '8':
  1024.                     case '9':
  1025.                     case ':':
  1026.                     case ';':
  1027.                     case '<':
  1028.                     case '=':
  1029.                     case '>':
  1030.                     case '?':
  1031.                     case 'p':
  1032.                     case 'q':
  1033.                     case 'r':
  1034.                     case 's':
  1035.                     case 't':
  1036.                     case 'u':
  1037.                     case 'v':
  1038.                     case 'w':
  1039.                     case 'x':
  1040.                     case 'y':
  1041.                     case 'z':
  1042.                     case '{':
  1043.                     case '|':
  1044.                     case '}':
  1045.                     case '~':
  1046.                     {
  1047.                         attr = wysecharattr( ch ) ;
  1048.                         if ( debses )
  1049.                             break;
  1050.  
  1051.                         for ( y = 0 ; y < ys ; y++ )
  1052.                             for ( x = 0 ; x < xs ; x++ ) {
  1053.                                 vta = VscrnGetVtCharAttr( VTERM, x, y ) ;
  1054.                                 if ( !protect || !vta.unerasable )
  1055.                                     VscrnSetVtCharAttr( VTERM, x, y, attr ) ;
  1056.                             }
  1057.                         break;
  1058.                     }
  1059.                     }
  1060.                 }
  1061.                 break;
  1062.             case '"':
  1063.                 /* Unlocks the keyboard */
  1064.                 debug(F110,"Wyse Escape","keylock off",0);
  1065.                 if ( !debses )
  1066.                     keylock = FALSE ;
  1067.                 break;
  1068.             case '#':
  1069.                 /* Locks the keyboard */
  1070.                 debug(F110,"Wyse Escape","keylock on",0);
  1071.                 if ( !debses )
  1072.                     keylock = TRUE ;
  1073.                 break;
  1074.             case '$':
  1075.                 debug(F110,"Wyse Escape","$",0);
  1076.                 break;
  1077.             case '%':
  1078.                 debug(F110,"Wyse Escape","%",0);
  1079.                 break;
  1080.             case '&':
  1081.                 /* Turns the protect submode on and prevents the auto */
  1082.                 /* scroll operation */
  1083.                 debug(F110,"Wyse Escape","Protect On",0);
  1084.                 if ( !debses )
  1085.                     protect = TRUE ;
  1086.                 break;
  1087.             case '\'':
  1088.                 /* Turns the protect submode off and allows the auto */
  1089.                 /* scroll operation */
  1090.                 debug(F110,"Wyse Escape","Protect Off",0);
  1091.                 if ( !debses )
  1092.                     protect = FALSE ;
  1093.                 break;
  1094.             case '(':
  1095.                 /* Turns the write protect submode off */
  1096.                 debug(F110,"Wyse Escape","Write Protect Off",0);
  1097.                 if ( debses || !writeprotect )
  1098.                     break;
  1099.                 writeprotect = FALSE ;
  1100.                 attrib.unerasable = FALSE;
  1101.                 break;
  1102.             case ')':
  1103.                 /* Turns the write protect submode on */
  1104.                 debug(F110,"Wyse Escape","Write Protect On",0);
  1105.                 if ( debses || writeprotect )
  1106.                     break;
  1107.                 writeprotect = TRUE ;
  1108.                 attrib.unerasable = TRUE ;
  1109.                 break;
  1110.             case '*':
  1111.                 /* Clears the screen to nulls. */
  1112.                 /* The protect submode is turned off */
  1113.                 debug(F110,"Wyse Escape","Clear screen to NUL; Protect Off; Home Cursor",0);
  1114.                 if ( debses )
  1115.                     break;
  1116.                 protect = FALSE ;
  1117.                 writeprotect = FALSE ;
  1118.                 insertmode = FALSE ;
  1119.                 clrscreen( VTERM, NUL ) ;
  1120.                 lgotoxy(VTERM,1,1);       /* and home the cursor */
  1121.                 break;
  1122.             case '+':
  1123.                 /* Clears the screen to spaces. */
  1124.                 /* The protect submode is turned off */
  1125.                 debug(F110,"Wyse Escape","Clear screen to SP; Protect Off; Home Cursor",0);
  1126.                 if ( debses )
  1127.                     break;
  1128.                 attrib.unerasable = FALSE;
  1129.                 protect = FALSE ;
  1130.                 writeprotect = FALSE ;
  1131.                 insertmode = FALSE ;
  1132.                 clrscreen( VTERM, SP );
  1133.                 lgotoxy(VTERM,1,1);       /* and home the cursor */
  1134.                 break;
  1135.             case ',': {
  1136.                 /* Clears the screen to protected spaces. */
  1137.                 /* The protect submode is turned off */
  1138.                 /* Home Cursor */
  1139.                 int xs = VscrnGetWidth(VTERM);
  1140.                 int ys = VscrnGetHeight(VTERM)-(tt_status[VTERM]?1:0);
  1141.                 vtattrib vta = {0,0,0,0,0,1,0,0,0,0,0}; /* Protected */
  1142.                 debug(F110,"Wyse Escape","Clear screen to Protected SP; Protect Off; Home Cursor",0);
  1143.                 if ( debses )
  1144.                     break;
  1145.                 clrscreen( VTERM, SP ) ;
  1146.                 lgotoxy(VTERM,1,1);       /* and home the cursor */
  1147.                 for ( y = 0 ; y < ys ; y++ )
  1148.                     for ( x = 0 ; x < xs ; x++ )
  1149.                         VscrnSetVtCharAttr( VTERM, x, y, vta ) ;
  1150.                 protect = FALSE ;
  1151.                 writeprotect = FALSE ;
  1152.                 insertmode = FALSE ;
  1153.                 break;
  1154.             }
  1155.             case '-': {
  1156.                 /* Moves the cursor to a specified text segment. */
  1157.                 /* This has a multiple code sequence of:         */
  1158.                 /* ESC - nrc                                     */
  1159.                 /* where n = the text segment number, 0 or 1     */
  1160.                 /*       r = the row code                        */
  1161.                 /*       c = the column code                     */
  1162.                 int n,r,c ;
  1163.                 debug(F110,"Wyse Escape","Move cursor to text segment",0);
  1164.                 n = wyinc();
  1165.  
  1166.                 r = wyinc();
  1167.  
  1168.                 c = wyinc();
  1169.  
  1170.                 if ( debses )
  1171.                     break;
  1172.                 if ( n == WY_FIELD_APPL )
  1173.                     lgotoxy(VTERM,c-31,r-31);
  1174.                 break;
  1175.             }
  1176.             case '.': {
  1177.                 /* Clears all unprotected character positions with    */
  1178.                 /* a specified character code.  This has a format of: */
  1179.                 /*   ESC . CODE where CODE = the character hex value  */
  1180.                 /* Use protected characters if write-protect mode is on */
  1181.                 int xs = VscrnGetWidth(VTERM);
  1182.                 int ys = VscrnGetHeight(VTERM)-(tt_status[VTERM]?1:0);
  1183.                 vtattrib vta = {0,0,0,0,0,1,0,0,0,0,0}; /* Protected */
  1184.                 int C1, C2, C ;
  1185.                 debug(F110,"Wyse Escape","Clear unprotected chars with code",0);
  1186.                 C1 = wyinc() ;
  1187.                 C2 = wyinc() ;
  1188.  
  1189.                 if ( debses )
  1190.                     break;
  1191.                 C = unhex(C1) * 16 + unhex(C2) ;
  1192.                 if ( protect )
  1193.                     selclrscreen(VTERM, C) ;
  1194.                 else
  1195.                     clrscreen( VTERM, C ) ;
  1196.                 lgotoxy(VTERM,1,1);       /* and home the cursor */
  1197.                 if ( writeprotect ) {
  1198.                     for ( y = 0 ; y < ys ; y++ )
  1199.                         for ( x = 0 ; x < xs ; x++ ) {
  1200.                             vta = VscrnGetVtCharAttr( VTERM, x, y ) ;
  1201.                             vta.unerasable = TRUE ;
  1202.                             VscrnSetVtCharAttr( VTERM, x, y, vta ) ;
  1203.                         }
  1204.                 }
  1205.                 protect = FALSE ;
  1206.                 break;
  1207.             }
  1208.             case '/': {
  1209.                 /* Transmits the active text segment number and cursor */
  1210.                 /* address. */
  1211.                 char buf[5] ;
  1212.  
  1213.                 debug(F110,"Wyse Escape","Request Active Text Segment and Cursor Position",0);
  1214.                 if ( debses )
  1215.                     break;
  1216.  
  1217.                 buf[0] = 0;
  1218.                 buf[1] = wherey[VTERM]+31 ;
  1219.                 buf[2] = wherex[VTERM]+31 ;
  1220.                 buf[3] = CR ;
  1221.                 buf[4] = NUL ;
  1222.  
  1223.                 sendchars( buf, 4 ) ;
  1224.                 break;
  1225.             }
  1226.             case '0':
  1227.                 /* Clears all tab settings */
  1228.                 debug(F110,"Wyse Escape","Clear all tab settings",0);
  1229.                 if ( debses )
  1230.                     break;
  1231.                 for (j = 1; j <=MAXTERMCOL; ++j)
  1232.                     htab[j] = '0';
  1233.                 break;
  1234.             case '1':
  1235.                 /* Sets a tab stop */
  1236.                 debug(F110,"Wyse Escape","Set tab stop",0);
  1237.                 if ( debses )
  1238.                     break;
  1239.                 htab[wherex[VTERM]] = 'T';
  1240.                 break;
  1241.             case '2':
  1242.                 /* Clears a tab stop */
  1243.                 debug(F110,"Wyse Escape","Clear tab stop",0);
  1244.                 if ( debses )
  1245.                     break;
  1246.                 htab[wherex[VTERM]] = '0';
  1247.                 break;
  1248.             case '3':
  1249.                 /* Clears all tab stops - WY30 */
  1250.                 debug(F110,"Wyse Escape","Clear all tab stops",0);
  1251.                 if ( debses )
  1252.                     break;
  1253.                 for (j = 1; j <=MAXTERMCOL; ++j)
  1254.                     htab[j] = '0';
  1255.                 break;
  1256.             case '4': {
  1257.                 /* Sends all unprotected characters from the start-of-row */
  1258.                 /* to the host computer. */
  1259.                 int x, fs=1 ;
  1260.  
  1261.                 debug(F110,"Wyse Escape","Send all unprotected chars from BOL",0);
  1262.                 if ( debses )
  1263.                     break;
  1264.  
  1265.                 for ( x=0;x<=wherex[VTERM]-1;x++ ) {
  1266.                     if ( !VscrnGetVtCharAttr(VTERM, x, wherey[VTERM]-1).unerasable ) {
  1267.                         int ch = VscrnGetCell( VTERM, x, wherey[VTERM]-1 )->c ;
  1268.                         if ( ch || !wy_nullsuppress ) {
  1269.                             if ( tt_senddata ) {
  1270.                                 unsigned char * bytes;
  1271.                                 int nbytes;
  1272.                                 if ( isunicode() )
  1273.                                     nbytes = utorxlat(ch,&bytes);
  1274.                                 else
  1275.                                     nbytes = utorxlat(ch,&bytes);
  1276.                                 while ( nbytes-- > 0 )
  1277.                                     sendchar(*bytes++) ;
  1278.                             } else
  1279.                                 sendchar(SP);
  1280.                         }
  1281.                         fs = 0 ;
  1282.                     }
  1283.                     else if ( !fs ) {
  1284.                         sendchar(XFS);
  1285.                         fs = 1 ;
  1286.                     }
  1287.                 }
  1288.                 switch ( wy_blockend ) {
  1289.                 case EOB_CRLF_ETX:
  1290.                     sendchar(ETX);
  1291.                     break;
  1292.                 case EOB_US_CR:
  1293.                     sendchar(CR);
  1294.                     break;
  1295.                 }
  1296.                 break;
  1297.             }
  1298.             case '5': {
  1299.                 /* Sends all unprotected characters from the start-of-text */
  1300.                 /* to the host computer */
  1301.                 int x,y,fs=1 ;
  1302.  
  1303.                 debug(F110,"Wyse Escape","Send all unprotected chars from BOS",0);
  1304.                 if ( debses )
  1305.                     break;
  1306.  
  1307.                 for ( y=0;y<=wherey[VTERM]-1; y++ ) {
  1308.                     int xe;
  1309.                     if (y == wherey[VTERM]-1)
  1310.                         xe = wherex[VTERM]-1;
  1311.                     else
  1312.                         xe = VscrnGetWidth(VTERM)-1;
  1313.                     for ( x=0;x<=xe;x++ )
  1314.                         if ( !VscrnGetVtCharAttr(VTERM, x, y).unerasable ) {
  1315.                             int ch = VscrnGetCell( VTERM, x, y )->c ;
  1316.                             if ( ch || !wy_nullsuppress ) {
  1317.                                 if ( tt_senddata ) {
  1318.                                     unsigned char * bytes;
  1319.                                     int nbytes;
  1320.                                     if ( isunicode() )
  1321.                                         nbytes = utorxlat(ch,&bytes);
  1322.                                     else
  1323.                                         nbytes = utorxlat(ch,&bytes);
  1324.                                     while ( nbytes-- > 0 )
  1325.                                         sendchar(*bytes++) ;
  1326.                                 } else
  1327.                                     sendchar(SP);
  1328.                             }
  1329.                             fs = 0 ;
  1330.                         }
  1331.                         else if ( !fs ) {
  1332.                             sendchar(XFS);
  1333.                             fs = 1 ;
  1334.                         }
  1335.                     if ( y < wherey[VTERM]-1 ) {
  1336.                         switch ( wy_blockend ) {
  1337.                         case EOB_CRLF_ETX:
  1338.                             sendchar(CR);
  1339.                             sendchar(LF);
  1340.                             break;
  1341.                         case EOB_US_CR:
  1342.                             sendchar(US);
  1343.                             break;
  1344.                         }
  1345.                     }
  1346.                 }
  1347.                 switch ( wy_blockend ) {
  1348.                 case EOB_CRLF_ETX:
  1349.                     sendchar(ETX);
  1350.                     break;
  1351.                 case EOB_US_CR:
  1352.                     sendchar(CR);
  1353.                     break;
  1354.                 }
  1355.                 break;
  1356.             }
  1357.             case '6': {
  1358.                 /* Sends all characters from the start-of-row to the host */
  1359.                 /* computer */
  1360.                 int x, fs=0, ch=0 ;
  1361.  
  1362.                 debug(F110,"Wyse Escape","Send all chars from BOL",0);
  1363.                 if ( debses )
  1364.                     break;
  1365.  
  1366.                 for ( x=0;x<=wherex[VTERM];x++ ) {
  1367.                     if ( !VscrnGetVtCharAttr(VTERM, x, wherey[VTERM]-1).unerasable ) {
  1368.                         if ( fs ) {
  1369.                             sendchars("\x1b(",2);
  1370.                             fs = 0;
  1371.                         }
  1372.                     }
  1373.                     else if ( !fs ) {
  1374.                         sendchars("\x1b)",2);
  1375.                         fs = 1 ;
  1376.                     }
  1377.                     ch = VscrnGetCell( VTERM, x, wherey[VTERM]-1 )->c ;
  1378.                     if ( ch  || !wy_nullsuppress ) {
  1379.                         if ( tt_senddata ) {
  1380.                             unsigned char * bytes;
  1381.                             int nbytes;
  1382.                             if ( isunicode() )
  1383.                                 nbytes = utorxlat(ch,&bytes);
  1384.                             else
  1385.                                 nbytes = utorxlat(ch,&bytes);
  1386.                             while ( nbytes-- > 0 )
  1387.                                 sendchar(*bytes++) ;
  1388.                         } else
  1389.                             sendchar(SP);
  1390.                     }
  1391.                 }
  1392.                 switch ( wy_blockend ) {
  1393.                 case EOB_CRLF_ETX:
  1394.                     sendchar(ETX);
  1395.                     break;
  1396.                 case EOB_US_CR:
  1397.                     sendchar(CR);
  1398.                     break;
  1399.                 }
  1400.                 break;
  1401.             }
  1402.             case '7': {
  1403.                 /* Sends all characters from the start-of-text to the host */
  1404.                 /* computer */
  1405.                 int x,y,fs=0,ch=0;
  1406.  
  1407.                 debug(F110,"Wyse Escape","Send all chars from BOS",0);
  1408.                 if ( debses )
  1409.                     break;
  1410.  
  1411.                 for ( y=0;y<=wherey[VTERM]-1; y++ ) {
  1412.                     int xe;
  1413.                     if (y == wherey[VTERM]-1)
  1414.                         xe = wherex[VTERM]-1;
  1415.                     else
  1416.                         xe = VscrnGetWidth(VTERM)-1;
  1417.                     for ( x=0;x<=xe;x++ ) {
  1418.                         if ( !VscrnGetVtCharAttr(VTERM, x, y).unerasable ) {
  1419.                             if ( fs ) {
  1420.                                 sendchars("\x1b(",2);
  1421.                                 fs = 0;
  1422.                             }
  1423.                         }
  1424.                         else if ( !fs ) {
  1425.                             sendchars("\x1b)",2);
  1426.                             fs = 1 ;
  1427.                         }
  1428.                         ch = VscrnGetCell( VTERM, x, y )->c;
  1429.                         if ( ch || !wy_nullsuppress ) {
  1430.                             if ( tt_senddata ) {
  1431.                                 unsigned char * bytes;
  1432.                                 int nbytes;
  1433.                                 if ( isunicode() )
  1434.                                     nbytes = utorxlat(ch,&bytes);
  1435.                                 else
  1436.                                     nbytes = utorxlat(ch,&bytes);
  1437.                                 while ( nbytes-- > 0 )
  1438.                                     sendchar(*bytes++) ;
  1439.                             } else
  1440.                                 sendchar(SP);
  1441.                         }
  1442.                     }
  1443.                     if ( y < wherey[VTERM]-1 ) {
  1444.                         switch ( wy_blockend ) {
  1445.                         case EOB_CRLF_ETX:
  1446.                             sendchar(CR);
  1447.                             sendchar(LF);
  1448.                             break;
  1449.                         case EOB_US_CR:
  1450.                             sendchar(US);
  1451.                             break;
  1452.                         }
  1453.                     }
  1454.                 }
  1455.                 switch ( wy_blockend ) {
  1456.                 case EOB_CRLF_ETX:
  1457.                     sendchar(ETX);
  1458.                     break;
  1459.                 case EOB_US_CR:
  1460.                     sendchar(CR);
  1461.                     break;
  1462.                 }
  1463.                 break;
  1464.             }
  1465.             case '8':
  1466.                 /* Enters a start-of-message character (STX) */
  1467.                 debug(F110,"Wyse Escape","Enter Start of message Char",0);
  1468.                 if ( debses )
  1469.                     break;
  1470.                 wrtch(STX);
  1471.                 break;
  1472.             case '9':
  1473.                 /* Enters an end-of-message character (ETX) */
  1474.                 debug(F110,"Wyse Escape","Enter End of message Char",0);
  1475.                 if ( debses )
  1476.                     break;
  1477.                 wrtch(ETX);
  1478.                 break;
  1479.             case ':':
  1480.                 /* Clears all unprotected characters to nulls */
  1481.                 /* Home Cursor */
  1482.                 debug(F110,"Wyse Escape","Clear all unprotected chars to NUL; Home Cursor",0);
  1483.                 if ( debses )
  1484.                     break;
  1485.                 if ( protect )
  1486.                     selclrscreen(VTERM,NUL);
  1487.                 else
  1488.                     clrscreen( VTERM, NUL ) ;
  1489.                 lgotoxy(VTERM,1,1);
  1490.                 break;
  1491.             case ';':
  1492.                 /* Clears all unprotected characters to spaces */
  1493.                 /* Home Cursor */
  1494.                 debug(F110,"Wyse Escape","Clear all unprotected chars to SP; Home Cursor",0);
  1495.                 if ( debses )
  1496.                     break;
  1497.                 if ( protect )
  1498.                     selclrscreen(VTERM,SP);
  1499.                 else
  1500.                     clrscreen( VTERM, SP );
  1501.                 lgotoxy(VTERM,1,1);
  1502.                 break;
  1503.             case '<':
  1504.                 /* Turn off keyclick - WY30 */
  1505.                 debug(F110,"Wyse Escape","keyclick Off",0);
  1506.                 if ( debses )
  1507.                     break;
  1508.                 if ( wy_enhanced )
  1509.                     setkeyclick(FALSE);
  1510.                 break;
  1511.             case '=': {
  1512.                 /* Moves the cursor to a specified row and column for */
  1513.                 /* an 80-column screen.  This has a format of:        */
  1514.                 /*    ESC = rc where                                  */
  1515.                 /* r = the row code; and c = the column code          */
  1516.                 int r,c ;
  1517.  
  1518.                 debug(F110,"Wyse Escape","Move cursor to row and column (80)",0);
  1519.                 r = wyinc() ;
  1520.  
  1521.                 if ( r < SP ) {
  1522.                     escstate = ES_NORMAL ;
  1523.                     wyseascii(r) ;
  1524.                     return ;
  1525.                 }
  1526.                 c = wyinc() ;
  1527.  
  1528.                 if ( c < SP ) {
  1529.                     escstate = ES_NORMAL ;
  1530.                     wyseascii(c) ;
  1531.                     return ;
  1532.                 }
  1533.                 if ( debses )
  1534.                     break;
  1535.                 if ( /* VscrnGetWidth(VTERM) == 80 && */ c > 31 && r > 31 )
  1536.                      lgotoxy(VTERM,c-31,r-31);
  1537.                 else {
  1538.                         break;
  1539.                 }
  1540.                 break;
  1541.             }
  1542.             case '>':
  1543.                 /* Turn on keyclick - WY30 */
  1544.                 debug(F110,"Wyse Escape","keyclick on ",0);
  1545.                 if ( debses )
  1546.                     break;
  1547.                 if ( wy_enhanced )
  1548.                     setkeyclick(TRUE);
  1549.                 break;
  1550.             case '?':
  1551.                 /* Transmits the cursor address for the active text    */
  1552.                 /* segment of an 80-column screen only.  The format is */
  1553.                 /*    rc CR where r = the row code; and c = the column */
  1554.                 /* code.                                               */
  1555.                 debug(F110,"Wyse Escape","Request Cursor Position (80)",0);
  1556.                 if ( debses )
  1557.                     break;
  1558.                 if ( 1 /* VscrnGetWidth(VTERM) == 80 */ ) {
  1559.                     char buf[4] ;
  1560.                     buf[0] = (char)(wherey[VTERM]+31) ;
  1561.                     buf[1] = (char)(wherex[VTERM]+31) ;
  1562.                     buf[2] = CR ;
  1563.                     buf[3] = NUL ;
  1564.                     sendchars(buf,3) ;
  1565.                 }
  1566.                 break;
  1567.             case '@':
  1568.                 /* Sends all unprotected characters from the start-of-text */
  1569.                 /* to the auxiliary port.  Each row is terminated with:    */
  1570.                 /*   CR LF NULL                                            */
  1571.                 debug(F110,"Wyse Escape","Send all unprotected chars from BOS to AUX",0);
  1572.                 break;
  1573.             case 'A': {
  1574.                 /* Sets a video attribute for a specific message field or  */
  1575.                 /* the entire application display area.  This has a        */
  1576.                 /* multiple code sequence of ESC A n ATTR where:           */
  1577.                 /*   n = field code; ATTR = attribute code                 */
  1578.                 int field = wyinc() ;
  1579.                 int n = wyinc();
  1580.  
  1581.                 debug(F110,"Wyse Escape",
  1582.                        "Set attribute for message field or entire display",0);
  1583.                 if ( debses )
  1584.                     break;
  1585.                 if ( n == SP ) {
  1586.                     if ( field == WY_FIELD_APPL ) {
  1587.                         wrtch(tt_sac);
  1588.                     }
  1589.                 }
  1590.                 else {
  1591.                     attr = wysecharattr( n ) ;
  1592.                     if ( field == WY_FIELD_APPL ) {
  1593.                         if ( attrmode == ATTR_PAGE_MODE ) {
  1594.                             int x = wherex[VTERM];
  1595.                             int y = wherey[VTERM];
  1596.                             if ( !tt_hidattr )
  1597.                                 wrtch(tt_sac) ;
  1598.                             ApplyPageAttribute( VTERM, x, y, attr ) ;
  1599.                         }
  1600.                         else if ( attrmode == ATTR_LINE_MODE ) {
  1601.                             int x = wherex[VTERM];
  1602.                             int y = wherey[VTERM];
  1603.                             if ( !tt_hidattr )
  1604.                                 wrtch(tt_sac) ;
  1605.                             ApplyLineAttribute( VTERM, x, y, attr ) ;
  1606.                         }
  1607.                         /* set attribute for additional chars */
  1608.                         attrib = attr ;
  1609.                     }
  1610.                 }
  1611.                 break;
  1612.             }
  1613.             case 'B':
  1614.                 /* Places the terminal in the block mode.                  */
  1615.                 debug(F110,"Wyse Escape","Enter Block Mode",0);
  1616.                 if ( debses )
  1617.                     break;
  1618.                 wy_block = TRUE;
  1619.                 break;
  1620.             case 'C':
  1621.                 /* Places ther terminal in a conversational mode           */
  1622.                 debug(F110,"Wyse Escape","Enter Conversational Mode",0);
  1623.                 if ( debses )
  1624.                     break;
  1625.                 wy_block = FALSE;
  1626.                 break;
  1627.             case 'D': {
  1628.                 /* Selects the full duplex or half-duplex conversation   */
  1629.                 /* modes.  This has the multiple code sequence:          */
  1630.                 /*   ESC D x where x = F full duplex mode; H half duplex */
  1631.                 int n = wyinc();
  1632.  
  1633.                 if ( debses )
  1634.                     break;
  1635.                 switch ( n ) {
  1636.                 case 'F':
  1637.                     debug(F110,"Wyse Escape","Full Duplex Mode",0);
  1638.                     if ( duplex_sav < 0 )
  1639.                         duplex_sav = duplex ;
  1640.                     duplex = FALSE ;
  1641.                     break;
  1642.                 case 'H':
  1643.                     debug(F110,"Wyse Escape","Half Duplex Mode",0);
  1644.                     if ( duplex_sav < 0 )
  1645.                         duplex_sav = duplex ;
  1646.                     duplex = TRUE ;
  1647.                     break;
  1648.                 }
  1649.                 break;
  1650.             }
  1651.             case 'E':
  1652.                 /* Inserts a row of spaces */
  1653.                 debug(F110,"Wyse Escape","Insert row of spaces",0);
  1654.                 if ( debses )
  1655.                     break;
  1656.                 if ( !protect )
  1657.                     VscrnScroll(VTERM, DOWNWARD, wherey[VTERM] - 1,
  1658.                                  marginbot - 1, 1, FALSE, SP);
  1659.                 break;
  1660.             case 'F': {
  1661.                 /* Enters a message in the host message field.  This has     */
  1662.                 /* a format of:  ESC F aaaa CR where                         */
  1663.                 /*    aaaa = a character string of up to 46 characters       */
  1664.                 /*           for an 80-column screen or up to 100            */
  1665.                 /*           characters for a 132-column screen              */
  1666.                 /* This is also known as the Title Bar.  So set window title */
  1667.                 char buf[102] = "" ;
  1668.                 int  n = 0 ;
  1669.  
  1670.                 debug(F110,"Wyse Escape","Enter message into message field",0);
  1671.  
  1672.                 for ( ; n < ((VscrnGetWidth(VTERM)<=80)?46:100); n++ )
  1673.                 {
  1674.                     buf[n] = wyinc();
  1675.                     if ( buf[n] == CR )
  1676.                         break;
  1677.                 }
  1678.                 buf[n] = '\0';
  1679.  
  1680.                 if ( debses )
  1681.                     break;
  1682.                 /* assign buf to host message field */
  1683.                 os2settitle(buf,1);
  1684.                 break;
  1685.             }
  1686.             case 'G': {
  1687.                 /* Sets a video attribute within the application display  */
  1688.                 /* area.  The attribute occupies a space.  This has a     */
  1689.                 /* multiple code sequence of:   ESC G ATTR where:         */
  1690.                 /*    ATTR = attribute code.                              */
  1691.                 int n = wyinc() ;
  1692.  
  1693.                 debug(F110,"Wyse Escape","Set attribute within display area",0);
  1694.                 if ( debses )
  1695.                     break;
  1696.                 switch ( n ) {
  1697.                 case SP:
  1698.                     if ( tt_hidattr ) {
  1699.                         n = '0';        /* Same as normal */
  1700.                     }
  1701.                     else {
  1702.                         wrtch(tt_sac) ;
  1703.                         break;
  1704.                     }
  1705.                 case '0':
  1706.                 case '1':
  1707.                 case '2':
  1708.                 case '3':
  1709.                 case '4':
  1710.                 case '5':
  1711.                 case '6':
  1712.                 case '7':
  1713.                 case '8':
  1714.                 case '9':
  1715.                 case ':':
  1716.                 case ';':
  1717.                 case '<':
  1718.                 case '=':
  1719.                 case '>':
  1720.                 case '?':
  1721.                 case 'p':
  1722.                 case 'q':
  1723.                 case 'r':
  1724.                 case 's':
  1725.                 case 't':
  1726.                 case 'u':
  1727.                 case 'v':
  1728.                 case 'w':
  1729.                 case 'x':
  1730.                 case 'y':
  1731.                 case 'z':
  1732.                 case '{':
  1733.                 case '|':
  1734.                 case '}':
  1735.                 case '~':{
  1736.                     attr = wysecharattr( n ) ;
  1737.                     if ( attrmode == ATTR_PAGE_MODE ) {
  1738.                         int x = wherex[VTERM];
  1739.                         int y = wherey[VTERM];
  1740.                         if ( !tt_hidattr )
  1741.                             wrtch(tt_sac) ;
  1742.                         ApplyPageAttribute( VTERM, x, y, attr ) ;
  1743.                     }
  1744.                     else if ( attrmode == ATTR_LINE_MODE ) {
  1745.                         int x = wherex[VTERM];
  1746.                         int y = wherey[VTERM];
  1747.                         if ( !tt_hidattr )
  1748.                             wrtch(tt_sac) ;
  1749.                         ApplyLineAttribute( VTERM, x, y, attr ) ;
  1750.                     }
  1751.                     attrib = attr ;
  1752.                     break;
  1753.                 }
  1754.                 case '@':
  1755.                 case 'A':
  1756.                 case 'B':
  1757.                 case 'C':
  1758.                 case 'D':
  1759.                 case 'E': {
  1760.                     wyselineattr( n ) ;
  1761.                     if ( !tt_hidattr &&
  1762.                          (attrmode == ATTR_PAGE_MODE ||
  1763.                            attrmode == ATTR_LINE_MODE) )
  1764.                         wrtch(tt_sac) ;
  1765.                     break;
  1766.                 }
  1767.                 case 'G':
  1768.                 case 'H':
  1769.                 case 'I':
  1770.                 case 'J': {
  1771.                     wyselinebg( n ) ;
  1772.                     if ( !tt_hidattr &&
  1773.                          (attrmode == ATTR_PAGE_MODE ||
  1774.                            attrmode == ATTR_LINE_MODE) )
  1775.                         wrtch(tt_sac) ;
  1776.                     break;
  1777.                 }
  1778.                 }
  1779.                 break;
  1780.             }
  1781.             case 'H': {
  1782.                 /* Enters a graphic character at the cursor locations.    */
  1783.                 /* This has a multiple code sequence of ESC H x where     */
  1784.                 /*    x = the graphic character code                      */
  1785.                 /* ESC H STX (CTRL B) turns on the graphic submode        */
  1786.                 /* ESC H ETX (CTRL C) turns off the graphic submode       */
  1787.                 int x = wyinc(), gch = NUL ;
  1788.  
  1789.                 switch ( x ) {
  1790.                 case 2:
  1791.                     debug(F110,"Wyse Escape","Graphic Chars On",0);
  1792.                     if ( debses )
  1793.                         break;
  1794.                     wysegraphics = TRUE ;
  1795.                     break;
  1796.                 case 3:
  1797.                     debug(F110,"Wyse Escape","Graphic Chars Off",0);
  1798.                     if ( debses )
  1799.                         break;
  1800.                     wysegraphics = FALSE ;
  1801.                     break;
  1802.                 default:
  1803.                     debug(F110,"Wyse Escape","Enter Graphic Char",0);
  1804.                     if ( debses )
  1805.                         break;
  1806.                     gch = xlwygrph(x);
  1807.                     if ( gch )
  1808.                         wrtch( gch ) ;
  1809.                     else {
  1810.                         escstate = ES_NORMAL ;
  1811.                         wyseascii(x);
  1812.                         return ;
  1813.                     }
  1814.                 }
  1815.                 break;
  1816.             }
  1817.             case 'I':
  1818.                 /* Moves the cursor left to the previous tab stop */
  1819.                 debug(F110,"Wyse Escape","Reverse tab",0);
  1820.                 if ( debses )
  1821.                     break;
  1822.                 wyse_backtab();
  1823.                 break;
  1824.             case 'J':
  1825.                 /* Activates the alternate text segment */
  1826.                 debug(F110,"Wyse Escape","Activate alternate text segment",0);
  1827.                 break;
  1828.             case 'K':
  1829.                 /* Activates the alternate text segment.  Same as ESC J */
  1830.                 debug(F110,"Wyse Escape","Activate alternate text segment",0);
  1831.                 break;
  1832.             case 'L':
  1833.                 /* Sends all characters unformatted to the auxiliary port. */
  1834.                 /* Attribute codes are sent as spaces.  Row-end            */
  1835.                 /* sequences are not sent.  Same as ESC p.                 */
  1836.                 debug(F110,"Wyse Escape","Send all chars unformatted to AUX ",0);
  1837.                 break;
  1838.             case 'M':
  1839.                 /* Cause the terminal to send the character at the cursor  */
  1840.                 /* position to the host computer.                          */
  1841.                 debug(F110,"Wyse Escape","Send current char to host",0);
  1842.                 if ( debses )
  1843.                     break;
  1844.                 if ( tt_senddata ) {
  1845.                     unsigned char * bytes;
  1846.                     int nbytes;
  1847.                     unsigned short ch = VscrnGetCell( VTERM, wherex[VTERM]-1,
  1848.                                        wherey[VTERM]-1 )->c;
  1849.                     if ( isunicode() )
  1850.                         nbytes = utorxlat(ch,&bytes);
  1851.                     else
  1852.                         nbytes = utorxlat(ch,&bytes);
  1853.                     while ( nbytes-- > 0 )
  1854.                         sendchar(*bytes++) ;
  1855.                 } else
  1856.                     sendchar(SP);
  1857.                 break;
  1858.             case 'N':
  1859.                 /* turns the no scroll submode on */
  1860.                 debug(F110,"Wyse Escape","No Scroll on",0);
  1861.                 if ( debses )
  1862.                     break;
  1863.                 autoscroll = FALSE ;
  1864.                 break;
  1865.             case 'O':
  1866.                 /* Turns the no scroll submode off */
  1867.                 debug(F110,"Wyse Escape","No Scroll off",0);
  1868.                 if ( debses )
  1869.                     break;
  1870.                 autoscroll = TRUE ;
  1871.                 break;
  1872.             case 'P': {
  1873.                 /* Sends all protected and unprotected characters to the  */
  1874.                 /* auxiliary port, regardless of the mode setting.        */
  1875.                 int x;
  1876.  
  1877.                 debug(F110,"Wyse Escape","Send all chars to AUX",0);
  1878.                 if ( debses )
  1879.                     break;
  1880.  
  1881.                 x = xprintff; xprintff = 0; /*   Print/Dump current screen */
  1882.                 prtscreen(VTERM,1,VscrnGetHeight(VTERM)-(tt_status[VTERM]?1:0));
  1883.                 xprintff = x;
  1884.                 if ( wy_enhanced )
  1885.                     ttoc(ACK);
  1886.                 break;
  1887.             }
  1888.             case 'Q':
  1889.                 /* Inserts a space. */
  1890.                 debug(F110,"Wyse Escape","Insert SP",0);
  1891.                 if ( debses )
  1892.                     break;
  1893.                 blankvcell.c = SP;
  1894.                 blankvcell.a = geterasecolor(VTERM);
  1895.                 VscrnScrollRt(VTERM, wherey[VTERM] - 1,
  1896.                                wherex[VTERM] - 1, wherey[VTERM] - 1,
  1897.                                VscrnGetWidth(VTERM) - 1, 1, blankvcell);
  1898.                 break;
  1899.             case 'R':
  1900.                 /* Deletes a row. */
  1901.                 debug(F110,"Wyse Escape","Delete a row",0);
  1902.                 if ( debses )
  1903.                     break;
  1904.                 VscrnScroll(VTERM,
  1905.                              UPWARD,
  1906.                              wherey[VTERM] - 1,
  1907.                              marginbot - 1,
  1908.                              1,
  1909.                              FALSE,
  1910.                              SP);
  1911.                 break;
  1912.             case 'S': {
  1913.                 /* Sends a message unprotected */
  1914.                 int x,y,ch,
  1915.                 w=VscrnGetWidth(VTERM),
  1916.                 h=VscrnGetHeight(VTERM)-(tt_status[VTERM]?1:0),
  1917.                 xs=-1,
  1918.                 ys=-1,
  1919.                 xe=w-1,
  1920.                 ye=h-1,
  1921.                 fs=1 ;
  1922.  
  1923.                 debug(F110,"Wyse Escape","Send a message unprotected",0);
  1924.                 if ( debses )
  1925.                     break;
  1926.  
  1927.                 /* First figure out if we have markers, STX then ETX */
  1928.                 for ( y=0;y<h;y++ )
  1929.                     for ( x=0;x<w;x++ ) {
  1930.                         ch = VscrnGetCell( VTERM, x, y )->c ;
  1931.                         if ( ch == STX && xs < 0 && ys < 0 ) {
  1932.                             xs = x+1 ;
  1933.                             ys = y ;
  1934.                         }
  1935.                         else if ( ch == ETX && xs >= 0 && ys >= 0 ) {
  1936.                             xe = x-1 ;
  1937.                             ye = y ;
  1938.                             break;
  1939.                         }
  1940.                     }
  1941.                 if ( xs < 0 || ys < 0 ) {
  1942.                     xs = 0 ;
  1943.                     ys = 0 ;
  1944.                 }
  1945.  
  1946.                 /* Now send the data */
  1947.                 for ( y=ys;y<=ye; y++ ) {
  1948.                     for ( x=(y==ys)?xs:0 ; x <= (y==ye?xe:w-1) ; x++ )
  1949.                         if ( !VscrnGetVtCharAttr(VTERM, x, y).unerasable ) {
  1950.                             ch = VscrnGetCell( VTERM, x, y )->c;
  1951.                             if ( ch || !wy_nullsuppress ) {
  1952.                                 if ( tt_senddata ) {
  1953.                                     unsigned char * bytes;
  1954.                                     int nbytes;
  1955.                                     if ( isunicode() )
  1956.                                         nbytes = utorxlat(ch,&bytes);
  1957.                                     else
  1958.                                         nbytes = utorxlat(ch,&bytes);
  1959.                                     while ( nbytes-- > 0 )
  1960.                                         sendchar(*bytes++) ;
  1961.                                 } else
  1962.                                     sendchar(SP);
  1963.                             }
  1964.                             fs = 0 ;
  1965.                         }
  1966.                         else if ( !fs ) {
  1967.                             sendchar(XFS);
  1968.                             fs = 1 ;
  1969.                         }
  1970.                     if ( y < ye ) {
  1971.                         switch ( wy_blockend ) {
  1972.                         case EOB_CRLF_ETX:
  1973.                             sendchar(CR);
  1974.                             sendchar(LF);
  1975.                             break;
  1976.                         case EOB_US_CR:
  1977.                             sendchar(US);
  1978.                             break;
  1979.                         }
  1980.                     }
  1981.                 }
  1982.                 switch ( wy_blockend ) {
  1983.                 case EOB_CRLF_ETX:
  1984.                     sendchar(ETX);
  1985.                     break;
  1986.                 case EOB_US_CR:
  1987.                     sendchar(CR);
  1988.                     break;
  1989.                 }
  1990.                 break;
  1991.             }
  1992.             case 'T':
  1993.                 /* Clear unprotected line to spaces from cursor - WY60 */
  1994.                 debug(F110,"Wyse Escape","Clear unprotected line to space from cursor",0);
  1995.                 if ( debses )
  1996.                     break;
  1997.                 if ( protect )
  1998.                     selclrtoeoln( VTERM, SP ) ;
  1999.                 else
  2000.                     clrtoeoln( VTERM, SP ) ;
  2001.                 break;
  2002.             case 'U':
  2003.                 /* Turns the monitor submode on */
  2004.                 debug(F110,"Wyse Escape","Monitor mode on",0);
  2005.                 if ( debses || wy_monitor )
  2006.                     break;
  2007.                 setdebses(TRUE);
  2008.                 wy_monitor = TRUE ;
  2009.                 break;
  2010.             case 'V':
  2011.                 if ( ISWY60(tt_type_mode) ) {
  2012.                     /* Clear cursor column - wy60 */
  2013.                     viocell cell = {SP,geterasecolor(VTERM)};
  2014.                     int ys = VscrnGetHeight(VTERM)-(tt_status[VTERM]?1:0);
  2015.                     vtattrib vta = attrib;
  2016.  
  2017.                     debug(F110,"Wyse Escape","Clear cursor column",0);
  2018.                     if ( debses )
  2019.                         break;
  2020.  
  2021.                     x  = wherex[VTERM]-1 ;
  2022.                     vta.unerasable = TRUE ;
  2023.                     for ( y=wherey[VTERM]-1 ; y<ys ; y++ )
  2024.                         VscrnWrtCell( VTERM, cell, vta, y, x ) ;
  2025.                     cursorright(0);
  2026.                 }
  2027.                 else {
  2028.                     /* Sets a protected column */
  2029.                     int ys = VscrnGetHeight(VTERM)-(tt_status[VTERM]?1:0);
  2030.                     viocell cell = {SP,geterasecolor(VTERM)};
  2031.                     vtattrib vta ;
  2032.  
  2033.                     debug(F110,"Wyse Escape","Sets a protected column",0);
  2034.                     if ( debses )
  2035.                         break;
  2036.  
  2037.                     x  = wherex[VTERM]-1 ;
  2038.                     for ( y=wherey[VTERM]-1 ; y<ys ; y++ ) {
  2039.                         vta = VscrnGetVtCharAttr( VTERM, x, y ) ;
  2040.                         vta.unerasable = TRUE ;
  2041.                         VscrnWrtCell(VTERM, cell,
  2042.                                       writeprotect ? WPattrib : vta,
  2043.                                       y, x);
  2044.                     }
  2045.                     cursorright(0);
  2046.                 }
  2047.                 break;
  2048.             case 'W': {
  2049.                 /* Deletes a character or attribute */
  2050.                 vtattrib vta;
  2051.                 debug(F110,"Wyse Escape","Deletes a char or attribute",0);
  2052.                 if ( debses )
  2053.                     break;
  2054.                 vta = VscrnGetVtCharAttr( VTERM,
  2055.                                           wherex[VTERM]-1,
  2056.                                           wherey[VTERM]-1 ) ;
  2057.                 blankvcell.c = SP;
  2058.                 blankvcell.a = geterasecolor(VTERM);
  2059.                 VscrnScrollLf(VTERM, wherey[VTERM] - 1,
  2060.                                wherex[VTERM] - 1,
  2061.                                wherey[VTERM] - 1,
  2062.                                VscrnGetWidth(VTERM) - 1,
  2063.                                1, blankvcell) ;
  2064.                 if ( ( attrmode == ATTR_PAGE_MODE ||
  2065.                        attrmode == ATTR_LINE_MODE ) &&
  2066.                      vta.wyseattr == TRUE ) {
  2067.                     /* BUG */
  2068.                     /* If we are in Page or Line modes and the character */
  2069.                     /* being deleted is an Attribute, then we need to    */
  2070.                     /* correct the attributes for characters to the right*/
  2071.                     /* and down. */
  2072.                     vta.wyseattr = FALSE;
  2073.                     VscrnSetVtCharAttr( VTERM, wherex[VTERM]-1, wherey[VTERM]-1, vta );
  2074.  
  2075.                     if ( attrmode == ATTR_LINE_MODE ) {
  2076.                         /* Scan backward to beginning of line to find previous */
  2077.                         /* cell which is an attribute.  Then reapply it.       */
  2078.                         int x;
  2079.                         for ( x=wherex[VTERM]-1 ; x >= 1 ; x-- ) {
  2080.                             vta = VscrnGetVtCharAttr( VTERM, x-1, wherey[VTERM]-1 ) ;
  2081.                             if ( vta.wyseattr ) {
  2082.                                 ApplyLineAttribute( VTERM, x, wherey[VTERM], vta );
  2083.                                 return;
  2084.                             }
  2085.                         }
  2086.                         ApplyLineAttribute( VTERM, 1, wherey[VTERM], vta );
  2087.                     }
  2088.                     else if ( attrmode == ATTR_PAGE_MODE ) {
  2089.                         /* Scan backward to beginning of screen to find previous */
  2090.                         /* cell which is an attribute.  Then reapply it.         */
  2091.                         int x,y;
  2092.                                                 x = wherex[VTERM]-1;
  2093.                         for ( y=wherey[VTERM]-1 ; y >= 1 ; y-- ) {
  2094.                             for ( ; x >= 1 ; x-- ) {
  2095.                                 vta = VscrnGetVtCharAttr( VTERM, x-1, y-1 ) ;
  2096.                                 if ( vta.wyseattr ) {
  2097.                                     ApplyPageAttribute( VTERM, x, y, vta );
  2098.                                     return;
  2099.                                 }
  2100.                             }
  2101.                             x = VscrnGetWidth( VTERM );
  2102.                         }
  2103.                         ApplyPageAttribute( VTERM, 1, 1, vta );
  2104.                     }
  2105.                 }
  2106.                 break;
  2107.             }
  2108.             case 'X':
  2109.                 /* Turns the monitor submode off */
  2110.                 debug(F110,"Wyse Escape","Monitor mode off",0);
  2111.                 if ( !wy_monitor )
  2112.                     break;
  2113.                 setdebses(FALSE);
  2114.                 wy_monitor = FALSE ;
  2115.                 break;
  2116.             case 'Y':
  2117.                 if ( ISWY60(tt_type_mode) ) {
  2118.                     /* clear unprotected page to space characters */
  2119.                     /* from cursor */
  2120.                     debug(F110,"Wyse Escape","Clear unprotected page to SP from cursor",0);
  2121.                     if ( debses )
  2122.                         break;
  2123.                     if ( protect )
  2124.                         selclreoscr_escape( VTERM, SP ) ;
  2125.                     else
  2126.                         clreoscr_escape( VTERM, SP ) ;
  2127.                 }
  2128.                 else {
  2129.                     /* Erases all characters to the end of the active text */
  2130.                     /* segment and replaces them with spaces. */
  2131.                     debug(F110,"Wyse Escape","Clear all chars to end of segment with SP",0);
  2132.                     if ( debses )
  2133.                         break;
  2134.                     clreoscr_escape( VTERM, SP ) ;
  2135.                 }
  2136.                 /* ??? we really need to figure out what the last */
  2137.                 /* assigned attribute was so that we know what    */
  2138.                 /* to assign to these cleared cells               */
  2139.                 break;
  2140.             case 'Z': {
  2141.                 /* ESC Z dir key sequence DEL =            */
  2142.                 /*    Program key direction and definition */
  2143.                 /* ESC Z ~ key =                           */
  2144.                 /*    Read key direction and definition    */
  2145.                 char keydef[256] = "" ;
  2146.                 int dir = wyinc() ;
  2147.                 int key = wyinc() ;
  2148.                 int i=0,j=0 ;
  2149.                 int keyi = -1 ;
  2150.  
  2151.                 if ( dir == '~' ) {
  2152.                     /* Report Key Definition to host */
  2153.                     debug(F110,"Wyse Escape","Report Key Definition to Host",0);
  2154.                     if ( debses )
  2155.                         break;
  2156. #ifndef NOSETKEY
  2157.                     keydef[i++] = '1' ; /* Direction = remote */
  2158.                     keydef[i++] = key ; /* Key */
  2159.                     keydef[i] = NUL;    /* So we can use strcat */
  2160.  
  2161.                     /* actual definition goes here */
  2162.                     if ( key >= '@' && key <= 'O' ) {
  2163.                         keyi = key-'@';
  2164.                     }
  2165. #ifndef NOKVERBS
  2166.                     else if ( key >= '`' && key <= 'o' ) {
  2167.                         keyi = key-'`'+K_WYSF01-K_WYF01 ;
  2168.                     }
  2169.                     else switch (key) {
  2170.                     case '"':   /* Backspace */
  2171.                         keyi = K_WYBS-K_WYF01 ;
  2172.                         break;
  2173.                     case '}':   /* Clear Line */
  2174.                         keyi = K_WYCLRLN-K_WYF01;
  2175.                         break;
  2176.                     case 'z':   /* Shift Clear Line - Clear Screen */
  2177.                         keyi = K_WYSCLRLN-K_WYF01;
  2178.                         break;
  2179.                         /* Clear Page */
  2180.                         /* Shift Clear Page */
  2181.                     case '5':   /* Del Char */
  2182.                         keyi = K_WYDELCHAR-K_WYF01;
  2183.                         break;
  2184.                     case '6':   /* Del Line */
  2185.                         keyi = K_WYDELLN-K_WYF01;
  2186.                         break;
  2187.                     case 's':   /* Enter */
  2188.                         keyi = K_WYENTER-K_WYF01;
  2189.                         break;
  2190.                     case SP:    /* Escape */
  2191.                         keyi = K_WYESC-K_WYF01;
  2192.                         break;
  2193.                     case '*':   /* Home */
  2194.                         keyi = K_WYHOME-K_WYF01;
  2195.                         break;
  2196.                     case '/':   /* Shift Home */
  2197.                         keyi = K_WYSHOME-K_WYF01;
  2198.                         break;
  2199.                     case '8':   /* Shift Replace (Insert) */
  2200.                         keyi = K_WYINSERT-K_WYF01;
  2201.                         break;
  2202.                     case 'q':   /* Insert Char */
  2203.                         keyi = K_WYINSCHAR-K_WYF01;
  2204.                         break;
  2205.                     case 'p':   /* Insert Line */
  2206.                         keyi = K_WYINSLN-K_WYF01;
  2207.                         break;
  2208.                     case 'r':   /* Page Next */
  2209.                         keyi = K_WYPGNEXT-K_WYF01;
  2210.                         break;
  2211.                     case 'w':   /* Page Prev */
  2212.                         keyi = K_WYPGPREV-K_WYF01;
  2213.                         break;
  2214.                     case '7':   /* Replace */
  2215.                         keyi = K_WYREPLACE-K_WYF01;
  2216.                         break;
  2217.                     case '$':   /* Return */
  2218.                         keyi = K_WYRETURN-K_WYF01;
  2219.                         break;
  2220.                     case '!':   /* Tab */
  2221.                         keyi = K_WYTAB-K_WYF01;
  2222.                         break;
  2223.                     case '&':   /* Shift Tab */
  2224.                         keyi = K_WYSTAB-K_WYF01;
  2225.                         break;
  2226.                     case 'R':   /* Print Screen */
  2227.                         keyi = K_WYPRTSCN-K_WYF01;
  2228.                         break;
  2229.                     case '%':   /* Shift Esc */
  2230.                         keyi = K_WYSESC-K_WYF01;
  2231.                         break;
  2232.                     case '\'':  /* Shift Backspace */
  2233.                         keyi = K_WYSBS-K_WYF01;
  2234.                         break;
  2235.                     case '4':   /* Shift Enter */
  2236.                         keyi = K_WYSENTER-K_WYF01;
  2237.                         break;
  2238.                     case ')':   /* Shift Return */
  2239.                         keyi = K_WYSRETURN-K_WYF01;
  2240.                         break;
  2241.                     case '+':   /* Up arrow */
  2242.                         keyi = K_WYUPARR-K_WYF01;
  2243.                         break;
  2244.                     case ',':   /* Dn arrow */
  2245.                         keyi = K_WYDNARR-K_WYF01;
  2246.                         break;
  2247.                     case '-':   /* Left arrow */
  2248.                         keyi = K_WYLFARR-K_WYF01;
  2249.                         break;
  2250.                     case '.':   /* Right arrow */
  2251.                         keyi = K_WYRTARR-K_WYF01;
  2252.                         break;
  2253.                     case '0':   /* Shift Up arrow */
  2254.                         keyi = K_WYSUPARR-K_WYF01;
  2255.                         break;
  2256.                     case '1':   /* Shift Dn arrow */
  2257.                         keyi = K_WYSDNARR-K_WYF01;
  2258.                         break;
  2259.                     case '2':   /* Shift Left arrow */
  2260.                         keyi = K_WYSLFARR-K_WYF01;
  2261.                         break;
  2262.                     case '3':   /* Shift Right arrow */
  2263.                         keyi = K_WYSRTARR-K_WYF01;
  2264.                         break;
  2265.                     case 'u':   /* Send */
  2266.                         keyi = K_WYSEND-K_WYF01;
  2267.                         break;
  2268.                     case 't':   /* Shift Send */
  2269.                         keyi = K_WYSSEND-K_WYF01;
  2270.                         break;
  2271.                     case 'Q':   /* F17 */
  2272.                         keyi = K_WYF17-K_WYF01;
  2273.                         break;
  2274.                     case 'W':   /* Shift F17 */
  2275.                         keyi = K_WYSF17-K_WYF01;
  2276.                         break;
  2277.                     case 'S':   /* F18 */
  2278.                         keyi = K_WYF18-K_WYF01;
  2279.                         break;
  2280.                     case 'Y':   /* Shift F18 */
  2281.                         keyi = K_WYSF18-K_WYF01;
  2282.                         break;
  2283.                     case 'T':   /* F19 */
  2284.                         keyi = K_WYF19-K_WYF01;
  2285.                         break;
  2286.                     case 'Z':   /* Shift F19 */
  2287.                         keyi = K_WYSF19-K_WYF01;
  2288.                         break;
  2289.                     case 'P':   /* F20 */
  2290.                         keyi = K_WYF20-K_WYF01;
  2291.                         break;
  2292.                     case 'V':   /* Shift F20 */
  2293.                         keyi = K_WYSF20-K_WYF01;
  2294.                         break;
  2295.  
  2296.                     case '#':   /* Del */
  2297.                     case '(':   /* Shift Del */
  2298.                     case 'X':   /* Shift Print Screen */
  2299.                     case ':':   /* PgUp */
  2300.                     case ';':   /* Shift PgUp */
  2301.                     case '\\':  /* End */
  2302.                     case ']':   /* Shift End */
  2303.                     default:
  2304.                         debug(F111,"Wyse (ESC Z ~)","key",key);
  2305.                         break;
  2306.                     }
  2307. #endif /* NOKVERBS */
  2308.                     if ( keyi >= 0 ) {
  2309.                         if ( udkfkeys[keyi] != NULL ) {
  2310.                             strcat( keydef, udkfkeys[keyi] );
  2311.                             i += strlen(udkfkeys[keyi]);
  2312.                         }
  2313.                     }
  2314.  
  2315.                     keydef[i++] = DEL ; /* End of report */
  2316.                     keydef[i] = NUL ;   /* For debugging */
  2317.                     sendchars(keydef,i);
  2318. #endif /* NOSETKEY */
  2319.                     break;
  2320.                 }
  2321.                 else {
  2322.                     debug(F110,"Wyse Escape","Assign Key Definition",0);
  2323.                     i = 0 ;
  2324.                     while ( (keydef[i]=wyinc()) != DEL )
  2325.                         i++;
  2326.                     keydef[i] = NUL ;
  2327.  
  2328.                     if ( debses )
  2329.                         break;
  2330.                     if ( key >= '@' && key <= 'O' ) {
  2331.                         keyi = key-'@';
  2332.                     }
  2333. #ifndef NOKVERBS
  2334.                     else if ( key >= '`' && key <= 'o' ) {
  2335.                         keyi = key-'`'+(K_WYSF01-K_WYF01);
  2336.                     }
  2337.                     else switch (key) {
  2338.                     case '"':   /* Backspace */
  2339.                         keyi = K_WYBS-K_WYF01 ;
  2340.                         break;
  2341.                     case '}':   /* Clear Line */
  2342.                         keyi = K_WYCLRLN-K_WYF01;
  2343.                         break;
  2344.                     case 'z':   /* Shift Clear Line - Clear Screen */
  2345.                         keyi = K_WYSCLRLN-K_WYF01;
  2346.                         break;
  2347.                         /* Clear Page */
  2348.                         /* Shift Clear Page */
  2349.                     case '5':   /* Del Char */
  2350.                         keyi = K_WYDELCHAR-K_WYF01;
  2351.                         break;
  2352.                     case '6':   /* Del Line */
  2353.                         keyi = K_WYDELLN-K_WYF01;
  2354.                         break;
  2355.                     case 's':   /* Enter */
  2356.                         keyi = K_WYENTER-K_WYF01;
  2357.                         break;
  2358.                     case SP:    /* Escape */
  2359.                         keyi = K_WYESC-K_WYF01;
  2360.                         break;
  2361.                     case '*':   /* Home */
  2362.                         keyi = K_WYHOME-K_WYF01;
  2363.                         break;
  2364.                     case '/':   /* Shift Home */
  2365.                         keyi = K_WYSHOME-K_WYF01;
  2366.                         break;
  2367.                     case '8':   /* Shift Replace (Insert) */
  2368.                         keyi = K_WYINSERT-K_WYF01;
  2369.                         break;
  2370.                     case 'q':   /* Insert Char */
  2371.                         keyi = K_WYINSCHAR-K_WYF01;
  2372.                         break;
  2373.                     case 'p':   /* Insert Line */
  2374.                         keyi = K_WYINSLN-K_WYF01;
  2375.                         break;
  2376.                     case 'r':   /* Page Next */
  2377.                         keyi = K_WYPGNEXT-K_WYF01;
  2378.                         break;
  2379.                     case 'w':   /* Page Prev */
  2380.                         keyi = K_WYPGPREV-K_WYF01;
  2381.                         break;
  2382.                     case '7':   /* Replace */
  2383.                         keyi = K_WYREPLACE-K_WYF01;
  2384.                         break;
  2385.                     case '$':   /* Return */
  2386.                         keyi = K_WYRETURN-K_WYF01;
  2387.                         break;
  2388.                     case '!':   /* Tab */
  2389.                         keyi = K_WYTAB-K_WYF01;
  2390.                         break;
  2391.                     case '&':   /* Shift Tab */
  2392.                         keyi = K_WYSTAB-K_WYF01;
  2393.                         break;
  2394.                     case 'R':   /* Print Screen */
  2395.                         keyi = K_WYPRTSCN-K_WYF01;
  2396.                         break;
  2397.                     case '%':   /* Shift Esc */
  2398.                         keyi = K_WYSESC-K_WYF01;
  2399.                         break;
  2400.                     case '\'':  /* Shift Backspace */
  2401.                         keyi = K_WYSBS-K_WYF01;
  2402.                         break;
  2403.                     case '4':   /* Shift Enter */
  2404.                         keyi = K_WYSENTER-K_WYF01;
  2405.                         break;
  2406.                     case ')':   /* Shift Return */
  2407.                         keyi = K_WYSRETURN-K_WYF01;
  2408.                         break;
  2409.                     case '+':   /* Up arrow */
  2410.                         keyi = K_WYUPARR-K_WYF01;
  2411.                         break;
  2412.                     case ',':   /* Dn arrow */
  2413.                         keyi = K_WYDNARR-K_WYF01;
  2414.                         break;
  2415.                     case '-':   /* Left arrow */
  2416.                         keyi = K_WYLFARR-K_WYF01;
  2417.                         break;
  2418.                     case '.':   /* Right arrow */
  2419.                         keyi = K_WYRTARR-K_WYF01;
  2420.                         break;
  2421.                     case '0':   /* Shift Up arrow */
  2422.                         keyi = K_WYSUPARR-K_WYF01;
  2423.                         break;
  2424.                     case '1':   /* Shift Dn arrow */
  2425.                         keyi = K_WYSDNARR-K_WYF01;
  2426.                         break;
  2427.                     case '2':   /* Shift Left arrow */
  2428.                         keyi = K_WYSLFARR-K_WYF01;
  2429.                         break;
  2430.                     case '3':   /* Shift Right arrow */
  2431.                         keyi = K_WYSRTARR-K_WYF01;
  2432.                         break;
  2433.                     case 'Q':   /* F17 */
  2434.                         keyi = K_WYF17-K_WYF01;
  2435.                         break;
  2436.                     case 'W':   /* Shift F17 */
  2437.                         keyi = K_WYSF17-K_WYF01;
  2438.                         break;
  2439.                     case 'S':   /* F18 */
  2440.                         keyi = K_WYF18-K_WYF01;
  2441.                         break;
  2442.                     case 'Y':   /* Shift F18 */
  2443.                         keyi = K_WYSF18-K_WYF01;
  2444.                         break;
  2445.                     case 'T':   /* F19 */
  2446.                         keyi = K_WYF19-K_WYF01;
  2447.                         break;
  2448.                     case 'Z':   /* Shift F19 */
  2449.                         keyi = K_WYSF19-K_WYF01;
  2450.                         break;
  2451.                     case 'P':   /* F20 */
  2452.                         keyi = K_WYF20-K_WYF01;
  2453.                         break;
  2454.                     case 'V':   /* Shift F20 */
  2455.                         keyi = K_WYSF20-K_WYF01;
  2456.                         break;
  2457.                     case 'u':   /* Send */
  2458.                         keyi = K_WYSEND-K_WYF01;
  2459.                         break;
  2460.                     case 't':   /* Shift Send */
  2461.                         keyi = K_WYSSEND-K_WYF01;
  2462.                         break;
  2463.  
  2464.                     case '#':   /* Del */
  2465.                     case '(':   /* Shift Del */
  2466.                     case 'X':   /* Shift Print Screen */
  2467.                     case ':':   /* PgUp */
  2468.                     case ';':   /* Shift PgUp */
  2469.                     case '\\':  /* End */
  2470.                     case ']':   /* Shift End */
  2471.                     default:
  2472.                         debug(F111,"Wyse (ESC Z)","unimplemented key",key);
  2473.                         break;
  2474.                     }
  2475. #endif /* NOKVERBS */
  2476. #ifndef NOSETKEY
  2477.                     if ( keyi >= 0 ) {
  2478.                         if ( udkfkeys[keyi] ){
  2479.                             free( udkfkeys[keyi] ) ;
  2480.                             udkfkeys[keyi]=NULL;
  2481.                         }
  2482.                         if ( strlen(keydef) ) {
  2483.                             char buf[80];
  2484.                             udkfkeys[keyi] = strdup( keydef ) ;
  2485.                             sprintf(buf,"Wyse [Define Key]=%d",keyi);
  2486.                             hexdump(buf,keydef,strlen(keydef));
  2487.                         } else {
  2488.                             udkfkeys[keyi] = wysedefkey( keyi );
  2489.                         }
  2490.                     }
  2491. #endif /* NOSETKEY */
  2492.                 }
  2493.                 break;
  2494.             }
  2495.             case '[': {
  2496.                 /* Address cursor to specific row */
  2497.                 int line = wyinc();
  2498.  
  2499.                 debug(F110,"Wyse Escape","Address cursor to row",0);
  2500.                 if ( debses )
  2501.                     break;
  2502.                 lgotoxy(VTERM,wherex[VTERM],line-31);
  2503.                 break;
  2504.             }
  2505.             case '\\':
  2506.                 debug(F110,"Wyse Escape","\\",0);
  2507.                 break;
  2508.             case ']':
  2509.                 /* Activates text segment 0 - Upper Window */
  2510.                 debug(F110,"Wyse Escape","Activate Text Segment 0",0);
  2511.                 break;
  2512.             case '^':
  2513.                 /* ESC ^ 0 - Restore normal screen */
  2514.                 /* ESC ^ 1 - Reverse screen */
  2515.                 {
  2516.                     int n = wyinc() ;
  2517.                     if ( debses )
  2518.                         break;
  2519.                     switch ( n ) {
  2520.                     case '0':
  2521.                         /* Restore normal screen */
  2522.                         debug(F110,"Wyse Escape","Restore Normal screen",0);
  2523.                         if (!decscnm) /* Already normal? */
  2524.                             break;
  2525.                         else {
  2526.                             flipscreen(VTERM);
  2527.                             VscrnIsDirty(VTERM);
  2528.                         }
  2529.                         break;
  2530.                     case '1':
  2531.                         /* Reverse screen */
  2532.                         debug(F110,"Wyse Escape","Reverse screen",0);
  2533.                         if (decscnm) /* Already reverse */
  2534.                             break;
  2535.                         else {
  2536.                             flipscreen(VTERM);
  2537.                             VscrnIsDirty(VTERM) ;
  2538.                         }
  2539.                         break;
  2540.                     }
  2541.                 }
  2542.                 break;
  2543.             case '_': {
  2544.                 /* Address cursor to column */
  2545.                 int col = wyinc() ;
  2546.  
  2547.                 debug(F110,"Wyse Escape","Address cursor to col",0);
  2548.                 if ( debses )
  2549.                     break;
  2550.                 lgotoxy(VTERM,col-31,wherey[VTERM]);
  2551.                 break;
  2552.             }
  2553.             case '`': {
  2554.                 /* Sets the screen features.  This mode has the following */
  2555.                 /* multiple code sequence:  ESC ' n  where:               */
  2556.                 /*   n = screen feature code                              */
  2557.                 int n = wyinc() ;
  2558.                 switch ( n ) {
  2559.                 case '0':
  2560.                     /* Cursor display off */
  2561.                     debug(F110,"Wyse Escape","Cursor display off",0);
  2562.                     if ( debses )
  2563.                         break;
  2564.                     cursorena[VTERM] = FALSE ;
  2565.                     break;
  2566.                 case '1':
  2567.                     /* Cursor display on (default) */
  2568.                     debug(F110,"Wyse Escape","Cursor display on",0);
  2569.                     if ( debses )
  2570.                         break;
  2571.                     cursorena[VTERM] = TRUE ;
  2572.                     break;
  2573.                 case '2':
  2574.                     /* Steady block cursor */
  2575.                     debug(F110,"Wyse Escape","Steady block cursor",0);
  2576.                     if ( debses )
  2577.                         break;
  2578.                     tt_cursor = TTC_BLOCK ;
  2579.                     setcursormode() ;
  2580.                     cursorena[VTERM] = TRUE ;
  2581.                     break;
  2582.                 case '3':
  2583.                     /* Blinking line cursor */
  2584.                     debug(F110,"Wyse Escape","Blinking line cursor",0);
  2585.                     if ( debses )
  2586.                         break;
  2587.                     tt_cursor = TTC_ULINE ;
  2588.                     setcursormode() ;
  2589.                     cursorena[VTERM] = TRUE ;
  2590.                     break;
  2591.                 case '4':
  2592.                     /* Steady line cursor */
  2593.                     debug(F110,"Wyse Escape","Steady line cursor",0);
  2594.                     if ( debses )
  2595.                         break;
  2596.                     tt_cursor = TTC_ULINE ;
  2597.                     setcursormode() ;
  2598.                     cursorena[VTERM] = TRUE ;
  2599.                     break;
  2600.                 case '5':
  2601.                     /* Blinking block cursor (default) */
  2602.                     debug(F110,"Wyse Escape","Blinking block cursor",0);
  2603.                     if ( debses )
  2604.                         break;
  2605.                     tt_cursor = TTC_BLOCK ;
  2606.                     setcursormode() ;
  2607.                     cursorena[VTERM] = TRUE ;
  2608.                     break;
  2609.  
  2610.                     /* These attributes are used only in Write-Protect Mode */
  2611.                 case '6':
  2612.                     /* Reverse protect character */
  2613.                     debug(F110,"Wyse Escape","Write Protect Attribute: Reverse",0);
  2614.                     if ( debses )
  2615.                         break;
  2616.                     WPattrib.blinking = FALSE;          /* No blink */
  2617.                     WPattrib.bold = FALSE;              /* No bold */
  2618.                     WPattrib.invisible = FALSE;         /* Visible */
  2619.                     WPattrib.underlined = FALSE;        /* No underline */
  2620.                     WPattrib.reversed = TRUE;           /* Reverse video */
  2621.                     WPattrib.unerasable = TRUE;         /* Write-Protected */
  2622.                     WPattrib.graphic = FALSE ;          /* Not graphic character */
  2623.                     WPattrib.dim = FALSE ;              /* No dim */
  2624.                     break;
  2625.                 case '7':
  2626.                     /* Dim protect character (default) */
  2627.                     debug(F110,"Wyse Escape","Write Protect Attribute: Dim",0);
  2628.                     if ( debses )
  2629.                         break;
  2630.                     WPattrib.blinking = FALSE;          /* No blink */
  2631.                     WPattrib.bold = FALSE;              /* No bold */
  2632.                     WPattrib.invisible = FALSE;         /* Visible */
  2633.                     WPattrib.underlined = FALSE;        /* No underline */
  2634.                     WPattrib.reversed = FALSE;          /* No reverse video */
  2635.                     WPattrib.unerasable = TRUE;         /* Write-Protected */
  2636.                     WPattrib.graphic = FALSE ;          /* Not graphic character */
  2637.                     WPattrib.dim = TRUE ;               /* Dim */
  2638.                     break;
  2639.                 case 'A':
  2640.                     /* Normal protect character */
  2641.                     debug(F110,"Wyse Escape","Write Protect Attribute: Normal",0);
  2642.                     if ( debses )
  2643.                         break;
  2644.                     WPattrib.blinking = FALSE;          /* No blink */
  2645.                     WPattrib.bold = FALSE;              /* No bold */
  2646.                     WPattrib.invisible = FALSE;         /* Visible */
  2647.                     WPattrib.underlined = FALSE;        /* No underline */
  2648.                     WPattrib.reversed = FALSE;          /* No reverse video */
  2649.                     WPattrib.unerasable = TRUE;         /* Write-Protected */
  2650.                     WPattrib.graphic = FALSE ;          /* Not graphic character */
  2651.                     WPattrib.dim = FALSE ;              /* No dim */
  2652.                     break;
  2653.                 case 'B':
  2654.                     if ( ISWY60(tt_type_mode) ) {
  2655.                         /* Blink on */
  2656.                         debug(F110,"Wyse Escape","Write Protect Attribute: Blink",0);
  2657.                         if ( debses )
  2658.                             break;
  2659.                         WPattrib.blinking = TRUE ;
  2660.                     }
  2661.                     else if ( ISWY30( tt_type_mode ) ) {
  2662.                         /* Reverse and Dim */
  2663.                         debug(F110,"Wyse Escape","Write Protect Attribute: Reverse and Dim",0);
  2664.                         if ( debses )
  2665.                             break;
  2666.                         WPattrib.blinking = FALSE;      /* No blink */
  2667.                         WPattrib.bold = FALSE;          /* No bold */
  2668.                         WPattrib.invisible = FALSE;     /* Visible */
  2669.                         WPattrib.underlined = FALSE;    /* No underline */
  2670.                         WPattrib.reversed = TRUE;       /* reverse video */
  2671.                         WPattrib.unerasable = TRUE;     /* Write-Protected */
  2672.                         WPattrib.graphic = FALSE ;      /* Not graphic character */
  2673.                         WPattrib.dim = TRUE ;           /* dim */
  2674.                     }
  2675.                     break;
  2676.                 case 'C':
  2677.                     if ( ISWY60(tt_type_mode) ) {
  2678.                         /* Invisible on */
  2679.                         debug(F110,"Wyse Escape","Write Protect Attribute: Invisible",0);
  2680.                         if ( debses )
  2681.                             break;
  2682.                         WPattrib.invisible = TRUE ;
  2683.                     }
  2684.                     else if ( ISWY30( tt_type_mode ) ) {
  2685.                         /* Double-wide and normal */
  2686.                         debug(F110,"Wyse Escape","Write Protect Attribute: Double Wide and Normal",0);
  2687.                         if ( debses )
  2688.                             break;
  2689.                         WPattrib.blinking = FALSE;      /* No blink */
  2690.                         WPattrib.bold = FALSE;          /* No bold */
  2691.                         WPattrib.invisible = FALSE;     /* Visible */
  2692.                         WPattrib.underlined = FALSE;    /* No underline */
  2693.                         WPattrib.reversed = FALSE;      /* No reverse video */
  2694.                         WPattrib.unerasable = TRUE;     /* Write-Protected */
  2695.                         WPattrib.graphic = FALSE ;      /* Not graphic character */
  2696.                         WPattrib.dim = FALSE ;          /* No dim */
  2697.                     }
  2698.                     break;
  2699.                 case 'D':
  2700.                     if ( ISWY30( tt_type_mode ) ) {
  2701.                         /* Double-wide and reverse */
  2702.                         debug(F110,"Wyse Escape","Write Protect Attribute: Double Wide and Reverse",0);
  2703.                         if ( debses )
  2704.                             break;
  2705.                         WPattrib.blinking = FALSE;      /* No blink */
  2706.                         WPattrib.bold = FALSE;          /* No bold */
  2707.                         WPattrib.invisible = FALSE;     /* Visible */
  2708.                         WPattrib.underlined = FALSE;    /* No underline */
  2709.                         WPattrib.reversed = TRUE;       /* reverse video */
  2710.                         WPattrib.unerasable = TRUE;     /* Write-Protected */
  2711.                         WPattrib.graphic = FALSE ;      /* Not graphic character */
  2712.                         WPattrib.dim = FALSE ;          /* No dim */
  2713.                     }
  2714.                     break;
  2715.                 case 'E':
  2716.                     if ( ISWY60(tt_type_mode) ) {
  2717.                         /* Underline on */
  2718.                         debug(F110,"Wyse Escape","Write Protect Attribute: Underline",0);
  2719.                         if ( debses )
  2720.                             break;
  2721.                         WPattrib.underlined = TRUE ;
  2722.                     }
  2723.                     else if ( ISWY30( tt_type_mode ) ) {
  2724.                         /* Double-wide and dim */
  2725.                         debug(F110,"Wyse Escape","Write Protect Attribute: Double Wide and Dim",0);
  2726.                         if ( debses )
  2727.                             break;
  2728.                         WPattrib.blinking = FALSE;      /* No blink */
  2729.                         WPattrib.bold = FALSE;          /* No bold */
  2730.                         WPattrib.invisible = FALSE;     /* Visible */
  2731.                         WPattrib.underlined = FALSE;    /* No underline */
  2732.                         WPattrib.reversed = FALSE;      /* No reverse video */
  2733.                         WPattrib.unerasable = TRUE;     /* Write-Protected */
  2734.                         WPattrib.graphic = FALSE ;      /* Not graphic character */
  2735.                         WPattrib.dim = TRUE ;           /* dim */
  2736.                     }
  2737.                     break;
  2738.                 case 'F':
  2739.                     if ( ISWY60(tt_type_mode) ) {
  2740.                         /* Reverse on */
  2741.                         debug(F110,"Wyse Escape","Write Protect Attribute: Reverse",0);
  2742.                         if ( debses )
  2743.                             break;
  2744.                         WPattrib.reversed = TRUE ;
  2745.                     }
  2746.                     else if ( ISWY30( tt_type_mode ) ) {
  2747.                         /* Double-wide, reverse, and dim */
  2748.                         debug(F110,"Wyse Escape","Write Protect Attribute: Double Wide, Reverse and Dim",0);
  2749.                         if ( debses )
  2750.                             break;
  2751.                         WPattrib.blinking = FALSE;      /* No blink */
  2752.                         WPattrib.bold = FALSE;          /* No bold */
  2753.                         WPattrib.invisible = FALSE;     /* Visible */
  2754.                         WPattrib.underlined = FALSE;    /* No underline */
  2755.                         WPattrib.reversed = TRUE;       /* reverse video */
  2756.                         WPattrib.unerasable = TRUE;     /* Write-Protected */
  2757.                         WPattrib.graphic = FALSE ;      /* Not graphic character */
  2758.                         WPattrib.dim = TRUE ;           /* dim */
  2759.                     }
  2760.                     break;
  2761.                 case 'G':
  2762.                     if ( ISWY60( tt_type_mode ) ) {
  2763.                         /* Dim on */
  2764.                         debug(F110,"Wyse Escape","Write Protect Attribute: Dim",0);
  2765.                         if ( debses )
  2766.                             break;
  2767.                         WPattrib.blinking = FALSE;      /* No blink */
  2768.                         WPattrib.bold = FALSE;          /* No bold */
  2769.                         WPattrib.invisible = FALSE;     /* Visible */
  2770.                         WPattrib.underlined = FALSE;    /* No underline */
  2771.                         WPattrib.reversed = FALSE;      /* No reverse video */
  2772.                         WPattrib.unerasable = TRUE;     /* Write-Protected */
  2773.                         WPattrib.graphic = FALSE ;      /* Not graphic character */
  2774.                         WPattrib.dim = TRUE ;           /* dim */
  2775.                     }
  2776.                     break;
  2777.                 case 'H':
  2778.                     if ( ISWY60( tt_type_mode ) ) {
  2779.                         /* Line lock mode on */
  2780.                         debug(F110,"Wyse Escape","Line lock mode on",0);
  2781.                         if ( debses )
  2782.                             break;
  2783.                         linelock = TRUE ;
  2784.                     }
  2785.                     break;
  2786.                 case 'I':
  2787.                     if ( ISWY60( tt_type_mode ) ) {
  2788.                         /* Line lock mode off */
  2789.                         debug(F110,"Wyse Escape","Line lock mode off",0);
  2790.                         if ( debses )
  2791.                             break;
  2792.                         linelock = FALSE ;
  2793.                     }
  2794.                     break;
  2795.                 case 'J':
  2796.                     if ( ISWY60( tt_type_mode ) ) {
  2797.                         /* Set margin bell at cursor position */
  2798.                         debug(F110,"Wyse Escape","Set margin bell cursor position",0);
  2799.                         if ( debses )
  2800.                             break;
  2801.                         marginbellcol = wherex[VTERM] ;
  2802.                         marginbell = TRUE ;
  2803.                     }
  2804.                     else if ( ISWY30( tt_type_mode ) ) {
  2805.                         /* Underline */
  2806.                         debug(F110,"Wyse Escape","Write Protect Attribute: Underline",0);
  2807.                         if ( debses )
  2808.                             break;
  2809.                         WPattrib.blinking = FALSE;      /* No blink */
  2810.                         WPattrib.bold = FALSE;          /* No bold */
  2811.                         WPattrib.invisible = FALSE;     /* Visible */
  2812.                         WPattrib.underlined = TRUE;     /* underline */
  2813.                         WPattrib.reversed = TRUE;       /* reverse video */
  2814.                         WPattrib.unerasable = TRUE;     /* Write-Protected */
  2815.                         WPattrib.graphic = FALSE ;      /* Not graphic character */
  2816.                         WPattrib.dim = FALSE ;          /* No dim */
  2817.                     }
  2818.                     break;
  2819.                 case 'K':
  2820.                     if ( ISWY30( tt_type_mode ) ) {
  2821.                         /* Underline and Dim */
  2822.                         debug(F110,"Wyse Escape","Write Protect Attribute: Underline and Dim",0);
  2823.                         if ( debses )
  2824.                             break;
  2825.                         WPattrib.blinking = FALSE;      /* No blink */
  2826.                         WPattrib.bold = FALSE;          /* No bold */
  2827.                         WPattrib.invisible = FALSE;     /* Visible */
  2828.                         WPattrib.underlined = TRUE;     /* underline */
  2829.                         WPattrib.reversed = FALSE;      /* No reverse video */
  2830.                         WPattrib.unerasable = TRUE;     /* Write-Protected */
  2831.                         WPattrib.graphic = FALSE ;      /* Not graphic character */
  2832.                         WPattrib.dim = TRUE;            /* dim */
  2833.                     }
  2834.                     break;
  2835.                 case 'L':
  2836.                     if ( ISWY30( tt_type_mode ) ) {
  2837.                         /* Underline and Double-wide */
  2838.                         debug(F110,"Wyse Escape","Write Protect Attribute: Double-wide and Underline",0);
  2839.                         if ( debses )
  2840.                             break;
  2841.                         WPattrib.blinking = FALSE;      /* No blink */
  2842.                         WPattrib.bold = FALSE;          /* No bold */
  2843.                         WPattrib.invisible = FALSE;     /* Visible */
  2844.                         WPattrib.underlined = TRUE;     /* underline */
  2845.                         WPattrib.reversed = FALSE;      /* No reverse video */
  2846.                         WPattrib.unerasable = TRUE;     /* Write-Protected */
  2847.                         WPattrib.graphic = FALSE ;      /* Not graphic character */
  2848.                         WPattrib.dim = FALSE ;          /* No dim */
  2849.                     }
  2850.                     break;
  2851.                 case '8':
  2852.                     /* Screen display off */
  2853.                     debug(F110,"Wyse Escape","Screen display off",0);
  2854.                     if ( debses )
  2855.                         break;
  2856.                     screenon = FALSE ;
  2857.                     break;
  2858.                 case '9':
  2859.                     /* Screen display on (default) */
  2860.                     debug(F110,"Wyse Escape","Screen display on",0);
  2861.                     if ( debses )
  2862.                         break;
  2863.                     screenon = TRUE ;
  2864.                     break;
  2865.  
  2866.                 case ':':
  2867.                     /* 80-column mode */
  2868.                     debug(F110,"Wyse Escape","80-column mode",0);
  2869.                     if ( debses )
  2870.                         break;
  2871.                     RequestScreenMutex(SEM_INDEFINITE_WAIT);
  2872.                     killcursor(VTERM);
  2873.                     Set80Cols(VTERM);
  2874. #ifdef TCPSOCKET
  2875. #ifdef CK_NAWS
  2876.                     if (ttmdm < 0 && TELOPT_ME(TELOPT_NAWS)) {
  2877.                         tn_snaws();
  2878. #ifdef RLOGCODE
  2879.                         rlog_naws();
  2880. #endif /* RLOGCODE */
  2881. #ifdef SSHBUILTIN
  2882.                         ssh_snaws();
  2883. #endif /* SSHBUILTIN */
  2884.                     }
  2885. #endif /* CK_NAWS */
  2886. #endif /* TCPSOCKET */
  2887.                     setborder();
  2888.                     newcursor(VTERM);
  2889.                     ipadl25();
  2890.                     ReleaseScreenMutex();
  2891.                     break;
  2892.  
  2893.                 case ';':
  2894.                     /* 132-column mode (default) */
  2895.                     debug(F110,"Wyse Escape","132-column mode",0);
  2896.                     if ( debses )
  2897.                         break;
  2898.                     RequestScreenMutex(SEM_INDEFINITE_WAIT);
  2899.                     killcursor(VTERM);
  2900.                     Set132Cols(VTERM);
  2901. #ifdef TCPSOCKET
  2902. #ifdef CK_NAWS
  2903.                     if (ttmdm < 0 && TELOPT_ME(TELOPT_NAWS)) {
  2904.                         tn_snaws();
  2905. #ifdef RLOGCODE
  2906.                         rlog_naws();
  2907. #endif /* RLOGCODE */
  2908. #ifdef SSHBUILTIN
  2909.                         ssh_snaws();
  2910. #endif /* SSHBUILTIN */
  2911.                     }
  2912. #endif /* CK_NAWS */
  2913. #endif /* TCPSOCKET */
  2914.                     setborder();
  2915.                     newcursor(VTERM);
  2916.                     ipadl25();
  2917.                     ReleaseScreenMutex();
  2918.                     break;
  2919.  
  2920.                 case '<':
  2921.                     /* Smooth scroll @ 1 row per second */
  2922.                     debug(F110,"Wyse Escape","Smooth scroll @ 1 row/second",0);
  2923.                     if ( debses )
  2924.                         break;
  2925.                     SmoothScroll() ;
  2926.                     break;
  2927.                 case '=':
  2928.                     /* Smooth scroll @ 2 rows per second */
  2929.                     debug(F110,"Wyse Escape","Smooth scroll @ 2 row/second",0);
  2930.                     if ( debses )
  2931.                         break;
  2932.                     SmoothScroll() ;
  2933.                     break;
  2934.                 case '>':
  2935.                     /* Smooth scroll @ 4 rows per second */
  2936.                     debug(F110,"Wyse Escape","Smooth scroll @ 4 row/second",0);
  2937.                     if ( debses )
  2938.                         break;
  2939.                     SmoothScroll() ;
  2940.                     break;
  2941.                 case '?':
  2942.                     /* Smooth scroll @ 8 rows per second */
  2943.                     debug(F110,"Wyse Escape","Smooth scroll @ 8 row/second",0);
  2944.                     if ( debses )
  2945.                         break;
  2946.                     SmoothScroll() ;
  2947.                     break;
  2948.                 case '@':
  2949.                     /* Jump scroll (default) */
  2950.                     debug(F110,"Wyse Escape","Jump scroll",0);
  2951.                     if ( debses )
  2952.                         break;
  2953.                     JumpScroll() ;
  2954.                     break;
  2955.  
  2956.                 case 'a':
  2957.                     /* WY60 - Extended status line on */
  2958.                     /* We use the status line for the label line */
  2959.                     debug(F110,"Wyse Escape","Extended Status Line On",0);
  2960.                     break;
  2961.                 case 'b':
  2962.                     /* WY60 - Standard status line on */
  2963.                     debug(F110,"Wyse Escape","Standard Status Line On",0);
  2964.                     break;
  2965.                 case 'c':
  2966.                     /* WY60 - Status line display off */
  2967.                     debug(F110,"Wyse Escape","Status Line Off",0);
  2968.                     break;
  2969.                 }
  2970.                 break;
  2971.             }
  2972.             case 'a': {
  2973.                 /* Moves the cursor to a specified row and column for an  */
  2974.                 /* 80- or a 132-column screen.  This has a format of:     */
  2975.                 /*    ESC a rr R ccc C  where:                            */
  2976.                 /*   rr  = the ASCII encoded decimal value of the row     */
  2977.                 /*   R   = ASCII R                                        */
  2978.                 /*   ccc = the ASCII encoded decimal value of the column  */
  2979.                 /*   C   = ASCII C                                        */
  2980.                 /* For example:  ESC a 1 R 1 C positions the cursor at    */
  2981.                 /* true home.                                             */
  2982.                 int n, c=0, r=0 ;
  2983.  
  2984.                 debug(F110,"Wyse Escape","Move cursor to row and column",0);
  2985.  
  2986.                 n = wyinc();
  2987.  
  2988.                 while ( isdigit(n) ) {
  2989.                     r = r * 10 + n - '0' ;
  2990.                     n = wyinc() ;
  2991.                 }
  2992.                 if ( n != 'R' ) {
  2993.                     escstate = ES_NORMAL ;
  2994.                     wyseascii( n ) ;
  2995.                     return ;
  2996.                 }
  2997.  
  2998.                 n = wyinc();
  2999.  
  3000.                 while ( isdigit(n) ) {
  3001.                     c = c * 10 + n - '0' ;
  3002.                     n = wyinc() ;
  3003.                 }
  3004.                 if ( n != 'C' ) {
  3005.                     escstate = ES_NORMAL ;
  3006.                     wyseascii( n ) ;
  3007.                     return ;
  3008.                 }
  3009.  
  3010.                 if ( debses )
  3011.                     break;
  3012.                 lgotoxy( VTERM, c, r ) ;
  3013.                 break;
  3014.             }
  3015.             case 'b': {
  3016.                 /* Transmits the cursor address to the host computer for  */
  3017.                 /* the active text segment.  The format is:               */
  3018.                 /*   rr R ccc C   where:                                  */
  3019.                 /*   rr  = the ASCII encoded decimal value of the row     */
  3020.                 /*   R   = ASCII R                                        */
  3021.                 /*   ccc = the ASCII encoded decimal value of the column  */
  3022.                 /*   C   = ASCII C                                        */
  3023.                 char buf[12] ;
  3024.                 debug(F110,"Wyse Escape","Transmit cursor address to the host",0);
  3025.  
  3026.                 if ( debses )
  3027.                     break;
  3028.                 sprintf(buf,"%dR%dC",wherey[VTERM],wherex[VTERM]);
  3029.                 break;
  3030.             }
  3031.             case 'c':
  3032.                 if ( ISWY30(tt_type_mode) ) {
  3033.                     /* Activate Upper Data Segment */
  3034.                     debug(F110,"Wyse Escape","Activate Upper Data Segment",0);
  3035.                     if ( debses )
  3036.                         break;
  3037.                 }
  3038.                 else if ( ISWY60(tt_type_mode) )
  3039.                 {
  3040.                     int n = wyinc() ;
  3041.  
  3042.                     switch ( n ) {
  3043.                     case '0': {
  3044.                         /* Set MODEM port operating parameters */
  3045.                         /* baud stop parity word               */
  3046.                         int baud, stop, parity, word ;
  3047.                         debug(F110,"Wyse Escape","Set Modem Port parameters",0);
  3048.                         baud = wyinc();
  3049.                         stop = wyinc();
  3050.                         parity = wyinc();
  3051.                         word = wyinc();
  3052.                         break;
  3053.                     }
  3054.                     case '1': {
  3055.                         /* Set AUX port operating parameters */
  3056.                         /* baud stop parity word             */
  3057.                         int baud, stop, parity, word ;
  3058.                         debug(F110,"Wyse Escape","Set AUX port parameters",0);
  3059.                         baud = wyinc();
  3060.                         stop = wyinc();
  3061.                         parity = wyinc();
  3062.                         word = wyinc();
  3063.                         break;
  3064.                     }
  3065.                     case '2': {
  3066.                         /* Set MODEM port receive handshaking */
  3067.                         /* hndshk */
  3068.                         int hndshk = wyinc();
  3069.                         debug(F110,"Wyse Escape","Set Modem port RX handshaking",0);
  3070.                         break;
  3071.                     }
  3072.                     case '3': {
  3073.                         /* Set AUX port receive handshaking */
  3074.                         /* hndshk */
  3075.                         int hndshk = wyinc();
  3076.                         debug(F110,"Wyse Escape","Set AUX port RX handshaking",0);
  3077.                         break;
  3078.                     }
  3079.                     case '4': {
  3080.                         /* Set MODEM port transmit handshaking */
  3081.                         /* hndshk */
  3082.                         int hndshk = wyinc();
  3083.                         debug(F110,"Wyse Escape","Set Modem port TX handshaking",0);
  3084.                         break;
  3085.                     }
  3086.                     case '5': {
  3087.                         /* Set AUX port transmit handshaking */
  3088.                         /* hndshk */
  3089.                         int hndshk = wyinc();
  3090.                         debug(F110,"Wyse Escape","Set AUX port TX handshaking",0);
  3091.                         break;
  3092.                     }
  3093.                     case '6': {
  3094.                         /* Set maximum data transmission speed */
  3095.                         /* maxspd */
  3096.                         int maxspd = wyinc();
  3097.                         debug(F110,"Wyse Escape","Set Max Data TX speed",0);
  3098.                         break;
  3099.                     }
  3100.                     case '7': {
  3101.                         /* Set maximum function key transmission speed */
  3102.                         /* max */
  3103.                         int max = wyinc() ;
  3104.                         debug(F110,"Wyse Escape","Set Max Function Key TX speed",0);
  3105.                         break;
  3106.                     }
  3107.                     case '8': {
  3108.                         /* Load time of day */
  3109.                         /* hh mm */
  3110.                         int hh, mm ;
  3111.                         debug(F110,"Wyse Escape","Load Time of Day",0);
  3112.                         hh = wyinc();
  3113.                         mm = wyinc();
  3114.                         loadtod( hh, mm ) ;
  3115.                         break;
  3116.                     }
  3117.                     case ';': {
  3118.                         /* Program answerback message */
  3119.                         /* answer CTRL-Y */
  3120.                         int n ;
  3121.                         debug(F110,"Wyse Escape","Program Answerback message",0);
  3122.                         while ( (n=wyinc()) != 25 )
  3123.                             ;
  3124.                         if ( debses )
  3125.                             break;
  3126.                         break;
  3127.                     }
  3128.                     case '<':
  3129.                         /* Send answerback message */
  3130.                         debug(F110,"Wyse Escape","Send Answerback message",0);
  3131.                         if ( debses )
  3132.                             break;
  3133.                         if (tt_answer)
  3134.                             sendchars(answerback,strlen(answerback)) ;
  3135.                         break;
  3136.                     case '\\': {
  3137.                         /* 325 or 160 - Select Bell Tone */
  3138.                         /* 0 off, 1 Low pitch, 2,3 High pitch */
  3139.                         int tone = wyinc() ;
  3140.                         debug(F110,"Wyse Escape","Select Bell Tone",0);
  3141.                         if ( debses )
  3142.                             break;
  3143.                         break;
  3144.                     }
  3145.                     case '=':
  3146.                         /* Conceal answerback message */
  3147.                         debug(F110,"Wyse Escape","Conceal Answerback message",0);
  3148.                         break;
  3149.                     case '?': {
  3150.                         /* Clear font back */
  3151.                         /* bank */
  3152.                         int bank = wyinc();
  3153.                         struct _vtG * pG;
  3154.  
  3155.                         debug(F110,"Wyse Escape","Clear font bank",0);
  3156.  
  3157.                         if ( debses )
  3158.                             break;
  3159.  
  3160.                         pG = &G[bank];
  3161.                         pG->designation = TX_UNDEF;
  3162.                         pG->c1 = FALSE ;
  3163.                         pG->national = FALSE;
  3164.                         pG->rtoi = NULL ;
  3165.                         pG->itol = NULL ;
  3166.                         pG->itor = NULL ;
  3167.                         pG->ltoi = NULL ;
  3168.                         break;
  3169.                     }
  3170.                     case '@': {
  3171.                         /* Load font bank */
  3172.                         /* bank set */
  3173.                         int bank, set ;
  3174.                         unsigned char cs = TX_UNDEF ;
  3175.                         struct _vtG * pG;
  3176.                         debug(F110,"Wyse Escape","Load font bank",0);
  3177.                         bank = wyinc();
  3178.                         set = wyinc() ;
  3179.  
  3180.                         /* bank is 0 (G0) to 3 (G3) */
  3181.                         /* Set is:
  3182.                            @ - Native mode
  3183.                            A - Multinational (CP437)
  3184.                            B - Standard ASCII
  3185.                            C - Graphics 1
  3186.                            D - PC Equivalent
  3187.                            E - Graphics 2
  3188.                            F - Graphics 3
  3189.                            G - Standard ANSI
  3190.                            ` - 44-line native
  3191.                            a - 44-line multinational
  3192.                            b - 44-line PC
  3193.                            c - 44-line Standard ASCII
  3194.                            d - 44-line Standard ANSI
  3195.                         */
  3196.                         if ( debses )
  3197.                             break;
  3198.  
  3199.                         pG = &G[bank];
  3200.                         switch ( set ) {
  3201.                         case '@':
  3202.                         case 'a':
  3203.                             cs = TX_WYSE60G_N;
  3204.                             break;
  3205.                         case 'A':
  3206.                             cs = TX_CP437;
  3207.                             break;
  3208.                         case 'B':
  3209.                         case 'c':
  3210.                             cs = TX_ASCII;
  3211.                             break;
  3212.                         case 'C':
  3213.                             cs = TX_WYSE60G_1;
  3214.                             break;
  3215.                         case 'D':
  3216.                         case 'b':
  3217.                             cs = TX_IBMC0GRPH;
  3218.                             break;
  3219.                         case 'E':
  3220.                             cs = TX_WYSE60G_2;
  3221.                             break;
  3222.                         case 'F':
  3223.                             cs = TX_WYSE60G_3;
  3224.                             break;
  3225.                         case 'G':
  3226.                         case 'd':
  3227.                             cs = TX_CP1252; /* This is wrong */
  3228.                             break;
  3229.                         }
  3230.  
  3231.                         if ( cs <= MAXTXSETS ) {
  3232.                             pG->designation = cs ;
  3233.                             pG->size = cs96;
  3234.                             pG->c1 = cs_is_std(cs) ;
  3235.                             pG->national = CSisNRC( cs ) ;
  3236.                             pG->rtoi = xl_u[cs] ;
  3237.                             pG->itol = xl_tx[tcsl] ;
  3238.                             pG->ltoi = xl_u[tcsl] ;
  3239.                             pG->itor = xl_tx[cs] ;
  3240.                         }
  3241.                         else if ( cs != TX_UNDEF ) {
  3242.                             debug(F110,"charset - ERROR","cs != TX_UNDEF",0);
  3243.                             pG->designation = cs ;
  3244.                             pG->c1 = FALSE ;
  3245.                             pG->national = FALSE;
  3246.                             pG->rtoi = NULL ;
  3247.                             pG->itol = NULL ;
  3248.                             pG->itor = NULL ;
  3249.                             pG->ltoi = NULL ;
  3250.                         }
  3251.                         break;
  3252.                     }
  3253.                     case 'A': {
  3254.                         /* Define and load character */
  3255.                         /* bank pp bb ... bb CTRL-Y  */
  3256.                         int bank, pp, bb, cnt = 0 ;
  3257.                         debug(F110,"Wyse Escape","Define and load character",0);
  3258.                         bank = wyinc() ;
  3259.                         pp = wyinc() ;
  3260.                         do {
  3261.                             bb = wyinc() ;
  3262.                             cnt++;
  3263.                         } while ( cnt < 32 && bb != XEM );
  3264.                         break;
  3265.                     }
  3266.                     case 'B': {
  3267.                         /* Define primary character set */
  3268.                         /* bank */
  3269.                         int bank = wyinc() ;
  3270.                         debug(F110,"Wyse Escape","Define primary char set",0);
  3271.                         /* This should point GL at a bank */
  3272.                         if ( debses )
  3273.                             break;
  3274.                         if ( bank >= '0' && bank <= '3' )
  3275.                             GL = &G[bank-'0'];
  3276.                         break;
  3277.                     }
  3278.                     case 'C': {
  3279.                         /* Define secondary character set */
  3280.                         /* bank */
  3281.                         int bank = wyinc() ;
  3282.                         debug(F110,"Wyse Escape","Define secondary char set",0);
  3283.                         /* This should point GR at a bank */
  3284.                         if ( debses )
  3285.                             break;
  3286.                         if ( bank >= '0' && bank <= '3' )
  3287.                             GR = &G[bank-'0'];
  3288.                         break;
  3289.                     }
  3290.                     case 'D':
  3291.                         /* Select primary character set */
  3292.                         debug(F110,"Wyse Escape","Select primary char set",0);
  3293.                         if ( debses )
  3294.                             break;
  3295.                         wyse8bit = FALSE;
  3296.                         break;
  3297.                     case 'E':
  3298.                         /* Select secondary character set */
  3299.                         debug(F110,"Wyse Escape","Select secondary char set",0);
  3300.                         if ( debses )
  3301.                             break;
  3302.                         wyse8bit = TRUE;
  3303.                         break;
  3304.                     case 'F': {
  3305.                         /* Clear unprotected rectangle in 80-col page */
  3306.                         /* line col char */
  3307.                         /* Clear unprotected rectangle in 132-col page */
  3308.                         /* line ~ col char */
  3309.                         /* Is ignored if a line is locked */
  3310.                         int line, col, fillchar ;
  3311.                         debug(F110,"Wyse Escape","Clear unprotected rectangle",0);
  3312.  
  3313.                         line = wyinc() ;
  3314.  
  3315.                         col = wyinc();
  3316.  
  3317.                         if ( col == '~' ) {
  3318.                             col = wyinc() ;
  3319.                         }
  3320.  
  3321.                         fillchar = wyinc() ;
  3322.  
  3323.                         if ( debses )
  3324.                             break;
  3325.                         if ( protect )
  3326.                             selclrrect_escape( VTERM, wherey[VTERM], wherex[VTERM],
  3327.                                                line-31, col-31, fillchar ) ;
  3328.                         else
  3329.                             clrrect_escape( VTERM, wherey[VTERM], wherex[VTERM],
  3330.                                             line-31, col-31, fillchar ) ;
  3331.                         break;
  3332.                     }
  3333.                     case 'G': {
  3334.                         /* Box rectangle in 80-col page */
  3335.                         /* line col */
  3336.                         /* Box rectangle in 132-col page */
  3337.                         /* line ~ col */
  3338.                         /* Is ignored if a line is locked */
  3339.                         int line, col ;
  3340.                         debug(F110,"Wyse Escape","Box rectangle",0);
  3341.                         line = wyinc() ;
  3342.  
  3343.                         col = wyinc();
  3344.  
  3345.                         if ( col == '~' ) {
  3346.                             col = wyinc() ;
  3347.                         }
  3348.  
  3349.                         if ( debses )
  3350.                             break;
  3351.                         boxrect_escape( VTERM, line-31, col-31 ) ;
  3352.                         break;
  3353.                     }
  3354.                     case 'H': {
  3355.                         /* Clear entire rectangle in 80-col page */
  3356.                         /* line col char */
  3357.                         /* Clear entire rectangle in 132-col page */
  3358.                         /* line ~ col char */
  3359.                         /* Is ignored if a line is locked */
  3360.                         int line, col, fillchar ;
  3361.                         debug(F110,"Wyse Escape","Clear entire rectangle",0);
  3362.                         line = wyinc() ;
  3363.  
  3364.                         col = wyinc();
  3365.  
  3366.                         if ( col == '~' ) {
  3367.                             col = wyinc() ;
  3368.                         }
  3369.  
  3370.                         fillchar = wyinc() ;
  3371.  
  3372.                         if ( debses )
  3373.                             break;
  3374.                         clrrect_escape( VTERM, wherey[VTERM], wherex[VTERM],
  3375.                                         line-31, col-31, fillchar ) ;
  3376.                         break;
  3377.                     }
  3378.                     case 'I':
  3379.                         /* Clear unprotected col to specific character */
  3380.                         /* char */
  3381.                         {
  3382.                             int n = wyinc();
  3383.                             debug(F110,"Wyse Escape","Clear unprotected col to char",0);
  3384.                             if ( debses )
  3385.                                 break;
  3386.                             if ( protect )
  3387.                                 selclrcol_escape( VTERM, n ) ;
  3388.                             else
  3389.                                 clrcol_escape( VTERM, n ) ;
  3390.                         }
  3391.                         break;
  3392.                     case 'J':
  3393.                         /* Delete cursor column */
  3394.                         if ( debses )
  3395.                             break;
  3396.                         blankvcell.c = SP ;
  3397.                         blankvcell.a = geterasecolor(VTERM) ;
  3398.                         VscrnScrollRt( VTERM,
  3399.                                        0, wherex[VTERM]-1,
  3400.                                        VscrnGetHeight(VTERM)-(tt_status[VTERM]?1:0),
  3401.                                        VscrnGetWidth(VTERM)-1,
  3402.                                        1, blankvcell ) ;
  3403.                         break;
  3404.                     case 'K':
  3405.                         /* Clear unprotected column to nulls */
  3406.                         debug(F110,"Wyse Escape","Clear unprotected col to NUL",0);
  3407.                         if ( debses )
  3408.                             break;
  3409.                         if (protect)
  3410.                             selclrcol_escape( VTERM, NUL ) ;
  3411.                         else
  3412.                             clrcol_escape( VTERM, NUL ) ;
  3413.                         break;
  3414.                     case 'L':
  3415.                         /* Clear unprotected to end of line with nulls */
  3416.                         debug(F110,"Wyse Escape","Clear unprotected to EOL to NUL",0);
  3417.                         if ( debses )
  3418.                             break;
  3419.                         if (protect)
  3420.                             selclrtoeoln( VTERM, NUL ) ;
  3421.                         else
  3422.                             clrtoeoln( VTERM, NUL ) ;
  3423.                         break;
  3424.                     case 'M':
  3425.                         /* Insert column of nulls */
  3426.                         debug(F110,"Wyse Escape","Insert col of NUL",0);
  3427.                         if ( debses )
  3428.                             break;
  3429.                         blankvcell.c = SP ;
  3430.                         blankvcell.a = geterasecolor(VTERM) ;
  3431.                         VscrnScrollRt( VTERM,
  3432.                                        0, wherex[VTERM]-1,
  3433.                                        VscrnGetHeight(VTERM)-(tt_status[VTERM]?1:0),
  3434.                                        VscrnGetWidth(VTERM)-1,
  3435.                                        1, blankvcell ) ;
  3436.                         break;
  3437.                     case 'N': {
  3438.                         /* Box rectangle to right of cursor */
  3439.                         /* width height */
  3440.                         int w, h ;
  3441.                         debug(F110,"Wyse Escape","Box rectangle to right of cursor",0);
  3442.                         w = wyinc() ;
  3443.  
  3444.                         h = wyinc() ;
  3445.  
  3446.                         if ( debses )
  3447.                             break;
  3448.                         boxrect_escape( VTERM, wherey[VTERM]+h-31,
  3449.                                         wherex[VTERM]+w-31 ) ;
  3450.                         break;
  3451.                     }
  3452.                     case 'O':
  3453.                         /* Clear unprotected to end of line with spaces */
  3454.                         debug(F110,"Wyse Escape","Clear unprotected to EOL to SP",0);
  3455.                         if ( debses )
  3456.                             break;
  3457.                         if ( protect )
  3458.                             selclrtoeoln( VTERM, SP ) ;
  3459.                         else
  3460.                             clrtoeoln( VTERM, SP ) ;
  3461.                         break;
  3462.                     case 'P':
  3463.                         /* Clear unprotected page foreground to spaces */
  3464.                         debug(F110,"Wyse Escape","Clear unprotected page foreground to SP",0);
  3465.                         if ( debses )
  3466.                             break;
  3467.                         if ( protect )
  3468.                             selclreoscr_escape( VTERM, SP ) ;
  3469.                         else
  3470.                             clreoscr_escape( VTERM, SP ) ;
  3471.                         /* ??? we really need to figure out what the last */
  3472.                         /* assigned attribute was so that we know what    */
  3473.                         /* to assign to these cleared cells               */
  3474.                         break;
  3475.                     case 'Q':
  3476.                         /* Clear unprotected page foreground to nulls */
  3477.                         debug(F110,"Wyse Escape","Clear unprotected page foreground to NUL",0);
  3478.                         if ( debses )
  3479.                             break;
  3480.                         if ( protect )
  3481.                             selclreoscr_escape( VTERM, NUL ) ;
  3482.                         else
  3483.                             clreoscr_escape( VTERM, NUL ) ;
  3484.                         /* ??? we really need to figure out what the last */
  3485.                         /* assigned attribute was so that we know what    */
  3486.                         /* to assign to these cleared cells               */
  3487.                         break;
  3488.                     case 'R':
  3489.                         /* Clear unprotected line foreground to spaces */
  3490.                         debug(F110,"Wyse Escape","Clear unprotected line foreground to SP",0);
  3491.                         if ( debses )
  3492.                             break;
  3493.                         if ( protect )
  3494.                             selclrtoeoln( VTERM, SP ) ;
  3495.                         else
  3496.                             clrtoeoln( VTERM, SP ) ;
  3497.                         break;
  3498.                     case 'S':
  3499.                         /* Clear unprotected line foreground to nulls */
  3500.                         debug(F110,"Wyse Escape","Clear unprotected line foreground to NUL",0);
  3501.                         if ( debses )
  3502.                             break;
  3503.                         if ( protect )
  3504.                             selclrtoeoln( VTERM, NUL ) ;
  3505.                         else
  3506.                             clrtoeoln( VTERM, NUL ) ;
  3507.                         break;
  3508.                     case 'T':
  3509.                         debug(F110,"Wyse Escape","cT",0);
  3510.                         break;
  3511.                     case 'U':
  3512.                         /* Clear all programmable keys */
  3513.                         debug(F110,"Wyse Escape","Clear all programmable keys",0);
  3514.                         if ( debses )
  3515.                             break;
  3516.                         udkreset() ;
  3517.                         break;
  3518.                     }
  3519.                 }
  3520.                 break;
  3521.             case 'd':
  3522.                 if ( ISWY30(tt_type_mode ) ) {
  3523.                     /* Moves the cursor to a specified row and column for an  */
  3524.                     /* 80- or a 132-column screen.  This has a format of:     */
  3525.                     /*    ESC a rr R ccc C  where:                            */
  3526.                     /*   rr  = the ASCII encoded decimal value of the row     */
  3527.                     /*   R   = ASCII R                                        */
  3528.                     /*   ccc = the ASCII encoded decimal value of the column  */
  3529.                     /*   C   = ASCII C                                        */
  3530.                     /* For example:  ESC a 1 R 1 C positions the cursor at    */
  3531.                     /* true home.                                             */
  3532.                     int n, c=0, r=0 ;
  3533.  
  3534.                     debug(F110,"Wyse Escape","Move cursor to row and column",0);
  3535.                     n = wyinc();
  3536.  
  3537.                     while ( isdigit(n) ) {
  3538.                         r = r * 10 + n - '0' ;
  3539.                         n = wyinc() ;
  3540.                     }
  3541.                     if ( n != 'R' ) {
  3542.                         escstate = ES_NORMAL ;
  3543.                         wyseascii( n ) ;
  3544.                         return ;
  3545.                     }
  3546.  
  3547.                     n = wyinc();
  3548.  
  3549.                     while ( isdigit(n) ) {
  3550.                         c = c * 10 + n - '0' ;
  3551.                         n = wyinc() ;
  3552.                     }
  3553.                     if ( n != 'C' ) {
  3554.                         escstate = ES_NORMAL ;
  3555.                         wyseascii( n ) ;
  3556.                         return ;
  3557.                     }
  3558.  
  3559.                     if ( debses )
  3560.                         break;
  3561.                     lgotoxy( VTERM, c, r ) ;
  3562.                 }
  3563.                 else if ( ISWY60(tt_type_mode) )
  3564.                 {
  3565.                     int n = wyinc();
  3566.  
  3567.                     switch ( n ) {
  3568.                     case SP:
  3569.                         /* Secondary receive mode off */
  3570.                         debug(F110,"Wyse Escape","Secondary RX mode off",0);
  3571.                         if ( debses )
  3572.                             break;
  3573.                         break;
  3574.                     case '!':
  3575.                         /* Secondary receive mode on */
  3576.                         debug(F110,"Wyse Escape","Secondary RX mode on",0);
  3577.                         if ( debses )
  3578.                             break;
  3579.                         break;
  3580.                     case '#':
  3581.                         /* Transparent print on */
  3582.                         debug(F110,"Wyse Escape","Transparent Print on",0);
  3583.                         if ( debses )
  3584.                             break;
  3585.                         xprint = TRUE ;
  3586.                         printeron();
  3587.                         break;
  3588.                     case '$':
  3589.                         /* Bidirectional mode off */
  3590.                         debug(F110,"Wyse Escape","Bidirectional mode off",0);
  3591.                         if ( debses )
  3592.                             break;
  3593.                         cprint = FALSE;
  3594.                         printeroff();
  3595.                         break;
  3596.                     case '%':
  3597.                         /* Bidirectional mode on */
  3598.                         debug(F110,"Wyse Escape","Bidirectional mode on",0);
  3599.                         if ( debses )
  3600.                             break;
  3601.                         cprint = TRUE;
  3602.                         printeron();
  3603.                         break;
  3604.                     case '&':
  3605.                         /* Begin print/send at top of screen */
  3606.                         debug(F110,"Wyse Escape","Begin print/send at top of screen",0);
  3607.                         if ( debses )
  3608.                             break;
  3609.                         break;
  3610.                     case '\'':
  3611.                         /* Begin print/send at top of page */
  3612.                         debug(F110,"Wyse Escape","Begin print/send at top of page",0);
  3613.                         if ( debses )
  3614.                             break;
  3615.                         break;
  3616.                     case '*':
  3617.                         /* Autopage mode off */
  3618.                         debug(F110,"Wyse Escape","Autopage mode off",0);
  3619.                         if ( debses )
  3620.                             break;
  3621.                         wy_autopage = FALSE ;
  3622.                         break;
  3623.                     case '+':
  3624.                         /* Autopage mode on */
  3625.                         debug(F110,"Wyse Escape","Autopage mode on",0);
  3626.                         if ( debses )
  3627.                             break;
  3628.                         wy_autopage = TRUE ;
  3629.                         break;
  3630.                     case '.':
  3631.                         /* End-of-line wrap mode off */
  3632.                         debug(F110,"Wyse Escape","EOL wrap mode off",0);
  3633.                         if ( debses )
  3634.                             break;
  3635.                         tt_wrap = FALSE ;
  3636.                         break;
  3637.                     case '/':
  3638.                         /* End-of-line wrap mode on */
  3639.                         debug(F110,"Wyse Escape","EOL wrap mode on",0);
  3640.                         if ( debses )
  3641.                             break;
  3642.                         tt_wrap = TRUE ;
  3643.                         break;
  3644.                     case '|':
  3645.                         /* Map the reverse attribute (default) - WY160 */
  3646.                         debug(F110,"Wyse Escape","Map the reverse attribute",0);
  3647.                         if ( debses )
  3648.                             break;
  3649.                         break;
  3650.                     case '{':
  3651.                         /* Map the blank attribute - WY160 */
  3652.                         debug(F110,"Wyse Escape","Map the blank attribute",0);
  3653.                         if ( debses )
  3654.                             break;
  3655.                         break;
  3656.                     }
  3657.                 }
  3658.                 break;
  3659.             case 'e':
  3660.                 if ( ISWY30(tt_type_mode) || ISWY60(tt_type_mode) ) {
  3661.                 int mode = wyinc() ;
  3662.  
  3663.                     switch ( mode ) {
  3664.                     case SP:
  3665.                         /* Answerback mode off */
  3666.                         debug(F110,"Wyse Escape","Answerback mode off",0);
  3667.                         if ( debses )
  3668.                             break;
  3669.                         tt_answer = FALSE ;
  3670.                         break;
  3671.                     case '!':
  3672.                         /* Answerback mode on */
  3673.                         debug(F110,"Wyse Escape","Answerback mode on",0);
  3674.                         if ( debses )
  3675.                             break;
  3676.                         tt_answer = TRUE ;
  3677.                         break;
  3678.                     case '"':
  3679.                         /* Page edit mode off */
  3680.                         debug(F110,"Wyse Escape","Page edit mode off",0);
  3681.                         if ( debses )
  3682.                             break;
  3683.                         break;
  3684.                     case '#':
  3685.                         /* Page edit mode on */
  3686.                         debug(F110,"Wyse Escape","Page edit mode on",0);
  3687.                         if ( debses )
  3688.                             break;
  3689.                         break;
  3690.                     case '$':
  3691.                         /* Keyclick on */
  3692.                         debug(F110,"Wyse Escape","keyclick on",0);
  3693.                         if ( debses )
  3694.                             break;
  3695.                         setkeyclick(TRUE);
  3696.                         break;
  3697.                     case '%':
  3698.                         /* Keyclick off */
  3699.                         debug(F110,"Wyse Escape","keyclick off",0);
  3700.                         if ( debses )
  3701.                             break;
  3702.                         setkeyclick(FALSE);
  3703.                         break;
  3704.                     case '&':
  3705.                         /* CAPSLOCK on */
  3706.                         debug(F110,"Wyse Escape","Capslock on",0);
  3707.                         if ( debses )
  3708.                             break;
  3709.                         break;
  3710.                     case '\'':
  3711.                         /* CAPSLOCK off */
  3712.                         debug(F110,"Wyse Escape","Capslock off",0);
  3713.                         if ( debses )
  3714.                             break;
  3715.                         break;
  3716.                     case '(':
  3717.                         /* Display 24 data lines */
  3718.                         debug(F110,"Wyse Escape","24 data lines",0);
  3719.                         if ( debses )
  3720.                             break;
  3721.                         settermstatus(TRUE);
  3722.                         break;
  3723.                     case ')':
  3724.                         /* Display 25 data lines */
  3725.                         debug(F110,"Wyse Escape","25 data lines",0);
  3726.                         if ( debses )
  3727.                             break;
  3728.                         settermstatus(FALSE);
  3729.                         break;
  3730.                     case '*':
  3731.                         /* Display 42 data lines */
  3732.                         debug(F110,"Wyse Escape","42 data lines",0);
  3733.                         if ( debses )
  3734.                             break;
  3735.                         settermstatus(TRUE);
  3736.                         break;
  3737.                     case '+':
  3738.                         /* Display 43 data lines */
  3739.                         debug(F110,"Wyse Escape","43 data lines",0);
  3740.                         if ( debses )
  3741.                             break;
  3742.                         settermstatus(FALSE);
  3743.                         break;
  3744.                     case ',':
  3745.                         /* Key repeat off */
  3746.                         debug(F110,"Wyse Escape","Key repeat off",0);
  3747.                         if ( debses )
  3748.                             break;
  3749.                         break;
  3750.                     case '-':
  3751.                         /* Key repeat on */
  3752.                         debug(F110,"Wyse Escape","Key repeat on",0);
  3753.                         if ( debses )
  3754.                             break;
  3755.                         break;
  3756.                     case '.':
  3757.                         /* Width change clear mode off */
  3758.                         debug(F110,"Wyse Escape","Width change clear mode off",0);
  3759.                         if ( debses )
  3760.                             break;
  3761.                         wy_widthclr = FALSE ;
  3762.                         break;
  3763.                     case '/':
  3764.                         /* Width change clear mode on */
  3765.                         debug(F110,"Wyse Escape","Width change clear mode on",0);
  3766.                         if ( debses )
  3767.                             break;
  3768.                         wy_widthclr = TRUE ;
  3769.                         break;
  3770.                     case '{':
  3771.                         /* Dim intensity on */
  3772.                         debug(F110,"Wyse Escape","Dim intensity on",0);
  3773.                         if ( debses )
  3774.                             break;
  3775.                         attrib.dim = TRUE ;
  3776.                         break;
  3777.                     case '|':
  3778.                         /* Dim intensity off */
  3779.                         debug(F110,"Wyse Escape","Dim intensity off",0);
  3780.                         if ( debses )
  3781.                             break;
  3782.                         attrib.dim = FALSE ;
  3783.                         break;
  3784.                     case '0':
  3785.                         /* Character attribute mode off */
  3786.                         debug(F110,"Wyse Escape","Character attribute mode off",0);
  3787.                         if ( debses )
  3788.                             break;
  3789.                         if ( attrmode & ATTR_CHAR_MODE )
  3790.                             attrmode ^= ATTR_CHAR_MODE ;
  3791.                         break;
  3792.                     case '1':
  3793.                         /* Character attribute mode on */
  3794.                         debug(F110,"Wyse Escape","Character attribute mode on",0);
  3795.                         if ( debses )
  3796.                             break;
  3797.                         if ( attrmode & ATTR_CHAR_MODE )
  3798.                             break;
  3799.                         attrmode ^= ATTR_CHAR_MODE ;
  3800.                         break;
  3801.                     case '2':
  3802.                         /* Page attribute mode on */
  3803.                         debug(F110,"Wyse Escape","Page attribute mode on",0);
  3804.                         if ( debses )
  3805.                             break;
  3806.                         attrmode = ATTR_PAGE_MODE ;
  3807.                         break;
  3808.                     case '3':
  3809.                         /* Line attribute mode on */
  3810.                         debug(F110,"Wyse Escape","Line attribute mode on",0);
  3811.                         if ( debses )
  3812.                             break;
  3813.                         attrmode = ATTR_LINE_MODE;
  3814.                         break;
  3815.                     case '4':
  3816.                         /* Received CR mode off */
  3817.                         debug(F110,"Wyse Escape","Received CR mode off",0);
  3818.                         if ( debses )
  3819.                             break;
  3820.                         tnlm = FALSE ;
  3821.                         break;
  3822.                     case '5':
  3823.                         /* Received CR mode on */
  3824.                         debug(F110,"Wyse Escape","Received CR mode on",0);
  3825.                         if ( debses )
  3826.                             break;
  3827.                         tnlm = TRUE ;
  3828.                         break;
  3829.                     case '6':
  3830.                         /* ACK mode off */
  3831.                         debug(F110,"Wyse Escape","ACK mode off",0);
  3832.                         if ( debses )
  3833.                             break;
  3834.                         break;
  3835.                     case '7':
  3836.                         /* ACK mode on */
  3837.                         debug(F110,"Wyse Escape","ACK mode on",0);
  3838.                         if ( debses )
  3839.                             break;
  3840.                         break;
  3841.                     case '8':
  3842.                         /* Select MODEM port for data communications */
  3843.                         debug(F110,"Wyse Escape","Select Modem port for data comm",0);
  3844.                         if ( debses )
  3845.                             break;
  3846.                         break;
  3847.                     case '9':
  3848.                         /* Select AUX port for data communications */
  3849.                         debug(F110,"Wyse Escape","Select AUX port for data comm",0);
  3850.                         if ( debses )
  3851.                             break;
  3852.                         break;
  3853.                     case ':':
  3854.                         /* Don't initialize tabs */
  3855.                         debug(F110,"Wyse Escape","Don't initialize tabs",0);
  3856.                         if ( debses )
  3857.                             break;
  3858.                         break;
  3859.                     case ';':
  3860.                         /* Initialize tabs */
  3861.                         debug(F110,"Wyse Escape","Initialize tabs",0);
  3862.                         if ( debses )
  3863.                             break;
  3864.                         break;
  3865.                     case '?':
  3866.                         /* Select 10x13 character cell - WY30 */
  3867.                         debug(F110,"Wyse Escape","10x3 character cell",0);
  3868.                         if ( debses )
  3869.                             break;
  3870.                         break;
  3871.                     case '@':
  3872.                         /* 325 or 160 - NumLock off */
  3873.                         debug(F110,"Wyse Escape","Numlock off",0);
  3874.                         if ( debses )
  3875.                             break;
  3876.                         break;
  3877.                     case 'A':
  3878.                         /* 325 or 160 - NumLock on */
  3879.                         debug(F110,"Wyse Escape","Numlock on",0);
  3880.                         if ( debses )
  3881.                             break;
  3882.                         break;
  3883.                     case 'B':
  3884.                         /* 325 or 160 - Scroll Lock off */
  3885.                         debug(F110,"Wyse Escape","Scroll Lock off",0);
  3886.                         if ( debses )
  3887.                             break;
  3888.                         break;
  3889.                     case 'C':
  3890.                         /* 325 or 160 - Scroll Lock on */
  3891.                         debug(F110,"Wyse Escape","Scroll Lock on",0);
  3892.                         if ( debses )
  3893.                             break;
  3894.                         break;
  3895.                     case 'F':
  3896.                         /* Economy 80-col mode off */
  3897.                         debug(F110,"Wyse Escape","Economy 80-col mode off",0);
  3898.                         if ( debses )
  3899.                             break;
  3900.                         break;
  3901.                     case 'G':
  3902.                         /* Economy 80-col mode on */
  3903.                         debug(F110,"Wyse Escape","Economy 80-col mode on",0);
  3904.                         if ( debses )
  3905.                             break;
  3906.                         break;
  3907.                     case 'H':
  3908.                         /* 325 or 160 - ASCII Key codes */
  3909.                         debug(F110,"Wyse Escape","ASCII Key codes",0);
  3910.                         if ( debses )
  3911.                             break;
  3912.                         break;
  3913.                     case 'I':
  3914.                         /* 325 or 160 - PC Scan codes */
  3915.                         debug(F110,"Wyse Escape","PC Scan codes",0);
  3916.                         if ( debses )
  3917.                             break;
  3918.                         break;
  3919.                     case 'J':
  3920.                         /* Don't save function key labels */
  3921.                         debug(F110,"Wyse Escape","Don't save function labels",0);
  3922.                         if ( debses )
  3923.                             break;
  3924.                         break;
  3925.                     case 'K':
  3926.                         /* Save function key labels */
  3927.                         debug(F110,"Wyse Escape","Save function labels",0);
  3928.                         if ( debses )
  3929.                             break;
  3930.                         break;
  3931.                     case 'L':
  3932.                         /* Margin bell off */
  3933.                         debug(F110,"Wyse Escape","Margin bell off",0);
  3934.                         if ( debses )
  3935.                             break;
  3936.                         marginbell = FALSE ;
  3937.                         break;
  3938.                     case 'M':
  3939.                         /* Margin bell on */
  3940.                         debug(F110,"Wyse Escape","Margin bell on",0);
  3941.                         if ( debses )
  3942.                             break;
  3943.                         marginbell = TRUE ;
  3944.                         break;
  3945.                     case 'N':
  3946.                         /* Automatic font loading off */
  3947.                         debug(F110,"Wyse Escape","Auto font loading off",0);
  3948.                         if ( debses )
  3949.                             break;
  3950.                         break;
  3951.                     case 'O':
  3952.                         /* Automatic font loading on */
  3953.                         debug(F110,"Wyse Escape","Auto font loading on",0);
  3954.                         if ( debses )
  3955.                             break;
  3956.                         break;
  3957.                     case 'P':
  3958.                         /* Screen saver off */
  3959.                         debug(F110,"Wyse Escape","Screen saver off",0);
  3960.                         if ( debses )
  3961.                             break;
  3962.                         break;
  3963.                     case 'Q':
  3964.                         /* Screen saver on */
  3965.                         debug(F110,"Wyse Escape","Screen saver on",0);
  3966.                         if ( debses )
  3967.                             break;
  3968.                         break;
  3969.                     case 'R':
  3970.                         /* Turn on nulls suppress */
  3971.                         debug(F110,"Wyse Escape","NUL suppress on",0);
  3972.                         if ( debses )
  3973.                             break;
  3974.                         wy_nullsuppress = TRUE ;
  3975.                         break;
  3976.                     case 'S':
  3977.                         /* Turn off nulls suppress */
  3978.                         debug(F110,"Wyse Escape","NUL suppress off",0);
  3979.                         if ( debses )
  3980.                             break;
  3981.                         wy_nullsuppress = FALSE ;
  3982.                         break;
  3983.                     case 'T':
  3984.                         /* Define CAPS LOCK key as CAPS LOCK */
  3985.                         debug(F110,"Wyse Escape","CapsLock is CapsLock",0);
  3986.                         if ( debses )
  3987.                             break;
  3988.                         break;
  3989.                     case 'U':
  3990.                         /* Define CAPS LOCK key as REV */
  3991.                         debug(F110,"Wyse Escape","CapsLock is REV",0);
  3992.                         if ( debses )
  3993.                             break;
  3994.                         break;
  3995.                     case 'V':
  3996.                         /* Define CAPS LOCK key as SHIFT */
  3997.                         debug(F110,"Wyse Escape","CapsLock is SHIFT",0);
  3998.                         if ( debses )
  3999.                             break;
  4000.                         break;
  4001.                     case 'x':
  4002.                         /* Turn off multiple page mode (default) WY30 */
  4003.                         debug(F110,"Wyse Escape","Multiple page mode off",0);
  4004.                         if ( debses )
  4005.                             break;
  4006.                         break;
  4007.                     case 'y':
  4008.                         /* Turn on multiple page mode WY30 */
  4009.                         debug(F110,"Wyse Escape","Multiple page mode on",0);
  4010.                         if ( debses )
  4011.                             break;
  4012.                         break;
  4013.                     case 'z':
  4014.                         /* Select 10x15 character cell WY30 */
  4015.                         debug(F110,"Wyse Escape","10x15 char cell",0);
  4016.                         if ( debses )
  4017.                             break;
  4018.                         break;
  4019.                     }
  4020.                 }
  4021.                 break;
  4022.             case 'f': {
  4023.                 /* Program and display computer message on label line */
  4024.                 /* Also known as the Status Line */
  4025.                 int width = VscrnGetWidth(VTERM);
  4026.                 int i = 0;
  4027.  
  4028.                 debug(F110,"Wyse Escape","Program and display computer message on label line",0);
  4029.                 if ( debses ) {
  4030.                     while ( i < width && wyinc() != CR ) {
  4031.                         i++;
  4032.                     }
  4033.                 }
  4034.                 else {
  4035.                     while ( i < width &&
  4036.                             (wy_labelmsg[i]=wyinc()) != CR ) {
  4037.                         i++;
  4038.                     }
  4039.                     wy_labelmsg[i] = NUL ;
  4040.                 }
  4041.                 while ( i < width )
  4042.                     wy_labelmsg[i++] = SP ;
  4043.                 wy_labelmsg[i]=NUL ;
  4044.                 if ( debses )
  4045.                     break;
  4046.                 setdecssdt(SSDT_HOST_WRITABLE);
  4047.                 if ( decssdt == SSDT_HOST_WRITABLE ) {
  4048.                     VscrnSetWidth(VSTATUS,VscrnGetWidth(VTERM));
  4049.                     VscrnWrtCharStrAtt( VSTATUS, wy_labelmsg,
  4050.                                         strlen(wy_labelmsg),
  4051.                                         1, 1, &colorstatus ) ;
  4052.                 }
  4053.                 break;
  4054.             }
  4055.             case 'g':
  4056.                 /* Turn on shifted and unshifted label line display */
  4057.                 /* (enhanced mode) WY30 */
  4058.                 debug(F110,"Wyse Escape","Label Line Display on",0);
  4059.                 if ( debses )
  4060.                     break;
  4061.                 setdecssdt(SSDT_HOST_WRITABLE);
  4062.                 break;
  4063.             case 'h':
  4064.                 /* Turn off shifted and unshifted label line display */
  4065.                 /* (enhanced mode) WY30 */
  4066.                 debug(F110,"Wyse Escape","Label Line Display off",0);
  4067.                 if ( debses )
  4068.                     break;
  4069.                 setdecssdt(SSDT_INDICATOR);
  4070.                 break;
  4071.             case 'i':
  4072.                 /* Moves the cursor to the next tab stop on the right.    */
  4073.                 debug(F110,"Wyse Escape","Horizontal Tab",0);
  4074.                 if ( debses )
  4075.                     break;
  4076.                 wyse_tab();
  4077.                 break;
  4078.             case 'j':
  4079.                 /* Moves the cursor up one row and begins scrolling at    */
  4080.                 /* top row.                                               */
  4081.                 debug(F110,"Wyse Escape","Cursor Up",0);
  4082.                 if ( debses )
  4083.                     break;
  4084.                 cursorup(0) ;
  4085.                 break;
  4086.             case 'k':
  4087.                 /* Turns the local edit submode on; duplex off */
  4088.                 /* Not the same as ECHO mode */
  4089.                 debug(F110,"Wyse Escape","Local Edit mode on; Duplex off",0);
  4090.                 break;
  4091.             case 'l':
  4092.                 /* Turns the duplex edit submode on; local off */
  4093.                 /* Not the same as ECHO mode */
  4094.                 debug(F110,"Wyse Escape","Local Edit mode off; Duplex on",0);
  4095.                 break;
  4096.             case 'm':
  4097.                 debug(F110,"Wyse Escape","m",0);
  4098.                 break;
  4099.             case 'n':
  4100.                 /* Turn on screen display (WY30) Enhanced Mode */
  4101.                 debug(F110,"Wyse Escape","Screen Display on",0);
  4102.                 if ( debses )
  4103.                     break;
  4104.                 if ( wy_enhanced )
  4105.                     screenon = TRUE ;
  4106.                 break;
  4107.             case 'o':
  4108.                 /* Turn off screen display (WY30) Enhanced Mode */
  4109.                 debug(F110,"Wyse Escape","Screen Display off",0);
  4110.                 if ( debses )
  4111.                     break;
  4112.                 if ( wy_enhanced )
  4113.                     screenon = FALSE ;
  4114.                 break;
  4115.             case 'p':
  4116.                 /* Sends all characters unformatted to the auxiliary port. */
  4117.                 /* Attributes codes are sent as spaces.  Row-end sequences */
  4118.                 /* are not sent.  The action is the same as ESC L.         */
  4119.                 debug(F110,"Wyse Escape","Sends all chars unformatted to AUX",0);
  4120.                 break;
  4121.             case 'q':
  4122.                 /* Turns the insert submode on; replace off */
  4123.                 debug(F110,"Wyse Escape","Insert submode on; replace off",0);
  4124.                 if ( debses )
  4125.                     break;
  4126.                 insertmode = TRUE ;
  4127.                 break;
  4128.             case 'r':
  4129.                 /* Turns the insert submode off; replace on */
  4130.                 debug(F110,"Wyse Escape","Insert submode off; replace on",0);
  4131.                 if ( debses )
  4132.                     break;
  4133.                 insertmode = FALSE ;
  4134.                 break;
  4135.             case 's': {
  4136.                 /* Sends a message (entire block) */
  4137.                 int x,y,ch,
  4138.                 w=VscrnGetWidth(VTERM),
  4139.                 h=VscrnGetHeight(VTERM)-(tt_status[VTERM]?1:0),
  4140.                 xs=-1,
  4141.                 ys=-1,
  4142.                 xe=w-1,
  4143.                 ye=h-1,
  4144.                 fs=0 ;
  4145.  
  4146.                 debug(F110,"Wyse Escape","Send a message (entire block)",0);
  4147.                 if ( debses )
  4148.                     break;
  4149.  
  4150.                 /* First figure out if we have markers, STX then ETX */
  4151.                 for ( y=0;y<h;y++ )
  4152.                     for ( x=0;x<w;x++ ) {
  4153.                         ch = VscrnGetCell( VTERM, x, y )->c ;
  4154.                         if ( ch == STX && xs < 0 && ys < 0 ) {
  4155.                             xs = x+1 ;
  4156.                             ys = y ;
  4157.                         }
  4158.                         else if ( ch == ETX && xs >= 0 && ys >= 0 ) {
  4159.                             xe = x-1 ;
  4160.                             ye = y ;
  4161.                             break;
  4162.                         }
  4163.                     }
  4164.                 if ( xs < 0 || ys < 0 ) {
  4165.                     xs = 0 ;
  4166.                     ys = 0 ;
  4167.                 }
  4168.  
  4169.                 /* Now send the data */
  4170.                 for ( y=ys;y<=ye; y++ ) {
  4171.                     for ( x=(y==ys)?xs:0 ; x <= (y==ye?xe:w-1) ; x++ ) {
  4172.                         if ( !VscrnGetVtCharAttr(VTERM, x, y).unerasable ) {
  4173.                             if ( fs ) {
  4174.                                 sendchars("\x1b(",2);
  4175.                                 fs = 0;
  4176.                             }
  4177.                         }
  4178.                         else if ( !fs ) {
  4179.                             sendchars("\x1b)",2);
  4180.                             fs = 1 ;
  4181.                         }
  4182.                         ch = VscrnGetCell( VTERM, x, y )->c;
  4183.                         if ( ch || !wy_nullsuppress ) {
  4184.                             if ( tt_senddata ) {
  4185.                                 unsigned char * bytes;
  4186.                                 int nbytes;
  4187.                                 if ( isunicode() )
  4188.                                     nbytes = utorxlat(ch,&bytes);
  4189.                                 else
  4190.                                     nbytes = utorxlat(ch,&bytes);
  4191.                                 while ( nbytes-- > 0 )
  4192.                                     sendchar(*bytes++) ;
  4193.                             } else
  4194.                                 sendchar(SP);
  4195.                         }
  4196.                     }
  4197.                     if ( y < ye ) {
  4198.                         switch ( wy_blockend ) {
  4199.                         case EOB_CRLF_ETX:
  4200.                             sendchar(CR);
  4201.                             sendchar(LF);
  4202.                             break;
  4203.                         case EOB_US_CR:
  4204.                             sendchar(US);
  4205.                             break;
  4206.                         }
  4207.                     }
  4208.                 }
  4209.                 switch ( wy_blockend ) {
  4210.                 case EOB_CRLF_ETX:
  4211.                     sendchar(ETX);
  4212.                     break;
  4213.                 case EOB_US_CR:
  4214.                     sendchar(CR);
  4215.                     break;
  4216.                 }
  4217.                 break;
  4218.             }
  4219.             case 't':
  4220.                 /* Erases all (unprotected) characters from the current   */
  4221.                 /* cursor location to the end of the row and replaces     */
  4222.                 /* them with nulls.                                       */
  4223.                 debug(F110,"Wyse Escape","Erase all unprotected chars from cursor to EOL with NUL",0);
  4224.  
  4225.                 if ( debses )
  4226.                     break;
  4227.                 if (protect)
  4228.                     selclrtoeoln( VTERM, NUL ) ;
  4229.                 else
  4230.                     clrtoeoln( VTERM, NUL ) ;
  4231.                 break;
  4232.             case 'u':
  4233.                 /* Turns the monitor submode off.  See ESC X.             */
  4234.                 debug(F110,"Wyse Escape","Monitor mode off",0);
  4235.                 if ( !wy_monitor )
  4236.                     break;
  4237.                 setdebses(FALSE);
  4238.                 wy_monitor = FALSE ;
  4239.                 break;
  4240.             case 'v':
  4241.                 /* Turn on autopage mode */
  4242.                 debug(F110,"Wyse Escape","Autopage mode on",0);
  4243.                 if ( debses )
  4244.                     break;
  4245.                 wy_autopage = TRUE ;
  4246.                 break;
  4247.             case 'w':
  4248.                 if ( ISWY30(tt_type_mode) || ISWY60(tt_type_mode) ) {
  4249.                     int n = wyinc() ;
  4250.  
  4251.                     switch ( n ) {
  4252.                     case '0':
  4253.                         /* Display page 0 */
  4254.                         debug(F110,"Wyse Escape","Display page 0",0);
  4255.                         break;
  4256.                     case '1':
  4257.                         /* Display page 1 */
  4258.                         debug(F110,"Wyse Escape","Display page 1",0);
  4259.                         break;
  4260.                     case '2':
  4261.                         /* Display page 2 (economy mode only) */
  4262.                         debug(F110,"Wyse Escape","Display page 2",0);
  4263.                         break;
  4264.                     case 'B':
  4265.                         /* Display previous page */
  4266.                         debug(F110,"Wyse Escape","Display previous page",0);
  4267.                         break;
  4268.                     case 'C':
  4269.                         /* Display next page */
  4270.                         debug(F110,"Wyse Escape","Display next page",0);
  4271.                         break;
  4272.                     case 'E':
  4273.                         /* Roll window up in page */
  4274.                         debug(F110,"Wyse Escape","Roll window up in page",0);
  4275.                         break;
  4276.                     case 'F':
  4277.                         /* Roll window down in page */
  4278.                         debug(F110,"Wyse Escape","Roll window down in page",0);
  4279.                         break;
  4280.                     case 'G':
  4281.                         /* Divide memory into pages (1xlines)    */
  4282.                         /* Length of page equal to the number of */
  4283.                         /* data lines (default)                  */
  4284.                         debug(F110,"Wyse Escape","Divide memory into pages (1x)",0);
  4285.                         break;
  4286.                     case 'H':
  4287.                         /* Divide memory into pages (2xlines)    */
  4288.                         /* Length of page equal to double the    */
  4289.                         /* number of data lines                  */
  4290.                         debug(F110,"Wyse Escape","Divide memory into pages (2x)",0);
  4291.                         break;
  4292.                     case 'I':
  4293.                         /* Divide memory into pages (4xlines)    */
  4294.                         /* Length of page equal to Four times    */
  4295.                         /* the number of data lines              */
  4296.                         debug(F110,"Wyse Escape","Divide memory into pages (4x)",0);
  4297.                         break;
  4298.                     case 'J':
  4299.                         /* Divide memory into pages                   */
  4300.                         /* One page contains the number of data lines */
  4301.                         /* The other contains the rest of the memory  */
  4302.                         debug(F110,"Wyse Escape","Divide memory into pages (split)",0);
  4303.                         break;
  4304.                     case '@':{
  4305.                         /* page line col */
  4306.                         /* Address cursor in specific 80-col page */
  4307.                         debug(F110,"Wyse Escape","Address cursor page line col",0);
  4308.                         z = wyinc();
  4309.                         y = wyinc() ;
  4310.                         x = wyinc() ;
  4311.  
  4312.                         if ( debses )
  4313.                             break;
  4314.                         if ( /* VscrnGetWidth(VTERM) == 80 && */ x > 31 && y > 31 )
  4315.                             lgotoxy(VTERM, x-31, y-31 ) ;
  4316.                         break;
  4317.                     }
  4318.                     case '`':
  4319.                         /* Read 80-col page number and cursor address */
  4320.                         debug(F110,"Wyse Escape","Report cursor page line col",0);
  4321.                         if ( debses )
  4322.                             break;
  4323.                         if ( 1 /* VscrnGetWidth(VTERM) == 80 */ ) {
  4324.                             char buf[4] ;
  4325.                             buf[0] = '0' ;
  4326.                             buf[1] = (char)(wherey[VTERM]+31) ;
  4327.                             buf[2] = (char)(wherex[VTERM]+31) ;
  4328.                             buf[3] = NUL ;
  4329.                             sendchars(buf,3) ;
  4330.                         }
  4331.                         break;
  4332.                     }
  4333.                 }
  4334.                 else {  /* Wyse 50 */
  4335.                     /* Turn off autopage mode */
  4336.                     debug(F110,"Wyse Escape","Autopage off",0);
  4337.                     if ( debses )
  4338.                         break;
  4339.                     wy_autopage = FALSE ;
  4340.                 }
  4341.                 break;
  4342.             case 'x':
  4343.                 /* Changes the screen display format.  The sequences are:   */
  4344.                 /*    ESC x 0 for a full screen, 24 rows by 80 or 132 cols. */
  4345.                 /*    ESC x 1 HSR for a horizontal split screen. (two page max) */
  4346.                 /*    ESC x 3 HSR for a horizontal split screen (wy60)      */
  4347.                 /* where                                                    */
  4348.                 /*    HSR = row code for the row number 2 to 24 on which    */
  4349.                 /*          the lower text segment starts.                  */
  4350.                 /* these calls clear the pages.                             */
  4351.                 {
  4352.                     int n = wyinc() ;
  4353.  
  4354.                     switch ( n ) {
  4355.                     case '0':
  4356.                         /* Redefine screen as one window and clear pages */
  4357.                         debug(F110,"Wyse Escape","Redefine screen as 1 window and clear pages",0);
  4358.                         if ( debses )
  4359.                             break;
  4360.                         writeprotect = FALSE ;
  4361.                         protect = FALSE ;
  4362.                         attrib.unerasable = FALSE ;
  4363.                         clrscreen(VTERM, SP) ;
  4364.                         lgotoxy(VTERM,1,1);       /* and home the cursor */
  4365.                         break;
  4366.                     case '1':
  4367.                         /* line */
  4368.                         /* Split screen and clear pages (two max) */
  4369.                         debug(F110,"Wyse Escape","Split screen and clear pages",0);
  4370.                         if ( debses )
  4371.                             break;
  4372.                         clrscreen( VTERM, SP ) ;
  4373.                         lgotoxy(VTERM,1,1);       /* and home the cursor */
  4374.                         /* if we support this, send ACK to host */
  4375.                         break;
  4376.                     case '3':
  4377.                         /* line */
  4378.                         /* Split screen and clear pages - WY60 */
  4379.                         debug(F110,"Wyse Escape","Split screen and clear pages",0);
  4380.                         if ( debses )
  4381.                             break;
  4382.                         break;
  4383.                     case '@':
  4384.                         /* Redefine screen as one window - no clear - WY60 */
  4385.                         debug(F110,"Wyse Escape","Redefine screen as one window - no clear",0);
  4386.                         if ( debses )
  4387.                             break;
  4388.                         break;
  4389.                     case 'A':
  4390.                         /* line */
  4391.                         /* Split screen (two max) - WY60 */
  4392.                         debug(F110,"Wyse Escape","Split screen",0);
  4393.                         if ( debses )
  4394.                             break;
  4395.                         break;
  4396.                     case 'C':
  4397.                         /* line */
  4398.                         /* Split screen - WY60 */
  4399.                         debug(F110,"Wyse Escape","Split Screen",0);
  4400.                         if ( debses )
  4401.                             break;
  4402.                         break;
  4403.                     case 'P':
  4404.                         /* Lower Horizontal Split - Wy60 */
  4405.                         debug(F110,"Wyse Escape","Lower horizontal split",0);
  4406.                         if ( debses )
  4407.                             break;
  4408.                         break;
  4409.                     case 'R':
  4410.                         /* Raise Horizontal Split - WY60 */
  4411.                         debug(F110,"Wyse Escape","Raise horizontal split",0);
  4412.                         if ( debses )
  4413.                             break;
  4414.                         break;
  4415.                     }
  4416.                 }
  4417.                 break;
  4418.             case 'y':
  4419.                 /* Erases all characters from the current cursor location   */
  4420.                 /* to the end of the active segment and replaces them with  */
  4421.                 /* nulls. (unprotected)                                     */
  4422.                 debug(F110,"Wyse Escape","Erase all chars from cursor to end of segment with NUL",0);
  4423.                 if ( debses )
  4424.                     break;
  4425.                 if ( protect )
  4426.                     selclreoscr_escape( VTERM, NUL ) ;
  4427.                 else
  4428.                     clreoscr_escape( VTERM, NUL ) ;
  4429.                 break;
  4430.             case 'z':  {
  4431.                 /* Enters a message into a selected function key label field */
  4432.                 /* or programs a user-defined sequence for a function key    */
  4433.                 /* (maximum of eight label fields, shiftable to 16 for an    */
  4434.                 /* 80-column screen; maximum of 16 label fields, shiftable   */
  4435.                 /* to 32 for a 132-column screen.  The message format is:    */
  4436.                 /*   ESC z n aaaa CR   where:                                */
  4437.                 /*   n = field code                                          */
  4438.                 /*  aaaa = a character string of up to eight characters for  */
  4439.                 /*         an 80-column screen or up to seven characters for */
  4440.                 /*         an 132-column screen.                             */
  4441.                 /*   ESC z n CR clears a particular function key label       */
  4442.                 /*   ESC z DEL turns off the shifted function key labeling   */
  4443.                 /*         line.                                             */
  4444.                 /* The function key program format is:                       */
  4445.                 /*   ESC z value SEQ DEL  where:                             */
  4446.                 /*   value = the default value code                          */
  4447.                 /*   SEQ   = the program sequence up to eight bytes          */
  4448.  
  4449.                 /* WY60 adds: */
  4450.                 /* ESC z ( text CR  Program/display unshifted label line     */
  4451.                 /* ESC z ) text CR  Program shifted label line               */
  4452.                 /* ESC z ( CR       Clear unshifted label line               */
  4453.                 /* ESC z ) CR       Clear shifted label line                 */
  4454.                 /* ESC z P CR       Display shifted label line               */
  4455.                 char keydef[256] = "" ;
  4456.                 int key = wyinc() ;
  4457.                 int i = 0 ;
  4458.  
  4459.                 if ( key == DEL ) {
  4460.                         /* Turn off shifted function key labeling */
  4461.                     debug(F110,"Wyse Escape","Turn off shifted function key labeling",0);
  4462.                     break ;
  4463.                 }
  4464.  
  4465.                 if ( !((key >= '@' && key <= 'O') ||
  4466.                         (key >= '`' && key <= 'o') ||
  4467.                         (key >= '0' && key <= '7') ||
  4468.                         (key >= 'P' && key <= '_'))) {
  4469.                     /* we don't support anything other than */
  4470.                     /* key programming yet. */
  4471.                     debug(F110,"Wyse Escape","Program key definition or label",0);
  4472.                     if ( debses )
  4473.                         break;
  4474.                     while ( (keydef[i]=wyinc()) != DEL &&
  4475.                                 (keydef[i] != CR))
  4476.                         i++;
  4477.                     keydef[i] = NUL ;
  4478.  
  4479.                     break;
  4480.                 }
  4481.                 else if ( ISWY60(tt_type_mode) &&
  4482.                           key == '(' ) {
  4483.                     /* ESC z ( text CR  Program/display unshifted label line */
  4484.                     /* ESC z ( CR       Clear unshifted label line           */
  4485.                     int i = 0;
  4486.  
  4487.                     debug(F110,"Wyse Escape","Program/display/clear unshifted label line",0);
  4488.  
  4489.                     if ( debses ) {
  4490.                         while ( i < MAXTERMCOL &&
  4491.                                 wyinc() != CR ) {
  4492.                             i++;
  4493.                         }
  4494.                     }
  4495.                     else {
  4496.                         while ( i < MAXTERMCOL &&
  4497.                                 (wy_labelline[i]=wyinc()) != CR ) {
  4498.                             i++;
  4499.                         }
  4500.                         wy_labelline[i] = NUL ;
  4501.                     }
  4502.                 }
  4503.                 else if ( ISWY60(tt_type_mode) &&
  4504.                           key == ')' ) {
  4505.                     /* ESC z ) text CR  Program shifted label line */
  4506.                     /* ESC z ) CR       Clear shifted label line   */
  4507.                     int i = 0;
  4508.  
  4509.                     debug(F110,"Wyse Escape","Program/display/clear shifted label line",0);
  4510.                     if ( debses ) {
  4511.                         while ( i < MAXTERMCOL &&
  4512.                                 wyinc() != CR ) {
  4513.                             i++;
  4514.                         }
  4515.                     }
  4516.                     else {
  4517.                         while ( i < MAXTERMCOL &&
  4518.                                 (wy_shiftlabelline[i]=wyinc()) != CR ) {
  4519.                             i++;
  4520.                         }
  4521.                         wy_shiftlabelline[i] = NUL ;
  4522.                     }
  4523.                 }
  4524.                 else if ( ISWY60(tt_type_mode) &&
  4525.                           key == 'P' && wyinc() == CR ) {
  4526.                     /* ESC z P CR       Display shifted label line */
  4527.                     debug(F110,"Wyse Escape","Display Shifted label line",0);
  4528.                     if ( debses )
  4529.                         break;
  4530.                 }
  4531.                 else {
  4532.                     int label = ( (key >= '0' && key <= '7') ||
  4533.                               (key >= 'P' && key <= '_') );
  4534.  
  4535.                     while ( i < 255 &&
  4536.                             (((keydef[i]=wyinc()) != DEL) || label) &&
  4537.                             ((keydef[i] != CR) || !label) )
  4538.                         i++;
  4539.                     keydef[i] = NUL ;
  4540.  
  4541.                     if ( debses ) {
  4542.                         debug(F110,"Wyse Escape","Program key or label",0);
  4543.                         break;
  4544.                     }
  4545.  
  4546.                     if ( keydef[0] == '~' ) {
  4547.                         /* we only allow redefinition of function keys */
  4548.                         debug(F110,"Wyse Escape","Program key or label tilde",0);
  4549.                     }
  4550.                     else if ( label ) {
  4551.                         /* Function key labels */
  4552.                         ckstrncpy( fkeylabel[key-'0'], keydef, 32 );
  4553.                         debug(F111,"Wyse [Label]",fkeylabel[key-'0'],key-'0');
  4554.                     }
  4555.                     else {
  4556.                         int keyi=0;
  4557.                         if ( key >= '@' && key <= 'O' ) {
  4558.                             keyi = key-'@';
  4559.                         }
  4560.                         else if ( key >= '`' && key <= 'o' ) {
  4561.                             keyi = key-'`'+(K_WYSF01-K_WYF01);
  4562.                         }
  4563. #ifndef NOKVERBS
  4564.                         else switch (key) {
  4565.                         case '"':       /* Backspace */
  4566.                             keyi = K_WYBS-K_WYF01 ;
  4567.                             break;
  4568.                         case '}':       /* Clear Line */
  4569.                             keyi = K_WYCLRLN-K_WYF01;
  4570.                             break;
  4571.                         case 'z':       /* Shift Clear Line - Clear Screen */
  4572.                             keyi = K_WYSCLRLN-K_WYF01;
  4573.                             break;
  4574.                             /* Clear Page */
  4575.                             /* Shift Clear Page */
  4576.                         case '5':       /* Del Char */
  4577.                             keyi = K_WYDELCHAR-K_WYF01;
  4578.                             break;
  4579.                         case '6':       /* Del Line */
  4580.                             keyi = K_WYDELLN-K_WYF01;
  4581.                             break;
  4582.                         case 's':       /* Enter */
  4583.                             keyi = K_WYENTER-K_WYF01;
  4584.                             break;
  4585.                         case SP:        /* Escape */
  4586.                             keyi = K_WYESC-K_WYF01;
  4587.                             break;
  4588.                         case '*':       /* Home */
  4589.                             keyi = K_WYHOME-K_WYF01;
  4590.                             break;
  4591.                         case '/':       /* Shift Home */
  4592.                             keyi = K_WYSHOME-K_WYF01;
  4593.                             break;
  4594.                         case '8':       /* Shift Replace (Insert) */
  4595.                             keyi = K_WYINSERT-K_WYF01;
  4596.                             break;
  4597.                         case 'q':       /* Insert Char */
  4598.                             keyi = K_WYINSCHAR-K_WYF01;
  4599.                             break;
  4600.                         case 'p':       /* Insert Line */
  4601.                             keyi = K_WYINSLN-K_WYF01;
  4602.                             break;
  4603.                         case 'r':       /* Page Next */
  4604.                             keyi = K_WYPGNEXT-K_WYF01;
  4605.                             break;
  4606.                         case 'w':       /* Page Prev */
  4607.                             keyi = K_WYPGPREV-K_WYF01;
  4608.                             break;
  4609.                         case '7':       /* Replace */
  4610.                             keyi = K_WYREPLACE-K_WYF01;
  4611.                             break;
  4612.                         case '$':       /* Return */
  4613.                             keyi = K_WYRETURN-K_WYF01;
  4614.                             break;
  4615.                         case '!':       /* Tab */
  4616.                             keyi = K_WYTAB-K_WYF01;
  4617.                             break;
  4618.                         case '&':       /* Shift Tab */
  4619.                             keyi = K_WYSTAB-K_WYF01;
  4620.                             break;
  4621.                         case 'R':       /* Print Screen */
  4622.                             keyi = K_WYPRTSCN-K_WYF01;
  4623.                             break;
  4624.                         case '%':       /* Shift Esc */
  4625.                             keyi = K_WYSESC-K_WYF01;
  4626.                             break;
  4627.                         case '\'':      /* Shift Backspace */
  4628.                             keyi = K_WYSBS-K_WYF01;
  4629.                             break;
  4630.                         case '4':       /* Shift Enter */
  4631.                             keyi = K_WYSENTER-K_WYF01;
  4632.                             break;
  4633.                         case ')':       /* Shift Return */
  4634.                             keyi = K_WYSRETURN-K_WYF01;
  4635.                             break;
  4636.                         case '+':       /* Up arrow */
  4637.                             keyi = K_WYUPARR-K_WYF01;
  4638.                             break;
  4639.                         case ',':       /* Dn arrow */
  4640.                             keyi = K_WYDNARR-K_WYF01;
  4641.                             break;
  4642.                         case '-':       /* Left arrow */
  4643.                             keyi = K_WYLFARR-K_WYF01;
  4644.                             break;
  4645.                         case '.':       /* Right arrow */
  4646.                             keyi = K_WYRTARR-K_WYF01;
  4647.                             break;
  4648.                         case '0':       /* Shift Up arrow */
  4649.                             keyi = K_WYSUPARR-K_WYF01;
  4650.                             break;
  4651.                         case '1':       /* Shift Dn arrow */
  4652.                             keyi = K_WYSDNARR-K_WYF01;
  4653.                             break;
  4654.                         case '2':       /* Shift Left arrow */
  4655.                             keyi = K_WYSLFARR-K_WYF01;
  4656.                             break;
  4657.                         case '3':       /* Shift Right arrow */
  4658.                             keyi = K_WYSRTARR-K_WYF01;
  4659.                             break;
  4660.                         case 'u':       /* Send */
  4661.                             keyi = K_WYSEND-K_WYF01;
  4662.                             break;
  4663.                         case 't':       /* Shift Send */
  4664.                             keyi = K_WYSSEND-K_WYF01;
  4665.                             break;
  4666.                         case 'Q':       /* F17 */
  4667.                             keyi = K_WYF17-K_WYF01;
  4668.                             break;
  4669.                         case 'W':       /* Shift F17 */
  4670.                             keyi = K_WYSF17-K_WYF01;
  4671.                             break;
  4672.                         case 'S':       /* F18 */
  4673.                             keyi = K_WYF18-K_WYF01;
  4674.                             break;
  4675.                         case 'Y':       /* Shift F18 */
  4676.                             keyi = K_WYSF18-K_WYF01;
  4677.                             break;
  4678.                         case 'T':       /* F19 */
  4679.                             keyi = K_WYF19-K_WYF01;
  4680.                             break;
  4681.                         case 'Z':       /* Shift F19 */
  4682.                             keyi = K_WYSF19-K_WYF01;
  4683.                             break;
  4684.                         case 'P':       /* F20 */
  4685.                             keyi = K_WYF20-K_WYF01;
  4686.                             break;
  4687.                         case 'V':       /* Shift F20 */
  4688.                             keyi = K_WYSF20-K_WYF01;
  4689.                             break;
  4690.  
  4691.                         case '#':       /* Del */
  4692.                         case '(':       /* Shift Del */
  4693.                         case 'X':       /* Shift Print Screen */
  4694.                         case ':':       /* PgUp */
  4695.                         case ';':       /* Shift PgUp */
  4696.                         case '\\':      /* End */
  4697.                         case ']':       /* Shift End */
  4698.                         default:
  4699.                             debug(F111,"Wyse (ESC z)","key",key);
  4700.                             break;
  4701.                         }
  4702. #endif /* NOKVERBS */
  4703. #ifndef NOSETKEY
  4704.                         if ( keyi >= 0 ) {
  4705.                             if ( udkfkeys[keyi] ){
  4706.                                 free( udkfkeys[keyi] ) ;
  4707.                                 udkfkeys[keyi]=NULL;
  4708.                             }
  4709.                             if ( strlen(keydef) ) {
  4710.                                 char buf[80];
  4711.                                 udkfkeys[keyi] = strdup( keydef ) ;
  4712.                                 sprintf(buf,"Wyse [Define Key]=%d",keyi);
  4713.                                 hexdump(buf,keydef,strlen(keydef));
  4714.                             } else {
  4715.                                 udkfkeys[keyi] = wysedefkey( keyi );
  4716.                             }
  4717.                         }
  4718. #endif /* NOSETKEY */
  4719.                     }
  4720.                 }
  4721.                 break;
  4722.             }
  4723.             case '{':
  4724.                 /* Moves the cursor to the home position of the text         */
  4725.                 /* segment.                                                  */
  4726.                 debug(F110,"Wyse Escape","Home cursor in active segment",0);
  4727.                 if ( debses )
  4728.                     break;
  4729.                 lgotoxy(VTERM,1,1) ;
  4730.                 break;
  4731.             case '|': {
  4732.                 int n = wyinc() ;
  4733.  
  4734.                 switch ( n ) {
  4735.                 case '0':
  4736.                     /* Redefine screen as one window and clear pages */
  4737.                     debug(F110,"Wyse Escape","Redefine screen as 1 window and clear pages",0);
  4738.                     if ( debses )
  4739.                         break;
  4740.                     if ( wy_enhanced ) {
  4741.                         writeprotect = FALSE ;
  4742.                         protect = FALSE ;
  4743.                         attrib.unerasable = FALSE ;
  4744.                         clrscreen(VTERM, SP) ;
  4745.                         lgotoxy(VTERM,1,1);       /* and home the cursor */
  4746.                     }
  4747.                     break;
  4748.                 case '1': {
  4749.                     /* Split screen horizontally and clear screen */
  4750.                     int line = wyinc();
  4751.  
  4752.                     debug(F110,"Wyse Escape","Split screen horizontally and clear screen",0);
  4753.                     if ( debses )
  4754.                         break;
  4755.                     if ( wy_enhanced ) {
  4756.                         clrscreen( VTERM, SP ) ;
  4757.                         lgotoxy(VTERM,1,1);       /* and home the cursor */
  4758.                         /* if we support this, send ACK to host */
  4759.                     }
  4760.                     break;
  4761.                 }
  4762.                 }
  4763.                 break;
  4764.             }
  4765.             case '}':
  4766.                 /* Activates text segment 1 (lower window) */
  4767.                 debug(F110,"Wyse Escape","Activate text segment 1",0);
  4768.                 break;
  4769.             case '~':
  4770.                 if ( ISWY60(tt_type_mode) || ISWY60(tt_type) )
  4771.                 {
  4772.                     int n = wyinc() ;
  4773.                     switch ( n ) {
  4774.                     case SP:
  4775.                         /* Enhanced mode off */
  4776.                         debug(F110,"Wyse Escape","Enhanced Mode Off",0);
  4777.                         if ( debses )
  4778.                             break;
  4779.                         wy_enhanced = FALSE ;
  4780.                         break;
  4781.                     case '!':
  4782.                         /* Enhanced mode on */
  4783.                         debug(F110,"Wyse Escape","Enhanced Mode On",0);
  4784.                         if ( debses )
  4785.                             break;
  4786.                         wy_enhanced = TRUE ;
  4787.                         break;
  4788.                     case '.':
  4789.                         /* Wyseword mode off */
  4790.                         debug(F110,"Wyse Escape","Wyseword Mode Off",0);
  4791.                         if ( debses )
  4792.                             break;
  4793.                         break;
  4794.                     case '/':
  4795.                         /* Wyseword mode on */
  4796.                         debug(F110,"Wyse Escape","Wyseword Mode On",0);
  4797.                         if ( debses )
  4798.                             break;
  4799.                         break;
  4800.                     case '2':
  4801.                         /* Application key mode off */
  4802.                         debug(F110,"Wyse Escape","Application Key Mode Off",0);
  4803.                         if ( debses )
  4804.                             break;
  4805.                         wy_keymode = FALSE ;
  4806.                         break;
  4807.                     case '3':
  4808.                         /* Application key mode on */
  4809.                         debug(F110,"Wyse Escape","Application Key Mode On",0);
  4810.                         if ( debses )
  4811.                             break;
  4812.                         wy_keymode = TRUE ;
  4813.                         break;
  4814.                     case '"':
  4815.                         /* WY50, WY50+, WY100 mode */
  4816.                         debug(F110,"Wyse Escape","Terminal Type WY30,50,50+,100",0);
  4817.                         if ( debses )
  4818.                             break;
  4819. #ifdef PCTERM
  4820.                         setpcterm(FALSE);
  4821. #endif /* PCTERM */
  4822.                         if ( ISWY30(tt_type) )
  4823.                             tt_type_mode = TT_WY30 ;
  4824.                         else
  4825.                             tt_type_mode = TT_WY50 ;
  4826.                         ipadl25();
  4827.                         break;
  4828.                     case '#':
  4829.                         /* TVI 910+ mode */
  4830.                         debug(F110,"Wyse Escape","Terminal Type TVI910+",0);
  4831.                         if ( debses )
  4832.                             break;
  4833. #ifdef PCTERM
  4834.                         setpcterm(FALSE);
  4835. #endif /* PCTERM */
  4836.                         tt_type_mode = TT_TVI910 ;
  4837.                         ipadl25();
  4838.                         break;
  4839.                     case '$':
  4840.                         /* TVI 925 mode */
  4841.                         debug(F110,"Wyse Escape","Terminal Type TVI925",0);
  4842.                         if ( debses )
  4843.                             break;
  4844. #ifdef PCTERM
  4845.                         setpcterm(FALSE);
  4846. #endif /* PCTERM */
  4847.                         tt_type_mode = TT_TVI925 ;
  4848.                         ipadl25();
  4849.                         break;
  4850.                     case '%':
  4851.                         /* ADDS VP A2 mode */
  4852.                         debug(F110,"Wyse Escape","Terminal Type ADDS VP A2",0);
  4853.                         if ( debses )
  4854.                             break;
  4855.                         break;
  4856.                     case '&':
  4857.                         /* HZ 1500 mode */
  4858.                         debug(F110,"Wyse Escape","Terminal Type HZ1500",0);
  4859.                         if ( debses )
  4860.                             break;
  4861. #ifdef PCTERM
  4862.                         setpcterm(FALSE);
  4863. #endif /* PCTERM */
  4864.                         tt_type_mode = TT_HZL1500 ;
  4865.                         ipadl25();
  4866.                         break;
  4867.                     case '\'':
  4868.                         /* TVI 912/920 mode */
  4869.                         debug(F110,"Wyse Escape","Terminal Type TVI912/920",0);
  4870.                         if ( debses )
  4871.                             break;
  4872.                         break;
  4873.                     case '(':
  4874.                         /* TVI 950 mode */
  4875.                         debug(F110,"Wyse Escape","Terminal Type TVI950",0);
  4876.                         if ( debses )
  4877.                             break;
  4878. #ifdef PCTERM
  4879.                         setpcterm(FALSE);
  4880. #endif /* PCTERM */
  4881.                         tt_type_mode = TT_TVI950 ;
  4882.                         ipadl25();
  4883.                         break;
  4884.                     case ')':
  4885.                         /* DG200 mode */
  4886.                         debug(F110,"Wyse Escape","Terminal Type DG200",0);
  4887.                         if ( debses )
  4888.                             break;
  4889. #ifdef PCTERM
  4890.                         setpcterm(FALSE);
  4891. #endif /* PCTERM */
  4892.                         tt_type_mode = TT_DG200 ;
  4893.                         ipadl25();
  4894.                         break;
  4895.                     case '*':
  4896.                         /* IBM 3101-1X mode */
  4897.                         debug(F110,"Wyse Escape","Terminal Type IBM 3101",0);
  4898.                         if ( debses )
  4899.                             break;
  4900. #ifdef PCTERM
  4901.                         setpcterm(FALSE);
  4902. #endif /* PCTERM */
  4903.                         tt_type_mode = TT_IBM31;
  4904.                         ipadl25();
  4905.                         break;
  4906.                     case '+':
  4907.                         /* ADM 31 mode */
  4908.                         debug(F110,"Wyse Escape","Terminal Type ADM 31",0);
  4909.                         if ( debses )
  4910.                             break;
  4911.                         break;
  4912.                     case '`':
  4913.                         /* TVI 955 mode */
  4914.                         debug(F110,"Wyse Escape","Terminal Type TVI 955",0);
  4915.                         if ( debses )
  4916.                             break;
  4917.                         break;
  4918.                     case '-':
  4919.                         /* WY75 mode */
  4920.                         debug(F110,"Wyse Escape","Terminal Type WY75",0);
  4921.                         if ( debses )
  4922.                             break;
  4923. #ifdef PCTERM
  4924.                         setpcterm(FALSE);
  4925. #endif /* PCTERM */
  4926.                         tt_type_mode = TT_VT102 ;
  4927.                         ipadl25();
  4928.                         break;
  4929.                     case '4':
  4930.                         /* WY60 mode */
  4931.                         debug(F110,"Wyse Escape","Terminal Type WY60",0);
  4932.                         if ( debses )
  4933.                             break;
  4934. #ifdef PCTERM
  4935.                         setpcterm(FALSE);
  4936. #endif /* PCTERM */
  4937.                         tt_type_mode = TT_WY60 ;
  4938.                         ipadl25();
  4939.                         break;
  4940.                     case '5':
  4941.                         /* PC Term mode */
  4942.                         debug(F110,"Wyse Escape","Terminal Type Wyse PC Term",0);
  4943.                         if ( debses )
  4944.                             break;
  4945.                         tt_type_mode = TT_WY60;
  4946. #ifdef PCTERM
  4947.                         setpcterm(TRUE);
  4948. #endif /* PCTERM */
  4949.                         ipadl25();
  4950.                         break;
  4951.                     case '6':
  4952.                         /* VT52 mode */
  4953.                         debug(F110,"Wyse Escape","Terminal Type VT52",0);
  4954.                         if ( debses )
  4955.                             break;
  4956. #ifdef PCTERM
  4957.                         setpcterm(FALSE);
  4958. #endif /* PCTERM */
  4959.                         tt_type_mode = TT_VT52 ;
  4960.                         ipadl25();
  4961.                         break;
  4962.                     case '7':
  4963.                         /* IBM 3101-2X mode */
  4964.                         debug(F110,"Wyse Escape","Terminal Type IBM 3101-2X",0);
  4965.                         if ( debses )
  4966.                             break;
  4967. #ifdef PCTERM
  4968.                         setpcterm(FALSE);
  4969. #endif /* PCTERM */
  4970.                         tt_type_mode = TT_IBM31;
  4971.                         ipadl25();
  4972.                         break;
  4973.                     case '8':
  4974.                         /* ADDS VP-60 mode */
  4975.                         debug(F110,"Wyse Escape","Terminal Type ADDS VP-60",0);
  4976.                         if ( debses )
  4977.                             break;
  4978.                         break;
  4979.                     case '9':
  4980.                         /* IBM 3161 mode */
  4981.                         debug(F110,"Wyse Escape","Terminal Type IBM 3161",0);
  4982.                         if ( debses )
  4983.                             break;
  4984.                         break;
  4985.                     case ':':
  4986.                         /* DG 210 mode */
  4987.                         debug(F110,"Wyse Escape","Terminal Type DG210",0);
  4988.                         if ( debses )
  4989.                             break;
  4990. #ifdef PCTERM
  4991.                         setpcterm(FALSE);
  4992. #endif /* PCTERM */
  4993.                         tt_type_mode = TT_DG210 ;
  4994.                         ipadl25();
  4995.                         break;
  4996.                     case ';':
  4997.                         /* VT100 mode */
  4998.                         debug(F110,"Wyse Escape","Terminal Type VT100",0);
  4999.                         if ( debses )
  5000.                             break;
  5001. #ifdef PCTERM
  5002.                         setpcterm(FALSE);
  5003. #endif /* PCTERM */
  5004.                         tt_type_mode = TT_VT102 ;
  5005.                         ipadl25();
  5006.                         break;
  5007.                     case 'A':
  5008.                         /* Esprit III mode */
  5009.                         debug(F110,"Wyse Escape","Terminal Type Esprit III",0);
  5010.                         if ( debses )
  5011.                             break;
  5012.                         break;
  5013.                     case 'B':
  5014.                         /* WY370/VT320 (7-bit) */
  5015.                         debug(F110,"Wyse Escape","Terminal Type WY370 (7-bit)",0);
  5016.                         if ( debses )
  5017.                             break;
  5018.                         tt_type_mode = TT_WY370 ;
  5019. #ifdef PCTERM
  5020.                         setpcterm(FALSE);
  5021. #endif /* PCTERM */
  5022.                         setcmask(7);
  5023.                         ipadl25();
  5024.                         break;
  5025.                     case 'C':
  5026.                         /* WY370/VT320 (8-bit) */
  5027.                         debug(F110,"Wyse Escape","Terminal Type WY370 (8-bit)",0);
  5028.                         if ( debses )
  5029.                             break;
  5030. #ifdef PCTERM
  5031.                         setpcterm(FALSE);
  5032. #endif /* PCTERM */
  5033.                         tt_type_mode = TT_WY370 ;
  5034.                         setcmask(8);
  5035.                         ipadl25();
  5036.                         break;
  5037.                     case '>':
  5038.                         /* Tek 4010/4014 mode */
  5039.                         debug(F110,"Wyse Escape","Terminal Type Tek 4010/4014",0);
  5040.                         if ( debses )
  5041.                             break;
  5042.                         ipadl25();
  5043.                         break;
  5044.                     }
  5045.                 }
  5046.                 break;
  5047.             case DEL:
  5048.                 break;
  5049.             }
  5050.             }
  5051.             escstate = ES_NORMAL ;      /* Done parsing escstate sequence */
  5052.         }
  5053.     }
  5054.     else                /* Handle as a normal character */
  5055.     {
  5056.         if ( ch < SP )
  5057.             wysectrl(ch) ;
  5058.         else if ( !debses && !xprint ) {
  5059.             if ( wysegraphics && ch < 128 )
  5060.                 ch = xlwygrph( ch ) ;
  5061.  
  5062.             /* Display the character */
  5063.             if ( !tt_hidattr &&
  5064.                  (attrmode == ATTR_PAGE_MODE || attrmode == ATTR_LINE_MODE) ) {
  5065.                 vtattrib vta = VscrnGetVtCharAttr( VTERM, wherex[VTERM]-1, wherey[VTERM]-1 ) ;
  5066.                 if ( vta.wyseattr ) {
  5067.                     int x=wherex[VTERM]-1 ;
  5068.                     int y=wherey[VTERM]-1 ;
  5069.                     /* we are about to overwrite an attribute */
  5070.                     /* this results in the previous attribute being used for the entire */
  5071.                     /* this and subsequent cells */
  5072.                     vta.wyseattr = FALSE ;
  5073.                     VscrnSetVtCharAttr( VTERM, x, y, vta ) ;
  5074.  
  5075.                     /* now find previous attribute */
  5076.                     while ( !vta.wyseattr ) {
  5077.                         if ( vta.wyseattr )     /* bug in MSVC 5.0 */
  5078.                             break;
  5079.                         x--;
  5080.                         if ( x < 0 ) {
  5081.                             y--;
  5082.                             if ( y >= 0 )
  5083.                                 x = VscrnGetWidth(VTERM) ;
  5084.                             else {
  5085.                                 x = y = 0 ;
  5086.                                 break;  /* nowhere left to go */
  5087.                             }
  5088.                         }
  5089.                         vta = VscrnGetVtCharAttr( VTERM, x, y ) ;
  5090.                     }
  5091.  
  5092.                     if ( attrmode == ATTR_PAGE_MODE )
  5093.                         ApplyPageAttribute( VTERM, x+1, y+1, vta ) ;
  5094.                     else
  5095.                         ApplyLineAttribute( VTERM, x+1, y+1, vta ) ;
  5096.                 }
  5097.             }
  5098.             if ( ch != DEL )
  5099.                 wrtch(ch);
  5100.         }
  5101.     }
  5102.     VscrnIsDirty(VTERM) ;
  5103. }
  5104. #endif /* NOTERM */
  5105.