MODULE overstrike; (*DEE 2014-08-06*) FROM ST IMPORT getc, putc; FROM STchars IMPORT BACKSPACE, BLANK, ENDFILE, NEWLINE, PLUS, character; FROM STutility IMPORT max; (*overstrike: convert backspaces into multiple lines.*) PROCEDURE overstrike; CONST SKIP = BLANK; NOSKIP = PLUS; VAR col, newcol, i: INTEGER; c: character; BEGIN col := 1; REPEAT newcol := col; WHILE (getc(c) = BACKSPACE) DO (* Eat backspaces. *) newcol := max(newcol - 1, 1) END; IF (newcol < col) THEN putc(NEWLINE); (* Start overstrike line. *) putc(NOSKIP); FOR i := 1 TO newcol - 1 DO putc(BLANK) END; col := newcol ELSIF (col = 1) AND (c # ENDFILE) THEN putc(SKIP) (* normal line *) (* ELSE middle of line *) END; IF (c # ENDFILE) THEN putc(c); (* normal character *) IF (c = ENDFILE) THEN col := 1 ELSE INC(col) END END UNTIL (c = ENDFILE) END overstrike; BEGIN overstrike END overstrike.