MODULE TextList; (* Procedures for managing lists of texts. *) IMPORT PS, Text, LineSkip; PRIVATE CONST BigInt = 1e6; PRIVATE VAR LineBreakChar := Text.GetChar("\n", 0); PROC l := FromText(t) IS VAR i IN i := Text.FindChar(t, LineBreakChar); IF i = -1 -> l := [t] | l := (Text.Sub(t, 0, i), FromText(Text.Sub(t, i + 1, BigInt))) FI END END; (* Sets "l" to the list of '\n'-separated texts in "t". For example: | FromText("abc") => ["abc"] | FromText("abc\ndef") => ["abc", "def"] | FromText("a\n\nd\n") => ["a", "", "d", ""] A checked run-time error occurs if "t" is not a text. *) PROC w, h := Size(l) IS VAR len IN len := 0; w := 0; DO l # NIL -> w := MAX(w, PS.StringWidth(CAR(l))); len := len + 1; l := CDR(l) OD; VAR asc, dec IN asc, dec := PS.FontHeight(); h := len * (asc + dec) + (len - 1) * LineSkip.Get() END END END; (* Set "w" and "h" to the width and height, respectively, of the bounding box of the text lines "l" printed as by the "TypeLinesL" procedures in the current font with the current line skip (as maintained by the "LineSkip" module. *) PROC w, h := SizeNoSkip(l) IS SAVE LineSkip IN LineSkip.Set(0); w, h := Size(l) END END; (* Line "Size" above, but uses a line skip value of 0. *)