IMPLEMENTATION MODULE KermTerm; (************************************************************************) (* Term connects the local Kermit to a remote host *) (* written: 09.10.85 Matthias Aebi *) (* last modification: 18.03.86 Matthias Aebi *) (************************************************************************) FROM Terminal IMPORT WriteString, WriteLn, Write; FROM KermMisc IMPORT InitPort, SendChar, RecvChar, SendBreak, WriteChar, ReadChar, BitAND, ClrScr; FROM KermParam IMPORT LEscChar, LCurrPort, LEcho; FROM KermShow IMPORT Show; FROM TextScreen IMPORT FreeLines; (************************************************************************) PROCEDURE Term; (************************************************************************) CONST BELL = 7C; EOL = 36C; CR = 15C; LF = 12C; XON = 21C; XOFF = 23C; VAR escRecv : BOOLEAN; done : BOOLEAN; ch : CHAR; BEGIN ClrScr; WriteString("Connected to remote host. Type "); WriteChar(LEscChar); WriteString(" c to return to local Kermit"); WriteLn; InitPort(LCurrPort); done := FALSE; escRecv := FALSE; REPEAT IF RecvChar(ch, LCurrPort) (* Busy Read *) THEN ch := CHAR(BitAND(CARDINAL(ch),7FH)); Write(ch); IF FreeLines() < 2 THEN SendChar(XOFF, LCurrPort); WriteLn; WriteString("--- press any key ---"); WHILE NOT ReadChar(ch) DO ; END; ClrScr; SendChar(XON, LCurrPort); END; END; IF ReadChar(ch) THEN IF ch = EOL THEN ch := CR; END; IF ch = LEscChar THEN IF escRecv THEN SendChar(ch, LCurrPort); escRecv := FALSE; IF LEcho THEN Write(ch); END; ELSE escRecv := TRUE; END; ELSE IF escRecv THEN IF ch = "?" THEN WriteLn; WriteString("Available commands are:"); WriteLn; WriteString("? Displays this Message"); WriteLn; WriteString("c Close the connection"); WriteLn; WriteString("s Show status information"); WriteLn; WriteString("b Send a line break"); WriteLn; WriteString("0 Send ASCII 0 (NUL)"); WriteLn; WriteString("^\ (or whatever the escape character"); WriteString(" is defined as) Send esc character"); WriteLn; ELSIF ch = "0" THEN SendChar(0C, LCurrPort); ELSE CASE CAP(ch) OF "C": done := TRUE; | "B": SendBreak(LCurrPort); | "S": Show; ELSE escRecv := FALSE; Write(BELL); END; END; ELSE SendChar(ch, LCurrPort); IF LEcho THEN Write(ch); END; END; END; END; UNTIL done; WriteLn; WriteLn; END Term; END KermTerm.