home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / lilith / m2term.mod < prev    next >
Text File  |  2020-01-01  |  4KB  |  135 lines

  1. IMPLEMENTATION MODULE KermTerm;
  2. (************************************************************************)
  3. (*  Term connects the local Kermit to a remote host                     *)
  4. (*  written:            09.10.85     Matthias Aebi                      *)
  5. (*  last modification:  18.03.86     Matthias Aebi                      *)
  6. (************************************************************************)
  7.  
  8. FROM Terminal    IMPORT WriteString, WriteLn, Write;
  9. FROM KermMisc    IMPORT InitPort, SendChar, RecvChar, SendBreak,
  10.                         WriteChar, ReadChar, BitAND, ClrScr;
  11. FROM KermParam   IMPORT LEscChar, LCurrPort, LEcho;
  12. FROM KermShow    IMPORT Show;
  13. FROM TextScreen  IMPORT FreeLines;
  14.  
  15. (************************************************************************)
  16.                               PROCEDURE Term;
  17. (************************************************************************)
  18. CONST
  19.     BELL = 7C;
  20.     EOL  = 36C;
  21.     CR   = 15C;
  22.     LF   = 12C;
  23.     XON  = 21C;
  24.     XOFF = 23C;
  25.  
  26. VAR
  27.     escRecv : BOOLEAN;
  28.     done    : BOOLEAN;
  29.     ch      : CHAR;
  30.  
  31. BEGIN
  32.     ClrScr;
  33.     WriteString("Connected to remote host. Type ");
  34.     WriteChar(LEscChar);
  35.     WriteString(" c to return to local Kermit"); WriteLn;
  36.     InitPort(LCurrPort);
  37.     done    := FALSE;
  38.     escRecv := FALSE;
  39.  
  40.     REPEAT
  41.         IF RecvChar(ch, LCurrPort)   (* Busy Read *)
  42.         THEN
  43.             ch := CHAR(BitAND(CARDINAL(ch),7FH));
  44.             Write(ch);
  45.  
  46.             IF FreeLines() < 2
  47.             THEN
  48.                 SendChar(XOFF, LCurrPort);
  49.                 WriteLn;
  50.                 WriteString("--- press any key ---");
  51.                 WHILE NOT ReadChar(ch) DO
  52.                     ;
  53.                 END;
  54.                 ClrScr;
  55.                 SendChar(XON, LCurrPort);
  56.             END;
  57.         END;
  58.  
  59.         IF ReadChar(ch)
  60.         THEN
  61.             IF ch = EOL
  62.             THEN
  63.                 ch := CR;
  64.             END;
  65.  
  66.  
  67.             IF ch = LEscChar
  68.             THEN
  69.                 IF escRecv
  70.                 THEN
  71.                     SendChar(ch, LCurrPort);
  72.                     escRecv := FALSE;
  73.                     IF LEcho
  74.                     THEN
  75.                         Write(ch);
  76.                     END;
  77.                 ELSE
  78.                     escRecv := TRUE;
  79.                 END;
  80.             ELSE
  81.                 IF escRecv
  82.                 THEN
  83.                     IF ch = "?"
  84.                     THEN
  85.                         WriteLn;
  86.                         WriteString("Available commands are:");
  87.                         WriteLn;
  88.                         WriteString("?  Displays this Message");
  89.                         WriteLn;
  90.                         WriteString("c  Close the connection");
  91.                         WriteLn;
  92.                         WriteString("s  Show status information");
  93.                         WriteLn;
  94.                         WriteString("b  Send a line break");
  95.                         WriteLn;
  96.                         WriteString("0  Send ASCII 0 (NUL)");
  97.                         WriteLn;
  98.                         WriteString("^\ (or whatever the escape character");
  99.                         WriteString("   is defined as) Send esc character");
  100.                         WriteLn;
  101.                     ELSIF ch = "0"
  102.                     THEN
  103.                         SendChar(0C, LCurrPort);
  104.                     ELSE
  105.                         CASE CAP(ch) OF
  106.                         "C":
  107.                             done := TRUE; |
  108.  
  109.                         "B":
  110.                             SendBreak(LCurrPort); |
  111.  
  112.                         "S":
  113.                             Show;
  114.  
  115.                         ELSE
  116.                             escRecv := FALSE;
  117.                             Write(BELL);
  118.                         END;
  119.                     END;
  120.                 ELSE
  121.                     SendChar(ch, LCurrPort);
  122.                     IF LEcho
  123.                     THEN
  124.                         Write(ch);
  125.                     END;
  126.                 END;
  127.             END;
  128.         END;
  129.     UNTIL done;
  130.     WriteLn;
  131.     WriteLn;
  132. END Term;
  133.  
  134. END KermTerm.
  135.