TEditFormatExtras.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Michael Plass, April 1, 1986 9:26:04 am PST
Provides a means for inserting artwork that behaves like a single character. The character artwork mechanism is invoked when a character property is detected that has the $Artwork key with a value matching one of the registered character artwork classes.
Also provides hooks for hyphenation routines.
DIRECTORY
Imager USING [Color, Context, Font, VEC],
ImagerFont USING [Extents],
NodeStyle USING [Ref, RealParam],
NodeStyleOps USING [OfStyle],
TextNode USING [Location, Ref];
TEditFormatExtras: CEDAR DEFINITIONS
~ BEGIN
Character artwork
CharacterArtwork: TYPE ~ REF CharacterArtworkRep;
CharacterArtworkRep: TYPE ~ RECORD [
paint: PROC [CharacterArtwork, Imager.Context],
extents: ImagerFont.Extents ← [0, 0, 0, 0],
escapement: Imager.VEC ← [0, 0],
amplified: BOOL ← FALSE,
data: REFNIL
];
CharacterArtworkClass: TYPE ~ REF CharacterArtworkClassRep;
CharacterArtworkClassRep: TYPE ~ RECORD [
name: ATOM,
format: PROC [CharacterArtworkClass, TextNode.Location, NodeStyle.Ref, NodeStyleOps.OfStyle] RETURNS [CharacterArtwork],
Note: The style may change before paint is called, so the client should extract all needed style info during format call.
data: REF
];
RegisterCharacterArtwork: PROC [class: CharacterArtworkClass];
UnregisterCharacterArtwork: PROC [name: ATOM];
GetCharacterArtworkClass: PROC [ATOM] RETURNS [CharacterArtworkClass];
GetFont: PROC [style: NodeStyle.Ref] RETURNS [Imager.Font];
GetColor: PROC [style: NodeStyle.Ref, h: NodeStyle.RealParam ← textHue, s: NodeStyle.RealParam ← textSaturation, b: NodeStyle.RealParam ← textBrightness] RETURNS [color: Imager.Color];
Global Artwork Controls
ArtworkEnabled: PROC RETURNS [BOOL];
SetArtworkEnabled: PROC [enabled: BOOL] RETURNS [was: BOOL];
Controls a global Boolean that says whether or not artwork is formatted and displayed.
Does not automatically refresh the screen.
Hyphenation
maxHyph: NAT ~ 16;
HyphenationPosition: TYPE ~ [0..256) ← 0;
HyphenationPositions: TYPE ~ PACKED ARRAY [0..maxHyph) OF HyphenationPosition;
HyphProc: TYPE ~ PROC [node: TextNode.Ref, start, len: INT, hyphData: REF]
RETURNS [HyphenationPositions];
If the returned value is h, should have 0 < h[0] < h[1] < . . . < h[k-1] < len and either k = maxHyph or h[k] = 0, where k is the number of places at which it is possible to hyphenate the word. If h[j] = i is in the range (0..len), it means it's ok to hyphenate after the ith character of the word. The word is at Rope.Substr[node.rope, start, len]; the hyphenation routine may examine the context of the word in the rest of the rope. If node.hascharsets, use TextEdit.FetchChar or equivalent to fetch 16-bit character codes.
RegisterHyphenation: PROC [hyphenationClass: ATOM, hyphProc: HyphProc, hyphData: REF] RETURNS [oldProc: HyphProc, oldData: REF];
Registers a HyphProc to be called; hyphenationClass identifies the language involved, as determined from style parameters. Any previously registered proc is returned (for layering, etc.) and forgotten by the registration mechanism. Note that registering a new hyphProc may invalidate line breaks on the screen; it's up to the client to refresh these viewers.
END.