TiogaFormat.mesa; written by S. McGregor
Edited by McGregor on March 7, 1983 1:31 pm
Edited by Paxton on December 2, 1982 2:48 pm
Edited by Plass on February 24, 1983 10:07 am
DIRECTORY
Graphics USING [Context],
NodeStyle USING [Ref, TabStop, FontUnderlining],
Scaled USING [Value, zero],
TiogaDocument USING [TiogaDocumentData, LineBreak],
TextEdit USING [Offset, RefTextNode],
TiogaLooks USING [Looks],
TiogaNode USING [Location],
UnifiedFonts;
TiogaFormat: CEDAR DEFINITIONS = BEGIN
TiogaDocumentData: TYPE = TiogaDocument.TiogaDocumentData;
LineInfo: TYPE = REF LineInfoRec;
LineInfoRec:
TYPE =
RECORD [
charInfo: CharInfo,
formatInfo: FormatInfo,
positionInfo: PositionInfo,
startPos, nextPos: TiogaNode.Location,
xOffset: Scaled.Value,
xmin, ymin, xmax, ymax:
INTEGER,
A (perhaps slightly generous) bounding box for the line.
nChars: NAT,
break: TiogaDocument.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: TiogaLooks.Looks,
font: REF --UnifiedFonts.FONT-- ← NIL,
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: TiogaDocumentData,
node: TextEdit.RefTextNode,
startOffset: TextEdit.Offset,
nodeStyle: NodeStyle.Ref,
lineWidth: Scaled.Value,
forPaint: BOOLEAN ← FALSE,
doLigsAndKern: BOOLEAN ← FALSE
];
Paint:
PROC [lineInfo: LineInfo, context: Graphics.Context, whiten:
BOOLEAN ←
FALSE];
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: TiogaNode.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