Text preview for : StreamIO.mesa_Oct77.pdf part of xerox StreamIO.mesa Oct77 xerox mesa 3.0_1977 listing StreamIO.mesa_Oct77.pdf
Back to : StreamIO.mesa_Oct77.pdf | Home
streamio.mESA 24-0CT-77 18:57:26 Pag9 1
-- StreamlO.Mesa Edited by Sandman on July 22, 1977 11:07 AM
DIRECTORY
IODefs: FROM "iodefs",
InlineDefs: FROM "in11nedefs".
StreamDefs: FROM "streamdefs",
Str1ngDefs: FROM "stringdefs":
DEFINITIONS FROM StreamDefs, IODefs:
StreamlO: PROGRAM [Input. Output: StreamHandle]
IMPORTS StreamDefs. StringDefs EXPORTS lODefs SHARES IODefs. StreamDefs PUBLIC
BEGIN
BeginLine: PRIVATE BOOLEAN ~ TRUE:
GetInputStream: PROCEDURE RETURNS [StreamHandle] a
BEGIN
RETURN[Input]
END:
GetOutputStream: PROCEDURE RETURNS [StreamHandle] =
BEGIN
RETURN[Output]
END:
-- Character operations
ReadChar: PROCEDURE RETURNS [CHARACTER] =
BEGIN
RETURN[Input.get[Input]]:
END:
WriteChar: PROCEDURE [c:CHARACTER] =
BEGIN
Output.put[Output. c]:
BeginLine ~ c = CR:
END:
-- Reading Strings
ReadString: PROCEDURE [s:STRING. t:PROCEDURE[CHARACTER]RETURNS(BOOLEAN]]
BEGIN
WriteChar[ReadEditedString[s.t.TRUE]]:
END:
ReadID: PROCEDURE [s:STRING] =
BEGIN
[] ~ ReadEditedString[s.atomfound.TRUE]:
END;
ReadLine: PROCEDURE [s:STRING] =
BEGIN
[] ~ ReadEditedString[s.crfound.TRUE];
WriteChar[CR];
END;
crfound: PRIVATE PROCEDURE [c:CHARACTER] RETURNS [BOOLEAN] =
B[GIN RETURN [c = CR] END:
atomfound: PRIVATE PROCEDURF [c:CHARACTER] RETURNS [BOOLEAN]
B[GIN RrTURN [c = CR OR c = SP] END:
Rubout: SIGNAL = CODF:
LineOverflow: SIGNAL [5: STRING] RETURNS ens: STRING] CODE:
-- the editing characters
controlA: CIlARACTrR 1C; delete character
controlll: CIlARAcrrR laC: delete character
conlrolW: CIIARACTER 27C: delete word
controlQ: CIIARACHR 21C: delete word
controlX: CIIARACHR JOC: delete 1 ine
streamio.mESA 24-0CT-77 18:57:26 Page 2
controlR: CHARACTER = 22C; retype line
controlV: CHARACTER = 26C; quote next character
ESC: CHARACTER = 33C; use old string
ReadEditedString: PROCEDURE [s:STRING, t:PROCEDURE [CHARACTER] RETURNS [BOOLEAN], newstring:BOOLEAN] RE
**TURNS[CHARACTER] =
BEGIN
c: CHARACTER;
i: CARDINAL;
state: {TrailingInvisible, Visible, LeadingInvisible};
c ~ Input.get[Input]:
IF newstring THEN
IF c = ESC THEN
BEGIN WriteString[s]; c ~ Input.get[Input]; END
ELSE s. length ~ 0;
UNTIL t[c] DO SELECT c FROM
DEL => SIGNAL Rubout;
controlA, controlH =)
BEGIN
IF s. length> 0 THEN
BEGIN
WITH Output SELECT FROM
Display => ClearDisplayChar[Output,s[s.length-1]];
ENDCASE => Output.put[OutPut.c];
s. length ~ s. length-1;
END;
END:
controlW, controlQ .>
BEGIN -- text to be backed up is of the form
-- ...
-- the are to be removed.
state ~ Trailinglnvisible;
FOR i DECREASING IN [O .. s.length) DO
SELECT sCi] FROM
IN ['A .. 'Z], IN ['a .. 'z], IN ['0 .. '9] =>
IF state