TSItemListFromRopeImpl.mesa
Making lists from ropes
Michael Plass, November 2, 1982 10:32 am
DIRECTORY Ascii, TSTypes, TSObject, TSFont, TSOps, Rope;
TSItemListFromRopeImpl: CEDAR PROGRAM
IMPORTS TSObject, Rope
EXPORTS TSOps =
BEGIN OPEN TSTypes;
ROPE: TYPE = Rope.ROPE;
RopeDataRec: TYPE = RECORD [
font: TSFont.Ref,
rope: ROPE
];
ItemListFromRope: PUBLIC PROCEDURE [
font: TSFont.Ref,
rope: ROPE
] RETURNS [ropeList: TSObject.ItemList] = {
r: REF RopeDataRec ← NEW[RopeDataRec];
r.font ← font;
r.rope ← rope;
ropeList ← TSObject.CreateItemList[
producer: ProduceFromRope,
writerData: r];
};
ProduceFromRope: TSObject.ProducerProc = {
r: REF RopeDataRec ← NARROW[listWriter.writerData];
n: INT ← 0;
ProduceChar: SAFE PROC [ch: CHAR] RETURNS [BOOLEANFALSE] = TRUSTED {
SELECT ch FROM
Ascii.SP, Ascii.TAB => listWriter.ProduceFromRope[r.font, r.rope, n, space];
Ascii.CR => {};
ENDCASE => listWriter.ProduceFromRope[r.font, r.rope, n, char];
n ← n + 1;
};
IF r # NIL THEN {
[] ← Rope.Map[base: r.rope, action: ProduceChar];
listWriter.writerData ← NIL;
}
ELSE listWriter.ProduceEnd[];
};
END.
Michael Plass, September 29, 1982 11:33 am: changed Rope.SP to Ascii.SP, etc.
Michael Plass, November 2, 1982 10:32 am. CEDARized.