TextLooksImpl.mesa
Copyright Ó 1985, 1986, 1988, 1991, 1992 by Xerox Corporation. All rights reserved.
written by Bill Paxton, February 1981
Bill Paxton, December 13, 1982 1:17 pm
Maxwell, January 5, 1983 3:54 pm
Russ Atkinson, July 25, 1983 3:36 pm
Michael Plass, September 24, 1991 2:20 pm PDT
Doug Wyatt, October 17, 1991 5:46 pm PDT
DIRECTORY
Rope USING [Concat, Fetch, FromChar, ROPE, Size],
Rosary USING [Fetch, Size],
TextEdit USING [LooksFromItem],
TextLooks USING [Look, Looks, noLooks, Runs];
TextLooksImpl: CEDAR PROGRAM
IMPORTS Rope, Rosary, TextEdit
EXPORTS TextLooks
= BEGIN OPEN TextLooks;
Rope conversion
LooksToRope: PUBLIC PROC [looks: Looks] RETURNS [rope: Rope.ROPE] = {
FOR lk: Look IN Look DO
IF looks[lk] THEN rope ¬ Rope.Concat[rope, Rope.FromChar[lk]];
ENDLOOP;
};
RopeToLooks: PUBLIC PROC [rope: Rope.ROPE] RETURNS [looks: Looks] = {
looks ¬ noLooks;
FOR i: INT IN [0..Rope.Size[rope]) DO
char: CHAR ¬ Rope.Fetch[rope, i];
IF char IN Look THEN looks[char] ¬ TRUE;
ENDLOOP;
};
General operations
Size: PUBLIC PROC [base: Runs] RETURNS [size: INT] = {
RETURN[Rosary.Size[base]];
};
FetchLooks: PUBLIC PROC [runs: Runs, index: INT] RETURNS [Looks] = {
IF runs=NIL THEN RETURN [noLooks];
RETURN[TextEdit.LooksFromItem[Rosary.Fetch[runs, index]]];
};
END.