TEditFormat.mesa Edited by McGregor on January 27, 1983 3:02 pm
Edited by Paxton on December 2, 1982 2:48 pm
Edited by Plass on August 9, 1983 2:23 pm
DIRECTORY
Imager USING [Context],
NodeStyle USING [Ref, TabStop, FontUnderlining],
Scaled USING [Value, zero],
TEditDocument USING [TEditDocumentData, LineBreak],
TextEdit USING [Offset, RefTextNode],
TextLooks USING [Looks],
TextNode USING [Location],
UnifiedFonts;
TEditFormat: CEDAR DEFINITIONS = BEGIN
TEditDocumentData: TYPE = TEditDocument.TEditDocumentData;
LineInfo: TYPE = REF LineInfoRec;
LineInfoRec: TYPE = RECORD [
charInfo: CharInfo,
formatInfo: FormatInfo,
positionInfo: PositionInfo,
startPos, nextPos: TextNode.Location,
xOffset: Scaled.Value,
xmin, ymin, xmax, ymax: INTEGER,
A (perhaps slightly generous) bounding box for the line.
nChars: NAT,
break: TEditDocument.LineBreak
];
CharNumber: TYPE = [0..LAST[CARDINAL]/SIZE[CharInfoEntry]-8);
CharInfo: PUBLIC TYPE = REF CharInfoRec;
CharInfoRec: PUBLIC TYPE = RECORD [
seq: SEQUENCE maxLength: CharNumber OF CharInfoEntry
];
CharInfoEntry: TYPE = RECORD [
char: CHAR,
formatNumber: FormatNumber,
width: Scaled.Value
];
FormatNumber: TYPE = [0..LAST[CARDINAL]/SIZE[FormatInfoEntry]-16);
FormatInfo: PUBLIC TYPE = REF FormatInfoRec;
FormatInfoRec: PUBLIC TYPE = RECORD [
length: FormatNumber ← 0,
seq: SEQUENCE maxLength: FormatNumber OF FormatInfoEntry
];
FormatInfoEntry: TYPE = RECORD [
looks: TextLooks.Looks,
font: UnifiedFonts.FONTNIL,
tab: NodeStyle.TabStop ← NIL,
vShift: Scaled.Value ← Scaled.zero,
strikeout, underlining: NodeStyle.FontUnderlining ← None
];
PositionInfo: PUBLIC TYPE = REF PositionInfoRec;
PositionInfoRec: PUBLIC TYPE = RECORD [
seq: SEQUENCE maxLength: CharNumber OF INTEGER
];
FormatLine: PROC [self: LineInfo,
tdd: TEditDocumentData,
node: TextEdit.RefTextNode,
startOffset: TextEdit.Offset,
nodeStyle: NodeStyle.Ref,
lineWidth: Scaled.Value,
forPaint: BOOLEANFALSE,
doLigsAndKern: BOOLEANFALSE
];
Paint: PROC [lineInfo: LineInfo, context: Imager.Context, whiten: BOOLEANFALSE];
Paints the line with its origin at the current position. The LineInfo must have been created with forPaint: TRUE.
Resolve: PROC [lineInfo: LineInfo, x: INTEGER]
RETURNS [loc: TextNode.Location, xmin, width: INTEGER, rightOfLine: BOOLEAN];
Finds the character pointed to.
CharPosition: PROC [lineInfo: LineInfo, offset: TextEdit.Offset]
RETURNS [x, width: INTEGER];
Finds the position of the indicated character. Returns FIRST[INTEGER] or LAST[INTEGER] if the character occurs before or after the line, respectively.
Allocate: PROC RETURNS [lineInfo: LineInfo];
This is how to get working space. Keeps a small cache of storage.
Release: PROC [lineInfo: LineInfo];
A promise that the client is done with this LineInfo. Use whenever possible to save on allocations.
END.
Michael Plass, February 1, 1983 9:15 am: conversion to UnifiedFonts
Michael Plass, August 9, 1983 2:23 pm: conversion to Imager