DIRECTORY
Imager USING [Color, Context, Box],
ImagerFont USING [Font, XChar],
NodeStyle USING [Ref, TabStop, FontUnderlining],
NodeStyleOps USING [OfStyle],
Scaled USING [Value],
TEditDocument USING [LineBreak],
TextEdit USING [Offset, RefTextNode],
TextLooks USING [Looks],
TextNode USING [Location];
~
BEGIN
LineInfo: TYPE = REF LineInfoRec;
LineInfoRec:
TYPE =
RECORD [
charInfo: CharInfo,
formatInfo: FormatInfo,
positionInfo: PositionInfo,
artworkClass: ArtworkClass,
artworkData: REF,
startPos, nextPos: TextNode.Location,
xOffset: Scaled.Value,
xmin, ymin, xmax, ymax:
INTEGER,
A (perhaps slightly generous) bounding box for the line.
nChars: NAT,
nBlankCharsAtEnd: NAT,
break: TEditDocument.LineBreak,
hasBackground: BOOL,
amplifySpace: REAL,
startAmplifyIndex: CharNumber,
index: INT, -- for use by clients
data: REF, -- for use by clients
link: LineInfo
];
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: ImagerFont.XChar,
formatNumber: FormatNumber,
alteredWidth: BOOLEAN,
amplified: BOOLEAN,
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: ImagerFont.Font ← NIL,
color: Imager.Color ← NIL,
tab: NodeStyle.TabStop ← NIL,
vShift: REAL ← 0.0,
charProps: REF,
strikeout: NodeStyle.FontUnderlining ← None,
underlining: NodeStyle.FontUnderlining ← None,
unique: BOOL
];
PositionInfo: PUBLIC TYPE = REF PositionInfoRec;
PositionInfoRec:
PUBLIC
TYPE =
RECORD [
seq: SEQUENCE maxLength: CharNumber OF INTEGER
];
FormatLine: FormatProc;
FormatProc:
TYPE ~
PROC [
lineInfo: LineInfo,
node: TextEdit.RefTextNode,
startOffset: TextEdit.Offset,
nodeStyle: NodeStyle.Ref,
lineWidth: Scaled.Value,
doLigsAndKern:
BOOLEAN ←
FALSE,
kind: NodeStyleOps.OfStyle ← screen
];
Paint: PaintProc;
PaintProc:
TYPE ~
PROC [lineInfo: LineInfo, context: Imager.Context];
Paints the line with its origin at the current position.
Resolve: ResolveProc;
ResolveProc:
TYPE ~
PROC [lineInfo: LineInfo, x:
INTEGER]
RETURNS [loc: TextNode.Location, xmin, width:
INTEGER, rightOfLine:
BOOLEAN];
Finds the character pointed to.
CharPosition: CharPositionProc;
CharPositionProc:
TYPE ~
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.
BoundingBox: BoundingBoxProc;
BoundingBoxProc:
TYPE ~
PROC [lineInfo: LineInfo, start:
INT ← 0, length:
INT ←
LAST[
INT]]
RETURNS [Imager.Box];
Computes a higher-precision bounding box of characters [start..start+length) of the line, relative to the line's origin.
Allocate:
PROC
RETURNS [lineInfo: LineInfo];
This is how to get working space. Keeps a cache of storage.
Release:
PROC [lineInfo: LineInfo];
A promise that the client is done with this LineInfo, and all those chained from it. Use whenever possible to save on allocations.
RegisterArtwork:
PROC [ArtworkClass];
UnRegisterArtwork:
PROC [
ATOM];
GetArtworkClass:
PROC [
ATOM]
RETURNS [ArtworkClass];
ArtworkClass: TYPE ~ REF ArtworkClassRep;
ArtworkClassRep:
TYPE ~
RECORD [
name: ATOM,
format: FormatProc,
paint: PaintProc,
resolve: ResolveProc,
charPosition: CharPositionProc,
boundingBox: BoundingBoxProc
];