TTOutputImpl.mesa
Michael Plass, December 13, 1982 3:34 pm
DIRECTORY
Ascii, IO, Rope, TTOutput;
TTOutputImpl: PROGRAM
IMPORTS IO
EXPORTS TTOutput =
BEGIN
maxSpacesInCurrentLine: NAT ← 10;
Create: PUBLIC PROCEDURE [stream: IO.STREAM] RETURNS [self: TTOutput.Ref] = {
self ← NEW[TTOutput.Rep];
self.stream ← stream;
};
Space: PUBLIC PROCEDURE [self: TTOutput.Ref] = {
IF self.spacesInCurrentLine >= maxSpacesInCurrentLine THEN EndLine[self];
self.stream.PutChar[Ascii.SP]; self.spacesInCurrentLine ← self.spacesInCurrentLine + 1;
self.lastThingWasControlSequence ← FALSE;
};
EndLine: PUBLIC PROCEDURE [self: TTOutput.Ref] = {
self.stream.PutChar[Ascii.CR];
THROUGH [0..self.level] DO self.stream.PutChar[Ascii.TAB] ENDLOOP;
self.spacesInCurrentLine ← 0;
};
ControlSeq: PUBLIC PROCEDURE [self: TTOutput.Ref, name: Rope.ROPE] = {
self.stream.PutChar['\\];
self.stream.PutRope[name];
};
BeginGroup: PUBLIC PROCEDURE [self: TTOutput.Ref] = {
self.stream.PutChar['{];
self.level ← self.level + 1;
self.lastThingWasControlSequence ← FALSE;
};
EndGroup: PUBLIC PROCEDURE [self: TTOutput.Ref] = {
self.stream.PutChar['}];
self.level ← self.level - 1;
self.lastThingWasControlSequence ← FALSE;
};
Close: PUBLIC PROCEDURE [self: TTOutput.Ref] = {
};
END.
Michael Plass, December 9, 1982 9:28 am. Created.