home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d8xx / d832 / term.lha / Term / term-3.1-Source.lha / termConsole.c < prev    next >
C/C++ Source or Header  |  1993-02-19  |  41KB  |  2,339 lines

  1. /*
  2. **    termConsole.c
  3. **
  4. **    High-level terminal console routines
  5. **
  6. **    Copyright © 1990-1993 by Olaf `Olsen' Barthel & MXM
  7. **        All Rights Reserved
  8. */
  9.  
  10. #include "termGlobal.h"
  11.  
  12.     /* Character set modes. */
  13.  
  14. enum    {    MODE_STANDARD,MODE_GFX };
  15.  
  16.     /* Hints for the data flow scanner. */
  17.  
  18. STATIC WORD    ScanStart,
  19.         ScanEnd;
  20.  
  21. STATIC WORD    AttentionCount[SCAN_COUNT],
  22.         AttentionLength[SCAN_COUNT],
  23.         FlowCount;
  24.  
  25.     /* Temporary console working buffer. */
  26.  
  27. STATIC UBYTE    ConTempBuffer[512];
  28.  
  29.     /* Text output data. */
  30.  
  31. STATIC UBYTE    CurrentFontScale,FontScalingRequired;
  32. STATIC WORD    LastPrintableColumn;
  33.  
  34.     /* ConTranslateSetup():
  35.      *
  36.      *    Set up for buffer translation.
  37.      */
  38.  
  39. STATIC VOID __inline
  40. ConTranslateSetup(struct TranslationHandle *Handle,STRPTR SourceBuffer,LONG SourceLen,STRPTR DestinationBuffer,LONG DestinationLen,struct TranslationEntry **Table)
  41. {
  42.     Handle -> LocalBuffer        = NULL;
  43.     Handle -> LocalLen        = 0;
  44.  
  45.     Handle -> SourceBuffer        = SourceBuffer;
  46.     Handle -> SourceLen        = SourceLen;
  47.  
  48.     Handle -> DestinationBuffer    = DestinationBuffer;
  49.     Handle -> DestinationLen    = DestinationLen;
  50.  
  51.     Handle -> Table            = Table;
  52. }
  53.  
  54.     /* ConTranslateBuffer(struct TranslationHandle *Handle):
  55.      *
  56.      *    Translate buffer contents according to
  57.      *    translation table contents.
  58.      */
  59.  
  60. STATIC LONG __inline
  61. ConTranslateBuffer(struct TranslationHandle *Handle)
  62. {
  63.     register STRPTR                 Data        = Handle -> DestinationBuffer;
  64.     register LONG                 BytesWritten    = 0;
  65.     register struct TranslationEntry    *Entry;
  66.  
  67.         /* Are we to return any translated data? */
  68.  
  69.     while(Handle -> LocalLen && BytesWritten < Handle -> DestinationLen)
  70.     {
  71.             /* Decrement number of bytes in buffer. */
  72.  
  73.         Handle -> LocalLen--;
  74.  
  75.             /* Return next character. */
  76.  
  77.         *Data++ = *Handle -> LocalBuffer++;
  78.  
  79.             /* Add another byte. */
  80.  
  81.         BytesWritten++;
  82.     }
  83.  
  84.         /* Loop until done. */
  85.  
  86.     while(Handle -> SourceLen && BytesWritten < Handle -> DestinationLen)
  87.     {
  88.             /* Another byte eaten. */
  89.  
  90.         Handle -> SourceLen--;
  91.  
  92.             /* Get table entry. */
  93.  
  94.         if(Entry = Handle -> Table[*Handle -> SourceBuffer++])
  95.         {
  96.                 /* Copy to local data area. */
  97.  
  98.             Handle -> LocalBuffer    = Entry -> String;
  99.             Handle -> LocalLen    = Entry -> Len;
  100.  
  101.                 /* Translate the data. */
  102.  
  103.             while(Handle -> LocalLen && BytesWritten < Handle -> DestinationLen)
  104.             {
  105.                     /* Decrement number of bytes in buffer. */
  106.  
  107.                 Handle -> LocalLen--;
  108.  
  109.                     /* Return next character. */
  110.  
  111.                 *Data++ = *Handle -> LocalBuffer++;
  112.  
  113.                     /* Add another byte. */
  114.  
  115.                 BytesWritten++;
  116.             }
  117.         }
  118.     }
  119.  
  120.     return(BytesWritten);
  121. }
  122.  
  123.     /* FlowFilter(register STRPTR Data,register LONG Size,UBYTE Mask):
  124.      *
  125.      *    Data flow filter.
  126.      */
  127.  
  128. STATIC VOID __regargs
  129. FlowFilter(register STRPTR Data,register LONG Size,register UBYTE Mask)
  130. {
  131.     register UBYTE c;
  132.  
  133.         /* Run until done. */
  134.  
  135.     do
  136.     {
  137.         if(c = (*Data++ & Mask))
  138.         {
  139.  
  140.                 /* We already got a `CONNECT' and the
  141.                  * `connect auto-baud' feature is enabled.
  142.                  * Continue scanning the serial output
  143.                  * data for the actual baud rate.
  144.                  */
  145.  
  146.             if(BaudPending)
  147.             {
  148.                 if(c < ' ')
  149.                 {
  150.                     if(BaudCount)
  151.                         BaudCount--;
  152.  
  153.                     while(BaudCount > 0 && BaudBuffer[BaudCount] == ' ')
  154.                         BaudCount--;
  155.  
  156.                     BaudBuffer[BaudCount + 1] = 0;
  157.  
  158.                     FlowInfo . Connect = TRUE;
  159.                     FlowInfo . Changed = TRUE;
  160.  
  161.                     BaudPending = FALSE;
  162.  
  163.                     DTERate = GetBaudRate(BaudBuffer);
  164.                 }
  165.                 else
  166.                 {
  167.                     if(c != ' ' || BaudCount)
  168.                     {
  169.                         BaudBuffer[BaudCount++] = c;
  170.  
  171.                         if(BaudCount == 79)
  172.                         {
  173.                             BaudCount--;
  174.  
  175.                             while(BaudCount > 0 && BaudBuffer[BaudCount] == ' ')
  176.                                 BaudCount--;
  177.  
  178.                             BaudBuffer[BaudCount + 1] = 0;
  179.  
  180.                             FlowInfo . Connect = TRUE;
  181.                             FlowInfo . Changed = TRUE;
  182.  
  183.                             BaudPending = FALSE;
  184.  
  185.                             DTERate = GetBaudRate(BaudBuffer);
  186.                         }
  187.                     }
  188.                 }
  189.             }
  190.             else
  191.             {
  192.                 register BYTE MatchMade;
  193.                 register WORD i;
  194.  
  195.                 do
  196.                 {
  197.                     MatchMade = FALSE;
  198.  
  199.                         /* Scan all ID strings for matches. */
  200.  
  201.                     for(i = ScanStart ; i <= ScanEnd ; i++)
  202.                     {
  203.                             /* This sequence is a likely
  204.                              * match.
  205.                              */
  206.  
  207.                         if(AttentionCount[i] == FlowCount)
  208.                         {
  209.                                 /* Does the character
  210.                                  * fit into the sequence?
  211.                                  */
  212.  
  213.                             if(c == AttentionBuffers[i][FlowCount])
  214.                             {
  215.                                 MatchMade = TRUE;
  216.  
  217.                                     /* Did we hit the
  218.                                      * last character
  219.                                      * in the sequence?
  220.                                      */
  221.  
  222.                                 if(++AttentionCount[i] == AttentionLength[i])
  223.                                 {
  224.                                         /* We've got a valid
  225.                                          * sequence, now look
  226.                                          * which flags to change.
  227.                                          */
  228.  
  229.                                     switch(i)
  230.                                     {
  231.                                             /* We got a `no carrier' message. */
  232.  
  233.                                         case SCAN_NOCARRIER:
  234.  
  235.                                             if(Config -> SerialConfig -> CheckCarrier)
  236.                                             {
  237.                                                 WriteRequest -> IOSer . io_Command = SDCMD_QUERY;
  238.  
  239.                                                 DoIO(WriteRequest);
  240.  
  241.                                                     /* Is the carrier still present? */
  242.  
  243.                                                 if(!(WriteRequest -> io_Status & CIAF_COMCD))
  244.                                                     break;
  245.                                             }
  246.  
  247.                                             if(!FlowInfo . NoCarrier)
  248.                                             {
  249.                                                 FlowInfo . NoCarrier    = TRUE;
  250.                                                 FlowInfo . Changed    = TRUE;
  251.                                             }
  252.  
  253.                                             WasOnline = Online;
  254.  
  255.                                             Online = FALSE;
  256.  
  257.                                                 /* Clear the password. */
  258.  
  259.                                             Password[0] = 0;
  260.                                             UserName[0] = 0;
  261.  
  262.                                             CurrentBBSName[0]    = 0;
  263.                                             CurrentBBSComment[0]    = 0;
  264.                                             CurrentBBSNumber[0]    = 0;
  265.  
  266.                                             if(WasOnline)
  267.                                             {
  268.                                                 StopCall(FALSE);
  269.  
  270.                                                 if(CurrentPay && ChosenEntry)
  271.                                                     LogAction(LocaleString(MSG_TERMAUX_CARRIER_LOST_COST_TXT),CreateSum(CurrentPay,TRUE));
  272.                                                 else
  273.                                                     LogAction(LocaleString(MSG_TERMAUX_CARRIER_LOST_TXT));
  274.  
  275.                                                 Say(LocaleString(MSG_TERMAUX_CARRIER_LOST_TXT));
  276.  
  277.                                                 SetDialMenu(TRUE);
  278.                                             }
  279.  
  280.                                             break;
  281.  
  282.                                             /* Got another call. */
  283.  
  284.                                         case SCAN_RING:
  285.  
  286.                                             if(!FlowInfo . Ring)
  287.                                             {
  288.                                                 FlowInfo . Ring        = TRUE;
  289.                                                 FlowInfo . Changed    = TRUE;
  290.                                             }
  291.  
  292.                                             break;
  293.  
  294.                                             /* Got a voice call. */
  295.  
  296.                                         case SCAN_VOICE:
  297.  
  298.                                             if(!FlowInfo . Voice)
  299.                                             {
  300.                                                 FlowInfo . Voice    = TRUE;
  301.                                                 FlowInfo . Changed    = TRUE;
  302.                                             }
  303.  
  304.                                             break;
  305.  
  306.                                             /* Got a connect message. */
  307.  
  308.                                         case SCAN_CONNECT:
  309.  
  310.                                                 /* Are we to check the carrier signal? */
  311.  
  312.                                             if(Config -> SerialConfig -> CheckCarrier)
  313.                                             {
  314.                                                 WriteRequest -> IOSer . io_Command = SDCMD_QUERY;
  315.  
  316.                                                 DoIO(WriteRequest);
  317.  
  318.                                                     /* Is the carrier signal present, i.e.
  319.                                                      * was the `CONNECT' message valid?
  320.                                                      */
  321.  
  322.                                                 if(WriteRequest -> io_Status & CIAF_COMCD)
  323.                                                     break;
  324.                                             }
  325.  
  326.                                             WasOnline = Online;
  327.  
  328.                                             if(!Online)
  329.                                             {
  330.                                                 BaudBuffer[0]    = 0;
  331.  
  332.                                                 BaudPending    = TRUE;
  333.                                                 BaudCount    = 0;
  334.                                             }
  335.  
  336.                                             break;
  337.  
  338.                                             /* Got the ZModem inquiry sequence. */
  339.  
  340.                                         case SCAN_ZMODEM:
  341.  
  342.                                             if(!FlowInfo . ZModemUpload)
  343.                                             {
  344.                                                 FlowInfo . ZModemUpload    = TRUE;
  345.                                                 FlowInfo . Changed    = TRUE;
  346.                                             }
  347.  
  348.                                             break;
  349.  
  350.                                             /* Line is busy. */
  351.  
  352.                                         case SCAN_BUSY:
  353.  
  354.                                             if(!FlowInfo . Busy)
  355.                                             {
  356.                                                 FlowInfo . Busy        = TRUE;
  357.                                                 FlowInfo . Changed    = TRUE;
  358.                                             }
  359.  
  360.                                             break;
  361.  
  362.                                         case SCAN_NODIALTONE:
  363.  
  364.                                             if(!FlowInfo . NoDialTone)
  365.                                             {
  366.                                                 FlowInfo . NoDialTone    = TRUE;
  367.                                                 FlowInfo . Changed    = TRUE;
  368.                                             }
  369.  
  370.                                             break;
  371.                                     }
  372.                                 }
  373.                             }
  374.                         }
  375.                     }
  376.  
  377.                     if(MatchMade)
  378.                         FlowCount++;
  379.                     else
  380.                     {
  381.                         if(FlowCount)
  382.                         {
  383.                             FlowCount = 0;
  384.  
  385.                             memset(AttentionCount,0,sizeof(AttentionCount));
  386.                         }
  387.                         else
  388.                             break;
  389.                     }
  390.                 }
  391.                 while(!FlowCount);
  392.             }
  393.         }
  394.     }
  395.     while(--Size);
  396. }
  397.  
  398.     /* StripSequence():
  399.      *
  400.      *    Strips a string from ESC and CSI introduced control
  401.      *    sequences.
  402.      */
  403.  
  404. STATIC LONG __regargs
  405. StripSequence(STRPTR Src,STRPTR Dst,LONG Length)
  406. {
  407.     STATIC BYTE    HasESC    = FALSE,
  408.             HasCSI    = FALSE;
  409.     LONG        Size    = 0;
  410.  
  411.     while(Length--)
  412.     {
  413.         if(HasESC)
  414.         {
  415.             if(*Src == '[')
  416.             {
  417.                 HasESC = FALSE;
  418.                 HasCSI = TRUE;
  419.             }
  420.             else
  421.             {
  422.                 if(*Src >= '0')
  423.                     HasESC = FALSE;
  424.             }
  425.  
  426.             Src++;
  427.  
  428.             continue;
  429.         }
  430.  
  431.         if(HasCSI)
  432.         {
  433.             if(*Src >= '@')
  434.                 HasCSI = FALSE;
  435.  
  436.             Src++;
  437.  
  438.             continue;
  439.         }
  440.  
  441.         switch(*Src)
  442.         {
  443.             case CAN:
  444.             case SUB:
  445.  
  446.                 HasESC = HasCSI = FALSE;
  447.                 break;
  448.  
  449.             case '\r':
  450.  
  451.                 break;
  452.  
  453.             case ESC:
  454.  
  455.                 HasESC = TRUE;
  456.                 break;
  457.  
  458.             case CSI:
  459.  
  460.                 HasCSI = TRUE;
  461.                 break;
  462.  
  463.             default:
  464.  
  465.                 if(IsPrintable[*Src])
  466.                 {
  467.                     *Dst++ = *Src;
  468.  
  469.                     Size++;
  470.                 }
  471.  
  472.                 break;
  473.         }
  474.  
  475.         Src++;
  476.     }
  477.  
  478.     return(Size);
  479. }
  480.  
  481.     /* ConOutputPrinter(STRPTR Buffer,LONG Size):
  482.      *
  483.      *    Raw text output routine, printer capture flavour.
  484.      */
  485.  
  486. STATIC VOID __regargs
  487. ConOutputPrinter(STRPTR Buffer,LONG Size)
  488. {
  489.     if(FWrite(PrinterCapture,Buffer,Size,1) != 1)
  490.     {
  491.         BlockWindows();
  492.  
  493.         if(!MyEasyRequest(NULL,LocaleString(MSG_CONSOLE_ERROR_WRITING_TO_PRINTER_TXT),LocaleString(MSG_CONSOLE_IGNORE_CLOSE_PRINTER_TXT)))
  494.             ClosePrinterCapture(TRUE);
  495.  
  496.         ReleaseWindows();
  497.     }
  498. }
  499.  
  500.     /* ConOutputCaptureGFX(STRPTR Buffer,LONG Size):
  501.      *
  502.      *    Raw text output routine, GFX text & capture flavour.
  503.      */
  504.  
  505. STATIC VOID __regargs
  506. ConOutputCaptureGFX(STRPTR Buffer,LONG Size)
  507. {
  508.     register WORD Offset;
  509.  
  510.         /* Do we still have a character in the
  511.          * magnificient buffer?
  512.          */
  513.  
  514.     while(Size)
  515.     {
  516.             /* Cursor is positioned at
  517.              * the right hand side of the
  518.              * display. If auto-wrap is
  519.              * enabled, perform some
  520.              * kind of CR/LF, else leave
  521.              * the cursor where it is and
  522.              * quit the show.
  523.              */
  524.  
  525.         if(CursorX > LastPrintableColumn)
  526.         {
  527.                 /* Wrap cursor. */
  528.  
  529.             if(Config -> EmulationConfig -> LineWrap)
  530.             {
  531.                     /* Move to beginning of next line. */
  532.  
  533.                 CursorX = 0;
  534.  
  535.                 DownLine();
  536.  
  537.                 Capture("\n",1);
  538.  
  539.                 CurrentFontScale = SCALE_ATTR_NORMAL;
  540.  
  541.                 FontScalingRequired = (Config -> EmulationConfig -> FontScale != SCALE_NORMAL);
  542.  
  543.                 LastPrintableColumn = LastColumn;
  544.  
  545.                     /* Reposition cursor, don't redraw it. */
  546.  
  547.                 ClipBlitCursor(FALSE,TRUE);
  548.             }
  549.             else
  550.             {
  551.                     /* Stop the cursor. */
  552.  
  553.                 CursorX = LastPrintableColumn;
  554.  
  555.                 Capture(Buffer,Size);
  556.  
  557.                     /* Make it reappear. */
  558.  
  559.                 ClipBlitCursor(FALSE,TRUE);
  560.  
  561.                 return;
  562.             }
  563.         }
  564.  
  565.         if((Offset = LastPrintableColumn + 1 - CursorX) > Size)
  566.             Offset = Size;
  567.  
  568.         if(Config -> EmulationConfig -> InsertMode)
  569.         {
  570.             RasterShiftChar(Offset);
  571.  
  572.             ScrollLineShiftChar(Offset);
  573.  
  574.             ShiftChar(Offset);
  575.         }
  576.  
  577.         RasterPutString(Buffer,Offset);
  578.  
  579.         ScrollLinePutString(Offset);
  580.  
  581.         if(FontScalingRequired)
  582.             PrintScaled(Buffer,Offset,CurrentFontScale);
  583.         else
  584.             GfxText(RPort,Buffer,Offset);
  585.  
  586.         Capture(Buffer,Offset);
  587.  
  588.         Buffer    += Offset;
  589.  
  590.         Size    -= Offset;
  591.  
  592.         CursorX    += Offset;
  593.     }
  594.  
  595.     ClipBlitCursor(FALSE,TRUE);
  596. }
  597.  
  598.     /* ConOutputCaptureNormal(STRPTR Buffer,LONG Size):
  599.      *
  600.      *    Raw text output routine, normal text & capture flavour.
  601.      */
  602.  
  603. STATIC VOID __regargs
  604. ConOutputCaptureNormal(STRPTR Buffer,LONG Size)
  605. {
  606.     register WORD Offset;
  607.  
  608.     while(Size)
  609.     {
  610.         if(CursorX > LastPrintableColumn)
  611.         {
  612.             if(Config -> EmulationConfig -> LineWrap)
  613.             {
  614.                 CursorX = 0;
  615.  
  616.                 DownLine();
  617.  
  618.                 Capture("\n",1);
  619.  
  620.                 CurrentFontScale = SCALE_ATTR_NORMAL;
  621.  
  622.                 FontScalingRequired = (Config -> EmulationConfig -> FontScale != SCALE_NORMAL);
  623.  
  624.                 LastPrintableColumn = LastColumn;
  625.  
  626.                 ClipBlitCursor(FALSE,TRUE);
  627.             }
  628.             else
  629.             {
  630.                 CursorX = LastPrintableColumn;
  631.  
  632.                 Capture(Buffer,Size);
  633.  
  634.                 ClipBlitCursor(FALSE,TRUE);
  635.  
  636.                 return;
  637.             }
  638.         }
  639.  
  640.         if((Offset = LastPrintableColumn + 1 - CursorX) > Size)
  641.             Offset = Size;
  642.  
  643.         if(Config -> EmulationConfig -> InsertMode)
  644.         {
  645.             RasterShiftChar(Offset);
  646.  
  647.             ScrollLineShiftChar(Offset);
  648.  
  649.             ShiftChar(Offset);
  650.         }
  651.  
  652.         RasterPutString(Buffer,Offset);
  653.  
  654.         ScrollLinePutString(Offset);
  655.  
  656.         if(FontScalingRequired)
  657.             PrintScaled(Buffer,Offset,CurrentFontScale);
  658.         else
  659.             Text(RPort,Buffer,Offset);
  660.  
  661.         Capture(Buffer,Offset);
  662.  
  663.         Buffer    += Offset;
  664.  
  665.         Size    -= Offset;
  666.  
  667.         CursorX    += Offset;
  668.     }
  669.  
  670.     ClipBlitCursor(FALSE,TRUE);
  671. }
  672.  
  673.     /* ConOutputGFX(STRPTR Buffer,LONG Size):
  674.      *
  675.      *    Raw text output routine, GFX text flavour.
  676.      */
  677.  
  678. STATIC VOID __regargs
  679. ConOutputGFX(STRPTR Buffer,LONG Size)
  680. {
  681.     register WORD Offset;
  682.  
  683.         /* Do we still have a character in the
  684.          * magnificient buffer?
  685.          */
  686.  
  687.     while(Size)
  688.     {
  689.             /* Cursor is positioned at
  690.              * the right hand side of the
  691.              * display. If auto-wrap is
  692.              * enabled, perform some
  693.              * kind of CR/LF, else leave
  694.              * the cursor where it is and
  695.              * quit the show.
  696.              */
  697.  
  698.         if(CursorX > LastPrintableColumn)
  699.         {
  700.                 /* Wrap cursor. */
  701.  
  702.             if(Config -> EmulationConfig -> LineWrap)
  703.             {
  704.                     /* Move to beginning of next line. */
  705.  
  706.                 CursorX = 0;
  707.  
  708.                 DownLine();
  709.  
  710.                 CurrentFontScale = SCALE_ATTR_NORMAL;
  711.  
  712.                 FontScalingRequired = (Config -> EmulationConfig -> FontScale != SCALE_NORMAL);
  713.  
  714.                 LastPrintableColumn = LastColumn;
  715.  
  716.                     /* Reposition cursor, don't redraw it. */
  717.  
  718.                 ClipBlitCursor(FALSE,TRUE);
  719.             }
  720.             else
  721.             {
  722.                     /* Stop the cursor. */
  723.  
  724.                 CursorX = LastPrintableColumn;
  725.  
  726.                     /* Make it reappear. */
  727.  
  728.                 ClipBlitCursor(FALSE,TRUE);
  729.  
  730.                 return;
  731.             }
  732.         }
  733.  
  734.         if((Offset = LastPrintableColumn + 1 - CursorX) > Size)
  735.             Offset = Size;
  736.  
  737.         if(Config -> EmulationConfig -> InsertMode)
  738.         {
  739.             RasterShiftChar(Offset);
  740.  
  741.             ScrollLineShiftChar(Offset);
  742.  
  743.             ShiftChar(Offset);
  744.         }
  745.  
  746.         RasterPutString(Buffer,Offset);
  747.  
  748.         ScrollLinePutString(Offset);
  749.  
  750.         if(FontScalingRequired)
  751.             PrintScaled(Buffer,Offset,CurrentFontScale);
  752.         else
  753.             GfxText(RPort,Buffer,Offset);
  754.  
  755.         Buffer    += Offset;
  756.  
  757.         Size    -= Offset;
  758.  
  759.         CursorX    += Offset;
  760.     }
  761.  
  762.     ClipBlitCursor(FALSE,TRUE);
  763. }
  764.  
  765.     /* ConOutputNormal(STRPTR Buffer,LONG Size):
  766.      *
  767.      *    Raw text output routine, normal text flavour.
  768.      */
  769.  
  770. STATIC VOID __regargs
  771. ConOutputNormal(STRPTR Buffer,LONG Size)
  772. {
  773.     register WORD Offset;
  774.  
  775.     while(Size)
  776.     {
  777.         if(CursorX > LastPrintableColumn)
  778.         {
  779.             if(Config -> EmulationConfig -> LineWrap)
  780.             {
  781.                 CursorX = 0;
  782.  
  783.                 DownLine();
  784.  
  785.                 CurrentFontScale = SCALE_ATTR_NORMAL;
  786.  
  787.                 FontScalingRequired = (Config -> EmulationConfig -> FontScale != SCALE_NORMAL);
  788.  
  789.                 LastPrintableColumn = LastColumn;
  790.  
  791.                 ClipBlitCursor(FALSE,TRUE);
  792.             }
  793.             else
  794.             {
  795.                 CursorX = LastPrintableColumn;
  796.  
  797.                 ClipBlitCursor(FALSE,TRUE);
  798.  
  799.                 return;
  800.             }
  801.         }
  802.  
  803.         if((Offset = LastPrintableColumn + 1 - CursorX) > Size)
  804.             Offset = Size;
  805.  
  806.         if(Config -> EmulationConfig -> InsertMode)
  807.         {
  808.             RasterShiftChar(Offset);
  809.  
  810.             ScrollLineShiftChar(Offset);
  811.  
  812.             ShiftChar(Offset);
  813.         }
  814.  
  815.         RasterPutString(Buffer,Offset);
  816.  
  817.         ScrollLinePutString(Offset);
  818.  
  819.         if(FontScalingRequired)
  820.             PrintScaled(Buffer,Offset,CurrentFontScale);
  821.         else
  822.             Text(RPort,Buffer,Offset);
  823.  
  824.         Buffer    += Offset;
  825.  
  826.         Size    -= Offset;
  827.  
  828.         CursorX    += Offset;
  829.     }
  830.  
  831.     ClipBlitCursor(FALSE,TRUE);
  832. }
  833.  
  834.     /* ConOutputUpdate():
  835.      *
  836.      *    Choose the right raw text output routine for the job.
  837.      */
  838.  
  839. VOID
  840. ConOutputUpdate()
  841. {
  842.     if(ControllerActive)
  843.         ConOutput = ConOutputPrinter;
  844.     else
  845.     {
  846.         if((Config -> CaptureConfig -> CaptureFilterMode && FileCapture) || PrinterCapture)
  847.         {
  848.             if(CurrentFont == GFX)
  849.                 ConOutput = ConOutputCaptureGFX;
  850.             else
  851.                 ConOutput = ConOutputCaptureNormal;
  852.         }
  853.         else
  854.         {
  855.             if(BufferFrozen)
  856.             {
  857.                 if(CurrentFont == GFX)
  858.                     ConOutput = ConOutputGFX;
  859.                 else
  860.                     ConOutput = ConOutputNormal;
  861.             }
  862.             else
  863.             {
  864.                 if(CurrentFont == GFX)
  865.                     ConOutput = ConOutputCaptureGFX;
  866.                 else
  867.                     ConOutput = ConOutputCaptureNormal;
  868.             }
  869.         }
  870.     }
  871.  
  872.     if(ReceiveTable)
  873.         ConDump = ConTransWrite;
  874.     else
  875.         ConDump = ConOutput;
  876. }
  877.  
  878.     /* ConFontScaleUpdate():
  879.      *
  880.      *    Choose the right font scale for the job.
  881.      */
  882.  
  883. VOID
  884. ConFontScaleUpdate()
  885. {
  886.     CurrentFontScale = RasterAttr[CursorY];
  887.  
  888.     if(Config -> EmulationConfig -> FontScale == SCALE_HALF)
  889.     {
  890.         FontScalingRequired    = (CurrentFontScale != SCALE_ATTR_2X);
  891.         LastPrintableColumn    = LastColumn;
  892.     }
  893.     else
  894.     {
  895.         if(FontScalingRequired = (CurrentFontScale != SCALE_ATTR_NORMAL))
  896.             LastPrintableColumn = ((LastColumn + 1) / 2) - 1;
  897.         else
  898.             LastPrintableColumn = LastColumn;
  899.     }
  900. }
  901.  
  902.     /* ConTransWrite(STRPTR Buffer,LONG Size):
  903.      *
  904.      *    Frontend for ConWrite(), including character translation.
  905.      */
  906.  
  907. VOID __regargs
  908. ConTransWrite(STRPTR Buffer,LONG Size)
  909. {
  910.     struct TranslationHandle    Handle;
  911.     UBYTE                LocalBuffer[256];
  912.  
  913.         /* Set up for translation. */
  914.  
  915.     ConTranslateSetup(&Handle,Buffer,Size,LocalBuffer,256,ReceiveTable);
  916.  
  917.         /* Process and output the data. */
  918.  
  919.     while(Size = ConTranslateBuffer(&Handle))
  920.         (* ConOutput)(LocalBuffer,Size);
  921. }
  922.  
  923.     /* ConProcessDataTransExternal(register STRPTR String,register LONG Size):
  924.      *
  925.      *    Process data, external emulation including translation flavour.
  926.      */
  927.  
  928. VOID __regargs
  929. ConProcessDataTransExternal(register STRPTR String,register LONG Size)
  930. {
  931.     struct TranslationHandle Handle;
  932.  
  933.         /* Set up for translation. */
  934.  
  935.     ConTranslateSetup(&Handle,String,Size,ConTempBuffer,256,ReceiveTable);
  936.  
  937.     if(StripBuffer)
  938.     {
  939.         register LONG Len;
  940.  
  941.             /* Process and output the data. */
  942.  
  943.         while(Size = ConTranslateBuffer(&Handle))
  944.         {
  945.             XEmulatorWrite(XEM_IO,ConTempBuffer,Size);
  946.  
  947.             XEM_HostData . Source        = ConTempBuffer;
  948.             XEM_HostData . Destination    = StripBuffer;
  949.  
  950.             if(Len = XEmulatorHostMon(XEM_IO,&XEM_HostData,Size))
  951.                 Capture(StripBuffer,Len);
  952.         }
  953.     }
  954.     else
  955.     {
  956.             /* Process and output the data. */
  957.  
  958.         while(Size = ConTranslateBuffer(&Handle))
  959.             XEmulatorWrite(XEM_IO,ConTempBuffer,Size);
  960.     }
  961. }
  962.  
  963.     /* ConProcessDataExternal(register STRPTR String,register LONG Size):
  964.      *
  965.      *    Process data, external emulation flavour.
  966.      */
  967.  
  968. VOID __regargs
  969. ConProcessDataExternal(register STRPTR String,register LONG Size)
  970. {
  971.     XEmulatorWrite(XEM_IO,String,Size);
  972.  
  973.         /* Build another string to contain
  974.          * the pure ASCII contents, i.e.
  975.          * not including any ESC control
  976.          * sequences.
  977.          */
  978.  
  979.     if(StripBuffer)
  980.     {
  981.         register LONG Len;
  982.  
  983.         XEM_HostData . Source        = String;
  984.         XEM_HostData . Destination    = StripBuffer;
  985.  
  986.         if(Len = XEmulatorHostMon(XEM_IO,&XEM_HostData,Size))
  987.             Capture(StripBuffer,Len);
  988.     }
  989. }
  990.  
  991.     /* ConProcessData7(register STRPTR String,register LONG Size):
  992.      *
  993.      *    Process data, 7 bit flavour.
  994.      */
  995.  
  996. VOID __regargs
  997. ConProcessData7(register STRPTR String,register LONG Size)
  998. {
  999.     register LONG    Len = 0;
  1000.     register UBYTE    c;
  1001.  
  1002.         /* If still parsing a sequence,
  1003.          * continue with it.
  1004.          */
  1005.  
  1006.     if(InSequence)
  1007.     {
  1008.         while(Size--)
  1009.         {
  1010.             c = *String++ & 0x7F;
  1011.  
  1012.             if(!(*AbortTable[c])(c))
  1013.             {
  1014.                 InSequence = FALSE;
  1015.  
  1016.                 break;
  1017.             }
  1018.         }
  1019.     }
  1020.  
  1021.         /* Check which font we are in, if other than Topaz
  1022.          * the only invalid char is a Null (0) which will
  1023.          * display as a space if let to continue.
  1024.          */
  1025.  
  1026.     if(Config -> TerminalConfig -> FontMode == FONT_STANDARD)
  1027.     {
  1028.         while(Size-- > 0)
  1029.         {
  1030.             if(IsPrintable[c = *String++ & 0x7F])
  1031.             {
  1032.                     /* This character is associated with a
  1033.                      * special function (bell, xon, xoff, etc.).
  1034.                      */
  1035.  
  1036.                 if(SpecialTable[c])
  1037.                 {
  1038.                     if(Len)
  1039.                     {
  1040.                         (*ConDump)(ConTempBuffer,Len);
  1041.  
  1042.                         Len = 0;
  1043.                     }
  1044.  
  1045.                         /* Does this character start
  1046.                          * a control sequence?
  1047.                          */
  1048.  
  1049.                     if(InSequence = (*SpecialTable[c])(c))
  1050.                     {
  1051.                         while(Size-- > 0)
  1052.                         {
  1053.                             c = *String++ & 0x7F;
  1054.  
  1055.                             if(!(*AbortTable[c])(c))
  1056.                             {
  1057.                                 InSequence = FALSE;
  1058.  
  1059.                                 break;
  1060.                             }
  1061.                         }
  1062.                     }
  1063.                 }
  1064.                 else
  1065.                 {
  1066.                         /* Put the character into the buffer
  1067.                          * and flush it if necessary.
  1068.                          */
  1069.  
  1070.                     ConTempBuffer[Len] = c;
  1071.  
  1072.                     if(Len++ == 512)
  1073.                     {
  1074.                         (*ConDump)(ConTempBuffer,Len);
  1075.  
  1076.                         Len = 0;
  1077.                     }
  1078.                 }
  1079.             }
  1080.         }
  1081.     }
  1082.     else
  1083.     {
  1084.         while(Size-- > 0)
  1085.         {
  1086.             if(c = (*String++ & 0x7F))
  1087.             {
  1088.                     /* This character is associated with a
  1089.                      * special function (bell, xon, xoff, etc.).
  1090.                      */
  1091.  
  1092.                 if(SpecialTable[c])
  1093.                 {
  1094.                     if(Len)
  1095.                     {
  1096.                         (*ConDump)(ConTempBuffer,Len);
  1097.  
  1098.                         Len = 0;
  1099.                     }
  1100.  
  1101.                     if(InSequence = (*SpecialTable[c])(c))
  1102.                     {
  1103.                         while(Size-- > 0)
  1104.                         {
  1105.                             c = *String++ & 0x7F;
  1106.  
  1107.                             if(!(*AbortTable[c])(c))
  1108.                             {
  1109.                                 InSequence = FALSE;
  1110.  
  1111.                                 break;
  1112.                             }
  1113.                         }
  1114.                     }
  1115.                 }
  1116.                 else
  1117.                 {
  1118.                         /* Put the character into the buffer
  1119.                          * and flush it if necessary.
  1120.                          */
  1121.  
  1122.                     ConTempBuffer[Len] = c;
  1123.  
  1124.                     if(Len++ == 512)
  1125.                     {
  1126.                         (*ConDump)(ConTempBuffer,Len);
  1127.  
  1128.                         Len = 0;
  1129.                     }
  1130.                 }
  1131.             }
  1132.         }
  1133.     }
  1134.  
  1135.     if(Len)
  1136.         (*ConDump)(ConTempBuffer,Len);
  1137. }
  1138.  
  1139.     /* ConProcessData8(register STRPTR String,register LONG Size):
  1140.      *
  1141.      *    Process data, 8 bit flavour.
  1142.      */
  1143.  
  1144. VOID __regargs
  1145. ConProcessData8(register STRPTR String,register LONG Size)
  1146. {
  1147.     register LONG    Len = 0;
  1148.     register UBYTE    c;
  1149.  
  1150.     if(InSequence)
  1151.     {
  1152.         while(Size--)
  1153.         {
  1154.             c = *String++;
  1155.  
  1156.             if(!(*AbortTable[c])(c))
  1157.             {
  1158.                 InSequence = FALSE;
  1159.  
  1160.                 break;
  1161.             }
  1162.         }
  1163.     }
  1164.  
  1165.     if(Config -> TerminalConfig -> FontMode == FONT_STANDARD)
  1166.     {
  1167.         while(Size-- > 0)
  1168.         {
  1169.             if(IsPrintable[c = *String++])
  1170.             {
  1171.                 if(SpecialTable[c])
  1172.                 {
  1173.                     if(Len)
  1174.                     {
  1175.                         (*ConDump)(ConTempBuffer,Len);
  1176.  
  1177.                         Len = 0;
  1178.                     }
  1179.  
  1180.                     if(InSequence = (*SpecialTable[c])(c))
  1181.                     {
  1182.                         while(Size-- > 0)
  1183.                         {
  1184.                             c = *String++;
  1185.  
  1186.                             if(!(*AbortTable[c])(c))
  1187.                             {
  1188.                                 InSequence = FALSE;
  1189.  
  1190.                                 break;
  1191.                             }
  1192.                         }
  1193.                     }
  1194.                 }
  1195.                 else
  1196.                 {
  1197.                     ConTempBuffer[Len] = c;
  1198.  
  1199.                     if(Len++ == 512)
  1200.                     {
  1201.                         (*ConDump)(ConTempBuffer,Len);
  1202.  
  1203.                         Len = 0;
  1204.                     }
  1205.                 }
  1206.             }
  1207.         }
  1208.     }
  1209.     else
  1210.     {
  1211.         while(Size-- > 0)
  1212.         {
  1213.             if(c = *String++)
  1214.             {
  1215.                 if(SpecialTable[c])
  1216.                 {
  1217.                     if(Len)
  1218.                     {
  1219.                         (*ConDump)(ConTempBuffer,Len);
  1220.  
  1221.                         Len = 0;
  1222.                     }
  1223.  
  1224.                     if(InSequence = (*SpecialTable[c])(c))
  1225.                     {
  1226.                         while(Size-- > 0)
  1227.                         {
  1228.                             c = *String++;
  1229.  
  1230.                             if(!(*AbortTable[c])(c))
  1231.                             {
  1232.                                 InSequence = FALSE;
  1233.  
  1234.                                 break;
  1235.                             }
  1236.                         }
  1237.                     }
  1238.                 }
  1239.                 else
  1240.                 {
  1241.                     ConTempBuffer[Len] = c;
  1242.  
  1243.                     if(Len++ == 512)
  1244.                     {
  1245.                         (*ConDump)(ConTempBuffer,Len);
  1246.  
  1247.                         Len = 0;
  1248.                     }
  1249.                 }
  1250.             }
  1251.         }
  1252.     }
  1253.  
  1254.     if(Len)
  1255.         (*ConDump)(ConTempBuffer,Len);
  1256. }
  1257.  
  1258.     /* ConTransferHost(STRPTR Buffer,LONG Len):
  1259.      *
  1260.      *    Process data read from the serial line,
  1261.      *    special XPR flavour.
  1262.      */
  1263.  
  1264. VOID __regargs
  1265. ConTransferHost(STRPTR Buffer,LONG Len)
  1266. {
  1267.     Len = XProtocolHostMon(XprIO,Buffer,Len,Config -> SerialConfig -> SerialBufferSize);
  1268.  
  1269.     if(TransferWindow)
  1270.         TransferCleanup();
  1271.  
  1272.     if(Len)
  1273.         ConProcess(Buffer,Len);
  1274. }
  1275.  
  1276.     /* ConProcess(STRPTR String,LONG Size):
  1277.      *
  1278.      *    Process the contents of a string to be sent to the
  1279.      *    console window.
  1280.      */
  1281.  
  1282. VOID __regargs
  1283. ConProcess(register STRPTR String,register LONG Size)
  1284. {
  1285.         /* If the capture filter happens to be disabled, write the
  1286.          * raw data.
  1287.          */
  1288.  
  1289.     if(!Config -> CaptureConfig -> CaptureFilterMode)
  1290.         CaptureToFile(String,Size);
  1291.  
  1292.         /* Feed the flow filter. */
  1293.  
  1294.     if(UseFlow)
  1295.     {
  1296.         if(Config -> SerialConfig -> StripBit8)
  1297.             FlowFilter(String,Size,0x7F);
  1298.         else
  1299.             FlowFilter(String,Size,0xFF);
  1300.     }
  1301.  
  1302.         /* In quiet mode no characters are echoed to the
  1303.          * console window, they are just passed through
  1304.          * the data flow filter. Usually, this mode is
  1305.          * enabled by the dial panel.
  1306.          */
  1307.  
  1308.     if(!Quiet)
  1309.         (*ConProcessData)(String,Size);
  1310. }
  1311.  
  1312.     /* ConWrites(STRPTR String,...):
  1313.      *
  1314.      *    Output a string to the console.
  1315.      */
  1316.  
  1317. VOID __stdargs
  1318. ConWrites(STRPTR String,...)
  1319. {
  1320.     va_list    VarArgs;
  1321.  
  1322.     if(Marking)
  1323.         DropMarker();
  1324.  
  1325.     ClearCursor();
  1326.  
  1327.     va_start(VarArgs,String);
  1328.     VSPrintf(SharedBuffer,String,VarArgs);
  1329.     va_end(VarArgs);
  1330.  
  1331.     ConProcess(SharedBuffer,strlen(SharedBuffer));
  1332.  
  1333.     DrawCursor();
  1334. }
  1335.  
  1336.     /* FlowInit():
  1337.      *
  1338.      *    Set up the data flow parser. The parser scans the serial
  1339.      *    output data for more or less interesting modem output
  1340.      *    (carrier lost, connect, etc.).
  1341.      */
  1342.  
  1343. VOID
  1344. FlowInit(BYTE FullReset)
  1345. {
  1346.     WORD i;
  1347.  
  1348.         /* Set up `NO CARRIER' message. */
  1349.  
  1350.     if(Config -> ModemConfig -> NoCarrier[0])
  1351.         SPrintf(AttentionBuffers[SCAN_NOCARRIER],"%s\r",Config -> ModemConfig -> NoCarrier);
  1352.     else
  1353.         AttentionBuffers[SCAN_NOCARRIER][0] = 0;
  1354.  
  1355.         /* Set up ZRQINIT message. */
  1356.  
  1357.     strcpy(AttentionBuffers[SCAN_ZMODEM],"*\030B01");
  1358.  
  1359.         /* Set up `CONNECT' message. */
  1360.  
  1361.     strcpy(AttentionBuffers[SCAN_CONNECT],Config -> ModemConfig -> Connect);
  1362.  
  1363.         /* Set up `VOICE' message. */
  1364.  
  1365.     if(Config -> ModemConfig -> Voice[0])
  1366.         SPrintf(AttentionBuffers[SCAN_VOICE],"%s\r",Config -> ModemConfig -> Voice);
  1367.     else
  1368.         AttentionBuffers[SCAN_VOICE][0] = 0;
  1369.  
  1370.         /* Set up `RING' message. */
  1371.  
  1372.     if(Config -> ModemConfig -> Ring[0])
  1373.         SPrintf(AttentionBuffers[SCAN_RING],"%s\r",Config -> ModemConfig -> Ring);
  1374.     else
  1375.         AttentionBuffers[SCAN_RING][0] = 0;
  1376.  
  1377.         /* Set up `BUSY' message. */
  1378.  
  1379.     if(Config -> ModemConfig -> Busy[0])
  1380.         SPrintf(AttentionBuffers[SCAN_BUSY],"%s\r",Config -> ModemConfig -> Busy);
  1381.     else
  1382.         AttentionBuffers[SCAN_BUSY][0] = 0;
  1383.  
  1384.         /* Set up `NO DIALTONE' message. */
  1385.  
  1386.     if(Config -> ModemConfig -> NoDialTone[0])
  1387.         SPrintf(AttentionBuffers[SCAN_NODIALTONE],"%s\r",Config -> ModemConfig -> NoDialTone);
  1388.     else
  1389.         AttentionBuffers[SCAN_NODIALTONE][0] = 0;
  1390.  
  1391.         /* Reset match counter. */
  1392.  
  1393.     FlowCount = 0;
  1394.  
  1395.         /* Reset indices. */
  1396.  
  1397.     memset(AttentionCount,0,sizeof(AttentionCount));
  1398.  
  1399.         /* Determine lengths. */
  1400.  
  1401.     for(i = 0 ; i < SCAN_COUNT ; i++)
  1402.         AttentionLength[i] = strlen(AttentionBuffers[i]);
  1403.  
  1404.     if(FullReset)
  1405.     {
  1406.             /* No, we are not yet looking for a baud rate. */
  1407.  
  1408.         BaudPending = FALSE;
  1409.  
  1410.             /* Reset the flags. */
  1411.  
  1412.         FlowInfo . Changed = FlowInfo . NoCarrier = FlowInfo . ZModemUpload = FlowInfo . Connect = FlowInfo . Voice = FlowInfo . Ring = FlowInfo . Busy = FlowInfo . NoDialTone = FALSE;
  1413.     }
  1414.  
  1415.         /* Is it safe to disable the flow filter? */
  1416.  
  1417.     if(!FullCheck && Online && Config -> SerialConfig -> CheckCarrier && !Config -> MiscConfig -> AutoUpload)
  1418.         UseFlow = FALSE;
  1419.     else
  1420.         UseFlow = TRUE;
  1421.  
  1422.         /* Full data check is a lot slower than looking for
  1423.          * just a single sequence (such as the `CONNECT'
  1424.          * below). This mode is reserved for the dial panel.
  1425.          */
  1426.  
  1427.     if(FullCheck)
  1428.     {
  1429.         ScanStart    = SCAN_NOCARRIER;
  1430.         ScanEnd        = SCAN_NODIALTONE;
  1431.     }
  1432.     else
  1433.     {
  1434.         if(Online)
  1435.         {
  1436.             ScanStart = SCAN_NOCARRIER;
  1437.  
  1438.             if(UsesZModem)
  1439.                 ScanEnd = SCAN_ZMODEM;
  1440.             else
  1441.                 ScanEnd = SCAN_NOCARRIER;
  1442.         }
  1443.         else
  1444.         {
  1445.             if(UsesZModem)
  1446.                 ScanStart = SCAN_ZMODEM;
  1447.             else
  1448.                 ScanStart = SCAN_CONNECT;
  1449.  
  1450.             ScanEnd = SCAN_RING;
  1451.         }
  1452.     }
  1453. }
  1454.  
  1455.     /* HandleCursor(UBYTE Char,ULONG Qualifier):
  1456.      *
  1457.      *    This routine handles the somewhat strange behaviour of
  1458.      *    an assorted set of keys in VT100 applications mode.
  1459.      */
  1460.  
  1461. BYTE __regargs
  1462. HandleCursor(UBYTE Char,ULONG Qualifier)
  1463. {
  1464.     STATIC struct { UBYTE Char; STRPTR VanillaString,ApplicationString; } Table[24] =
  1465.     {
  1466.         CUP,    "\033[A",    "\033OA",
  1467.         CDN,    "\033[B",    "\033OB",
  1468.         CFW,    "\033[C",    "\033OC",
  1469.         CBK,    "\033[D",    "\033OD",
  1470.  
  1471.         '0',    "0",        "\033Op",
  1472.         '1',    "1",        "\033Oq",
  1473.         '2',    "2",        "\033Or",
  1474.         '3',    "3",        "\033Os",
  1475.         '4',    "4",        "\033Ot",
  1476.         '5',    "5",        "\033Ou",
  1477.         '6',    "6",        "\033Ov",
  1478.         '7',    "7",        "\033Ow",
  1479.         '8',    "8",        "\033Ox",
  1480.         '9',    "9",        "\033Oy",
  1481.         '-',    "-",        "\033Om",
  1482.         '+',    "+",        "\033Ol",    /* This should really be a comma */
  1483.         '.',    ".",        "\033On",
  1484.  
  1485.         '[',    "[",        "\033OP",
  1486.         '{',    "{",        "\033OP",
  1487.         ']',    "]",        "\033OQ",
  1488.         '}',    "}",        "\033OQ",
  1489.         '/',    "/",        "\033OR",
  1490.         '*',    "*",        "\033OS",
  1491.  
  1492.         '\r',    "\r",        "\033OM"
  1493.     };
  1494.  
  1495.     BYTE i;
  1496.  
  1497.         /* Look for the cursor keys first. */
  1498.  
  1499.     for(i = 0 ; i < 4 ; i++)
  1500.     {
  1501.             /* Is this the key we want? */
  1502.  
  1503.         if(Table[i] . Char == Char)
  1504.         {
  1505.                 /* If in cursor key applications mode,
  1506.                  * send the corresponding string.
  1507.                  */
  1508.  
  1509.             if(Config -> EmulationConfig -> CursorMode == KEYMODE_APPLICATION)
  1510.                 SerWrite(Table[i] . ApplicationString,strlen(Table[i] . ApplicationString));
  1511.             else
  1512.             {
  1513.                 WORD QualType = 0;
  1514.  
  1515.                     /* Find the approriate qualifier. */
  1516.  
  1517.                 if(Qualifier & (IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT))
  1518.                     QualType = 1;
  1519.                 else
  1520.                 {
  1521.                     if(Qualifier & (IEQUALIFIER_LALT|IEQUALIFIER_RALT))
  1522.                         QualType = 2;
  1523.                     else
  1524.                     {
  1525.                         if(Qualifier & IEQUALIFIER_CONTROL)
  1526.                             QualType = 3;
  1527.                     }
  1528.                 }
  1529.  
  1530.                     /* Send the corresponding string. */
  1531.  
  1532.                 SerialCommand(CursorKeys -> Keys[QualType][i]);
  1533.             }
  1534.  
  1535.             return(TRUE);
  1536.         }
  1537.     }
  1538.  
  1539.         /* Then take a look at the numeric pad. */
  1540.  
  1541.     for(i = 4 ; i < 24 ; i++)
  1542.     {
  1543.             /* Is this the character we want? */
  1544.  
  1545.         if(Table[i] . Char == Char)
  1546.         {
  1547.                 /* If in numeric keypad applications mode,
  1548.                  * send the corresponding string.
  1549.                  */
  1550.  
  1551.             if(Config -> EmulationConfig -> NumericMode == KEYMODE_APPLICATION)
  1552.                 SerWrite(Table[i] . ApplicationString,strlen(Table[i] . ApplicationString));
  1553.             else
  1554.             {
  1555.                     /* Is this the return key? */
  1556.  
  1557.                 if(i == 23)
  1558.                 {
  1559.                     switch(Config -> TerminalConfig -> SendCR)
  1560.                     {
  1561.                         case CR_ASCR:
  1562.  
  1563.                             SerWrite("\r",1);
  1564.                             break;
  1565.  
  1566.                         case CR_ASCRLF:
  1567.  
  1568.                             SerWrite("\r\n",2);
  1569.                             break;
  1570.                     }
  1571.                 }
  1572.                 else
  1573.                     SerWrite(Table[i] . VanillaString,strlen(Table[i] . VanillaString));
  1574.             }
  1575.  
  1576.             return(TRUE);
  1577.         }
  1578.     }
  1579.  
  1580.     return(FALSE);
  1581. }
  1582.  
  1583.     /* ConvertKey():
  1584.      *
  1585.      *    The actual key conversion routine.
  1586.      */
  1587.  
  1588. STATIC LONG __inline
  1589. ConvertKey(ULONG Qualifier,UWORD Code,APTR IAddress,STRPTR Buffer,LONG Len)
  1590. {
  1591.     LONG Actual;
  1592.  
  1593.         /* Fill in the defaults. */
  1594.  
  1595.     FakeInputEvent -> ie_Code        = Code;
  1596.     FakeInputEvent -> ie_Qualifier        = Qualifier;
  1597.     FakeInputEvent -> ie_position . ie_addr    = *((APTR *)IAddress);
  1598.  
  1599.         /* Clear the buffer (sortof). */
  1600.  
  1601.     Buffer[0] = 0;
  1602.  
  1603.         /* Convert the codes. */
  1604.  
  1605.     if((Actual = RawKeyConvert(FakeInputEvent,Buffer,Len,KeyMap)) > 0)
  1606.         return(Actual);
  1607.     else
  1608.         return(0);
  1609. }
  1610.  
  1611.     /* KeyConvert(struct IntuiMessage *Massage,STRPTR Buffer):
  1612.      *
  1613.      *    Convert a raw key information according to the
  1614.      *    current keymap settings.
  1615.      */
  1616.  
  1617. UBYTE __regargs
  1618. KeyConvert(struct IntuiMessage *Massage,STRPTR Buffer,LONG *Len)
  1619. {
  1620.     if(Buffer)
  1621.         Buffer[0] = 0;
  1622.  
  1623.     if(Len)
  1624.         *Len = 0;
  1625.  
  1626.         /* Key was pressed, not released. */
  1627.  
  1628.     if(Massage -> Class == IDCMP_RAWKEY && !(Massage -> Code & IECODE_UP_PREFIX))
  1629.     {
  1630.             /* These are the sequences mapped to special
  1631.              * control keys (cursor keys, function keys,
  1632.              * the help key).
  1633.              */
  1634.  
  1635.         STATIC struct { STRPTR RawCode; UBYTE Result; } ConversionTable[15] =
  1636.         {
  1637.             (STRPTR)"A",    CUP,
  1638.             (STRPTR)"B",    CDN,
  1639.             (STRPTR)"C",    CFW,
  1640.             (STRPTR)"D",    CBK,
  1641.  
  1642.             (STRPTR)"?~",    HLP,
  1643.  
  1644.             (STRPTR)"0~",    FN1,
  1645.             (STRPTR)"1~",    FN2,
  1646.             (STRPTR)"2~",    FN3,
  1647.             (STRPTR)"3~",    FN4,
  1648.             (STRPTR)"4~",    FN5,
  1649.             (STRPTR)"5~",    FN6,
  1650.             (STRPTR)"6~",    FN7,
  1651.             (STRPTR)"7~",    FN8,
  1652.             (STRPTR)"8~",    FN9,
  1653.             (STRPTR)"9~",    F10
  1654.         };
  1655.  
  1656.         STATIC UBYTE SeqLens[15] = { 1,1,1,1,2,2,2,2,2,2,2,2,2,2,2 };
  1657.  
  1658.         UBYTE    ConvertBuffer[257];
  1659.         ULONG    Qualifier;
  1660.         LONG    Actual;
  1661.  
  1662.             /* If it's a function or cursor key, clear the qualifier. */
  1663.  
  1664.         if(Massage -> Code >= CURSOR_UP_CODE && Massage -> Code <= F10_CODE)
  1665.             Qualifier = NULL;
  1666.         else
  1667.         {
  1668.             Qualifier = Massage -> Qualifier;
  1669.  
  1670.                 /* Does it have a numeric keypad qualifier set? */
  1671.  
  1672.             if((Qualifier & (IEQUALIFIER_NUMERICPAD | IEQUALIFIER_CONTROL)) == (IEQUALIFIER_NUMERICPAD | IEQUALIFIER_CONTROL))
  1673.             {
  1674.                     /* Look at the vanilla result. */
  1675.  
  1676.                 if(ConvertKey(Qualifier & ~(IEQUALIFIER_CONTROL | IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT | IEQUALIFIER_LALT | IEQUALIFIER_RALT),Massage -> Code,Massage -> IAddress,ConvertBuffer,1))
  1677.                 {
  1678.                     STRPTR String;
  1679.  
  1680.                         /* Take a look at the results. */
  1681.  
  1682.                     switch(ConvertBuffer[0])
  1683.                     {
  1684.                         case '[':
  1685.  
  1686.                             String = "\033OP";
  1687.                             break;
  1688.  
  1689.                         case ']':
  1690.  
  1691.                             String = "\033OQ";
  1692.                             break;
  1693.  
  1694.                         case '/':
  1695.  
  1696.                             String = "\033OR";
  1697.                             break;
  1698.  
  1699.                         case '*':
  1700.  
  1701.                             String = "\033OS";
  1702.                             break;
  1703.  
  1704.                         default:
  1705.  
  1706.                             String = NULL;
  1707.                             break;
  1708.                     }
  1709.  
  1710.                         /* Return the PFx key code. */
  1711.  
  1712.                     if(String)
  1713.                     {
  1714.                         if(Buffer)
  1715.                             memcpy(Buffer,String,3);
  1716.  
  1717.                         if(Len)
  1718.                             *Len = 3;
  1719.  
  1720.                         return('\033');
  1721.                     }
  1722.                 }
  1723.             }
  1724.  
  1725.                 /* Does it have a shift qualifier set? */
  1726.  
  1727.             if(Qualifier & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT))
  1728.             {
  1729.                     /* Do the conversion... */
  1730.  
  1731.                 if(ConvertKey(Qualifier & ~(IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT),Massage -> Code,Massage -> IAddress,ConvertBuffer,1))
  1732.                 {
  1733.                         /* Did it produce a tab key? If so, transfer
  1734.                          * Esc tab instead.
  1735.                          */
  1736.  
  1737.                     if(ConvertBuffer[0] == '\t')
  1738.                     {
  1739.                         if(Len)
  1740.                             *Len = 2;
  1741.  
  1742.                         if(Buffer)
  1743.                             memcpy(Buffer,"\033\t",2);
  1744.  
  1745.                         return('\033');
  1746.                     }
  1747.                 }
  1748.             }
  1749.  
  1750.                 /* Does it have the control qualifier set? */
  1751.  
  1752.             if(Qualifier & IEQUALIFIER_CONTROL)
  1753.             {
  1754.                     /* Do the conversion... */
  1755.  
  1756.                 if(ConvertKey(Qualifier & ~IEQUALIFIER_CONTROL,Massage -> Code,Massage -> IAddress,ConvertBuffer,1))
  1757.                 {
  1758.                         /* Did it produce a space or an `at' sign? */
  1759.  
  1760.                     if(ConvertBuffer[0] == ' ' || ConvertBuffer[0] == '@')
  1761.                     {
  1762.                             /* If so, produce a nul instead. */
  1763.  
  1764.                         if(Len)
  1765.                             *Len = 1;
  1766.  
  1767.                         if(Buffer)
  1768.                             Buffer[0] = 0;
  1769.  
  1770.                         return(0);
  1771.                     }
  1772.                 }
  1773.             }
  1774.         }
  1775.  
  1776.             /* Do the final conversion... */
  1777.  
  1778.         if(Actual = ConvertKey(Qualifier,Massage -> Code,Massage -> IAddress,ConvertBuffer,256))
  1779.         {
  1780.                 /* Did we get anything in return? */
  1781.  
  1782.             if(ConvertBuffer[0])
  1783.             {
  1784.                     /* Are we to swap the backspace and
  1785.                      * delete keys?
  1786.                      */
  1787.  
  1788.                 if(Config -> EmulationConfig -> SwapBSDelete)
  1789.                 {
  1790.                     register WORD i;
  1791.  
  1792.                     for(i = 0 ; i < Actual ; i++)
  1793.                     {
  1794.                         if(ConvertBuffer[i] == BKS)
  1795.                             ConvertBuffer[i] = DEL;
  1796.                         else
  1797.                         {
  1798.                             if(ConvertBuffer[i] == DEL)
  1799.                                 ConvertBuffer[i] = BKS;
  1800.                         }
  1801.                     }
  1802.                 }
  1803.  
  1804.                     /* Translated sequence starts
  1805.                      * with a CSI, let's have a look
  1806.                      * at the associated control
  1807.                      * key.
  1808.                      */
  1809.  
  1810.                 if(ConvertBuffer[0] == CSI)
  1811.                 {
  1812.                     register WORD i;
  1813.  
  1814.                     for(i = 0 ; i < sizeof(SeqLens) ; i++)
  1815.                     {
  1816.                             /* Does it match? */
  1817.  
  1818.                         if(!memcmp(&ConvertBuffer[1],ConversionTable[i] . RawCode,SeqLens[i]))
  1819.                         {
  1820.                                 /* Store the length. */
  1821.  
  1822.                             if(Len)
  1823.                                 *Len = 1;
  1824.  
  1825.                                 /* Store the result. */
  1826.  
  1827.                             if(Buffer)
  1828.                             {
  1829.                                 Buffer[0] = ConversionTable[i] . Result;
  1830.                                 Buffer[1] = 0;
  1831.                             }
  1832.  
  1833.                             return(ConversionTable[i] . Result);
  1834.                         }
  1835.                     }
  1836.                 }
  1837.  
  1838.                     /* Store the number of characters converted. */
  1839.  
  1840.                 if(Len)
  1841.                     *Len = Actual;
  1842.  
  1843.                     /* Store the converted characters. */
  1844.  
  1845.                 if(Buffer)
  1846.                     memcpy(Buffer,ConvertBuffer,Actual);
  1847.  
  1848.                 return(ConvertBuffer[0]);
  1849.             }
  1850.         }
  1851.     }
  1852.  
  1853.     return(0);
  1854. }
  1855.  
  1856.     /* GfxText(struct RastPort *RPort,STRPTR Buffer,LONG Length):
  1857.      *
  1858.      *    Text output, if necessary switching from gfx font
  1859.      *    to current default font.
  1860.      */
  1861.  
  1862. VOID __regargs
  1863. GfxText(struct RastPort *RPort,STRPTR Buffer,LONG Length)
  1864. {
  1865.     BYTE TextMode;
  1866.     LONG SameMode;
  1867.  
  1868.         /* Determine current text rendering mode. */
  1869.  
  1870.     if(GfxTable[Buffer[0]] == MODE_GFX)
  1871.         TextMode = MODE_GFX;
  1872.     else
  1873.     {
  1874.         TextMode = MODE_STANDARD;
  1875.  
  1876.         SetFont(RPort,TextFont);
  1877.     }
  1878.  
  1879.         /* Reset number of characters in common mode. */
  1880.  
  1881.     SameMode = 0;
  1882.  
  1883.         /* Scan until all input is processed. */
  1884.  
  1885.     FOREVER
  1886.     {
  1887.             /* Scan for characters in the current mode. */
  1888.  
  1889.         while(GfxTable[Buffer[SameMode]] == TextMode && SameMode < Length)
  1890.             SameMode++;
  1891.  
  1892.             /* Output the text found. */
  1893.  
  1894.         Text(RPort,Buffer,SameMode);
  1895.  
  1896.             /* Decrement number of remaining bytes. */
  1897.  
  1898.         Length -= SameMode;
  1899.  
  1900.             /* Anything left? */
  1901.  
  1902.         if(Length)
  1903.         {
  1904.                 /* Skip to next character. */
  1905.  
  1906.             Buffer        += SameMode;
  1907.             SameMode     = 0;
  1908.  
  1909.                 /* Change text output mode. */
  1910.  
  1911.             if(TextMode == MODE_GFX)
  1912.             {
  1913.                 SetFont(RPort,TextFont);
  1914.  
  1915.                 TextMode = MODE_STANDARD;
  1916.             }
  1917.             else
  1918.             {
  1919.                 SetFont(RPort,GFX);
  1920.  
  1921.                 TextMode = MODE_GFX;
  1922.             }
  1923.         }
  1924.         else
  1925.             break;
  1926.     }
  1927.  
  1928.         /* Reset font type. */
  1929.  
  1930.     if(TextMode == MODE_STANDARD)
  1931.         SetFont(RPort,GFX);
  1932. }
  1933.  
  1934.     /* DoBackspace():
  1935.      *
  1936.      *    Special function: perform backspace.
  1937.      */
  1938.  
  1939. BYTE __regargs
  1940. DoBackspace()
  1941. {
  1942.     Capture("\b",1);
  1943.  
  1944.     if(CursorX)
  1945.     {
  1946.         CursorX--;
  1947.  
  1948.             /* If destructive, shift the remaining line
  1949.              * one character to the right.
  1950.              */
  1951.  
  1952.         if(Config -> EmulationConfig -> DestructiveBackspace)
  1953.         {
  1954.             WORD DeltaX,MinX;
  1955.  
  1956.             BackupRender();
  1957.  
  1958.             RasterEraseCharacters(1);
  1959.  
  1960.             if(Config -> EmulationConfig -> FontScale == SCALE_NORMAL)
  1961.             {
  1962.                 if(RasterAttr[CursorY] == SCALE_ATTR_NORMAL)
  1963.                 {
  1964.                     DeltaX    = TextFontWidth;
  1965.                     MinX    = MUL_X(CursorX);
  1966.                 }
  1967.                 else
  1968.                 {
  1969.                     DeltaX    = TextFontWidth / 2;
  1970.                     MinX    = MUL_X(CursorX) / 2;
  1971.                 }
  1972.             }
  1973.             else
  1974.             {
  1975.                 if(RasterAttr[CursorY] == SCALE_ATTR_NORMAL)
  1976.                 {
  1977.                     DeltaX    = TextFontWidth / 2;
  1978.                     MinX    = MUL_X(CursorX) / 2;
  1979.                 }
  1980.                 else
  1981.                 {
  1982.                     DeltaX    = TextFontWidth;
  1983.                     MinX    = MUL_X(CursorX);
  1984.                 }
  1985.             }
  1986.  
  1987.             ScrollLineEraseCharacters(1);
  1988.  
  1989.             ScrollLineRaster(RPort,DeltaX,0,MinX,MUL_Y(CursorY),LastPixel,MUL_Y(CursorY + 1) - 1,FALSE);
  1990.  
  1991.             BackupRender();
  1992.         }
  1993.  
  1994.         ClipBlitCursor(FALSE,TRUE);
  1995.     }
  1996.  
  1997.     return(FALSE);
  1998. }
  1999.  
  2000.     /* DoBeep():
  2001.      *
  2002.      *    The real interface to the beep routine.
  2003.      */
  2004.  
  2005. BYTE __regargs
  2006. DoBeep()
  2007. {
  2008.         /* Handle the visual part. */
  2009.  
  2010.     if(Config -> TerminalConfig -> BellMode != BELL_AUDIBLE)
  2011.     {
  2012.         if(StatusProcess)
  2013.             Signal(StatusProcess,SIG_BELL);
  2014.     }
  2015.  
  2016.         /* Let it beep. */
  2017.  
  2018.     if(Config -> TerminalConfig -> BellMode == BELL_AUDIBLE || Config -> TerminalConfig -> BellMode == BELL_BOTH)
  2019.         Beep();
  2020.  
  2021.         /* Capture the bell. */
  2022.  
  2023.     if(Config -> CaptureConfig -> CaptureFilterMode == FILTER_NONE)
  2024.         Capture("\a",1);
  2025.  
  2026.     return(FALSE);
  2027. }
  2028.  
  2029.     /* DoxON():
  2030.      *
  2031.      *    Perform XON (stop data flow).
  2032.      */
  2033.  
  2034. BYTE __regargs
  2035. DoxON()
  2036. {
  2037.     if(Config -> SerialConfig -> xONxOFF)
  2038.         Status = STATUS_HOLDING;
  2039.  
  2040.     return(FALSE);
  2041. }
  2042.  
  2043.     /* DoLF():
  2044.      *
  2045.      *    Special function: perform line feed.
  2046.      */
  2047.  
  2048. BYTE __regargs
  2049. DoLF()
  2050. {
  2051.     if(Config -> TerminalConfig -> ReceiveLF == LF_ASLFCR)
  2052.     {
  2053.         CursorX = 0;
  2054.  
  2055.         DownLine();
  2056.  
  2057.         ClipBlitCursor(FALSE,TRUE);
  2058.  
  2059.         Capture("\n",1);
  2060.     }
  2061.     else
  2062.     {
  2063.         if(Config -> TerminalConfig -> ReceiveLF == LF_ASLF)
  2064.         {
  2065.             DownLine();
  2066.  
  2067.             ClipBlitCursor(FALSE,TRUE);
  2068.         }
  2069.     }
  2070.  
  2071.     return(FALSE);
  2072. }
  2073.  
  2074.     /* DoShiftIn():
  2075.      *
  2076.      *    Special function: Shift into graphics mode
  2077.      */
  2078.  
  2079. BYTE __regargs
  2080. DoShiftIn()
  2081. {
  2082.     if(CharMode[1] == TABLE_GFX && GFX)
  2083.         CurrentFont = GFX;
  2084.  
  2085.     if(CharMode[1] == TABLE_ASCII)
  2086.         CurrentFont = TextFont;
  2087.  
  2088.     SetFont(RPort,CurrentFont);
  2089.  
  2090.     ConOutputUpdate();
  2091.  
  2092.     Charset = 1;
  2093.  
  2094.     return(FALSE);
  2095. }
  2096.  
  2097.     /* DoShiftOut():
  2098.      *
  2099.      *    Special function: Shift out of graphics mode
  2100.      */
  2101.  
  2102. BYTE __regargs
  2103. DoShiftOut()
  2104. {
  2105.     if(CharMode[0] == TABLE_GFX && GFX)
  2106.         CurrentFont = GFX;
  2107.  
  2108.     if(CharMode[0] == TABLE_ASCII)
  2109.         CurrentFont = TextFont;
  2110.  
  2111.     SetFont(RPort,CurrentFont);
  2112.  
  2113.     ConOutputUpdate();
  2114.  
  2115.     Charset = 0;
  2116.  
  2117.     return(FALSE);
  2118. }
  2119.  
  2120.     /* DoCR_LF():
  2121.      *
  2122.      *    Special function: perform carriage return and line feed.
  2123.      */
  2124.  
  2125. BYTE __regargs
  2126. DoCR_LF()
  2127. {
  2128.     CursorX = 0;
  2129.  
  2130.     DownLine();
  2131.  
  2132.     ClipBlitCursor(FALSE,TRUE);
  2133.  
  2134.     Capture("\n",1);
  2135.  
  2136.     return(FALSE);
  2137. }
  2138.  
  2139.     /* DoFF():
  2140.      *
  2141.      *    Special function: perform form feed.
  2142.      */
  2143.  
  2144. BYTE __regargs
  2145. DoFF()
  2146. {
  2147.     if(Config -> EmulationConfig -> NewLineMode)
  2148.     {
  2149.         CursorX = 0;
  2150.  
  2151.         DoCR_LF();
  2152.     }
  2153.     else
  2154.     {
  2155.         EraseScreen("2");
  2156.  
  2157.         CursorX = CursorY = 0;
  2158.  
  2159.         ClipBlitCursor(FALSE,TRUE);
  2160.  
  2161.         ConFontScaleUpdate();
  2162.  
  2163.         Capture("\n",1);
  2164.     }
  2165.  
  2166.     return(FALSE);
  2167. }
  2168.  
  2169.     /* DoLF_FF_VT():
  2170.      *
  2171.      *    Special function: handle line feed, form feed and vertical
  2172.      *    tab.
  2173.      */
  2174.  
  2175. BYTE __regargs
  2176. DoLF_FF_VT()
  2177. {
  2178.     if(Config -> EmulationConfig -> NewLineMode)
  2179.         DoCR_LF();
  2180.     else
  2181.         DoLF();
  2182.  
  2183.     return(FALSE);
  2184. }
  2185.  
  2186.     /* DoCR():
  2187.      *
  2188.      *    Special function: handle carriage return.
  2189.      */
  2190.  
  2191. BYTE __regargs
  2192. DoCR()
  2193. {
  2194.     if(Config -> EmulationConfig -> NewLineMode || Config -> TerminalConfig -> ReceiveCR == CR_ASCRLF)
  2195.         DoCR_LF();
  2196.     else
  2197.     {
  2198.         if(Config -> TerminalConfig -> ReceiveCR == CR_ASCR)
  2199.         {
  2200.             CursorX = 0;
  2201.  
  2202.             ClipBlitCursor(FALSE,TRUE);
  2203.  
  2204.             Capture("\n",1);
  2205.         }
  2206.     }
  2207.  
  2208.     return(FALSE);
  2209. }
  2210.  
  2211.     /* DoTab():
  2212.      *
  2213.      *    Special function: handle tab, move cursor to next
  2214.      *    tab stop.
  2215.      */
  2216.  
  2217. BYTE __regargs
  2218. DoTab()
  2219. {
  2220.     WORD Column;
  2221.  
  2222.     if(RasterAttr[CursorY] == SCALE_ATTR_NORMAL)
  2223.         Column = LastColumn;
  2224.     else
  2225.         Column = ((LastColumn + 1) / 2) - 1;
  2226.  
  2227.     if(Config -> EmulationConfig -> LineWrap)
  2228.     {
  2229.         if(CursorX >= LastColumn)
  2230.         {
  2231.             CursorX = 0;
  2232.  
  2233.             DownLine();
  2234.         }
  2235.         else
  2236.         {
  2237.             while(CursorX < Column)
  2238.             {
  2239.                 CursorX++;
  2240.  
  2241.                 if(TabStops[CursorX])
  2242.                     break;
  2243.             }
  2244.         }
  2245.     }
  2246.     else
  2247.     {
  2248.         while(CursorX < Column)
  2249.         {
  2250.             CursorX++;
  2251.  
  2252.             if(TabStops[CursorX])
  2253.                 break;
  2254.         }
  2255.     }
  2256.  
  2257.     ClipBlitCursor(FALSE,TRUE);
  2258.  
  2259.     Capture("\t",1);
  2260.  
  2261.     return(FALSE);
  2262. }
  2263.  
  2264.     /* DoEnq():
  2265.      *
  2266.      *    Special function: send answerback message.
  2267.      */
  2268.  
  2269. BYTE __regargs
  2270. DoEnq()
  2271. {
  2272.     if(Config -> EmulationConfig -> AnswerBack[0])
  2273.         SerialCommand(Config -> EmulationConfig -> AnswerBack);
  2274.  
  2275.     return(FALSE);
  2276. }
  2277.  
  2278.     /* DoEsc():
  2279.      *
  2280.      *    Start new control sequence.
  2281.      */
  2282.  
  2283. BYTE __regargs
  2284. DoEsc()
  2285. {
  2286.     if(Config -> TerminalConfig -> EmulationMode == EMULATION_TTY)
  2287.         (* ConDump)("^",1);
  2288.  
  2289.     return(TRUE);
  2290. }
  2291.  
  2292.     /* DoCsi():
  2293.      *
  2294.      *    Start new control sequence.
  2295.      */
  2296.  
  2297. BYTE __regargs
  2298. DoCsi()
  2299. {
  2300.     if(Config -> TerminalConfig -> EmulationMode == EMULATION_TTY)
  2301.         (* ConDump)("^[",2);
  2302.  
  2303.     ParseCode('[');
  2304.  
  2305.     return(TRUE);
  2306. }
  2307.  
  2308.     /* DoNewEsc(UBYTE Char):
  2309.      *
  2310.      *    Start new control sequence.
  2311.      */
  2312.  
  2313. BYTE __regargs
  2314. DoNewEsc(UBYTE Char)
  2315. {
  2316.     if(Config -> TerminalConfig -> EmulationMode == EMULATION_TTY)
  2317.         (* ConDump)("^",1);
  2318.  
  2319.     DoCancel();
  2320.  
  2321.     return(TRUE);
  2322. }
  2323.  
  2324.     /* DoNewCsi(UBYTE Char):
  2325.      *
  2326.      *    Start new control sequence.
  2327.      */
  2328.  
  2329. BYTE __regargs
  2330. DoNewCsi(UBYTE Char)
  2331. {
  2332.     if(Config -> TerminalConfig -> EmulationMode == EMULATION_TTY)
  2333.         (* ConDump)("^[",2);
  2334.  
  2335.     DoCancel();
  2336.  
  2337.     return(ParseCode('['));
  2338. }
  2339.