#INCLUDE "ioserver.inc" PROC read.line (CHAN OF KEYBOARD keyin, CHAN OF SCREEN screen, INT len, []BYTE line) --{{{ declarations BOOL running : BYTE key : VAL delete IS 127(BYTE) : VAL backspace IS 8(BYTE) : VAL delete.string IS [backspace, ' ', backspace] : --}}} SEQ len := 0 running := TRUE WHILE running SEQ keyin ? key --{{{ add to line, echo, and check for '*c' IF --{{{ return key - finished key = '*c' running := FALSE --}}} --{{{ newline key - skip key = '*n' SKIP --}}} --{{{ delete key (key = delete) OR (key = backspace) IF len > 0 SEQ -- output backspace, space, backspace screen ! string; 3 :: delete.string len := len - 1 TRUE SKIP --}}} --{{{ if it fits on the line, add it len < (SIZE line) SEQ line [len] := key screen ! char; key len := len + 1 --}}} if it fits on the line, add it --{{{ otherwise skip TRUE SKIP --}}} --}}} add to line, echo, and check for '*c' :