DIRECTORY Imager USING [Box, Color, Context, VEC], ImagerFont USING [Font, Extents, XChar], NodeStyle USING [Ref, RealParam, TabStop, FontUnderlining], NodeStyleOps USING [OfStyle], Scaled USING [Value], TEditDocument USING [LineBreak], TextLooks USING [Looks], TextNode USING [Location, Ref]; TEditFormat: CEDAR DEFINITIONS ~ 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, 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, extension: 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: TextNode.Ref, startOffset: INT, nodeStyle: NodeStyle.Ref, lineWidth: Scaled.Value, doLigsAndKern: BOOLEAN _ FALSE, kind: NodeStyleOps.OfStyle _ screen ]; Paint: PaintProc; PaintProc: TYPE ~ PROC [lineInfo: LineInfo, context: Imager.Context]; Resolve: ResolveProc; ResolveProc: TYPE ~ PROC [lineInfo: LineInfo, x: INTEGER] RETURNS [loc: TextNode.Location, xmin, width: INTEGER, rightOfLine: BOOLEAN]; CharPosition: CharPositionProc; CharPositionProc: TYPE ~ PROC [lineInfo: LineInfo, offset: INT] RETURNS [x, width: INTEGER]; BoundingBox: BoundingBoxProc; BoundingBoxProc: TYPE ~ PROC [lineInfo: LineInfo, start: INT _ 0, length: INT _ LAST[INT]] RETURNS [Imager.Box]; Allocate: PROC RETURNS [lineInfo: LineInfo]; Release: PROC [lineInfo: LineInfo]; 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 ]; 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: REF _ NIL ]; CharacterArtworkClass: TYPE ~ REF CharacterArtworkClassRep; CharacterArtworkClassRep: TYPE ~ RECORD [ name: ATOM, format: PROC [CharacterArtworkClass, TextNode.Location, NodeStyle.Ref, NodeStyleOps.OfStyle] RETURNS [CharacterArtwork], data: REF ]; RegisterCharacterArtwork: PROC [class: CharacterArtworkClass]; UnregisterCharacterArtwork: PROC [name: ATOM]; GetCharacterArtworkClass: PROC [ATOM] RETURNS [CharacterArtworkClass]; GetFont: PROC [style: NodeStyle.Ref] RETURNS [ImagerFont.Font]; GetColor: PROC [style: NodeStyle.Ref, h: NodeStyle.RealParam _ textHue, s: NodeStyle.RealParam _ textSaturation, b: NodeStyle.RealParam _ textBrightness] RETURNS [color: Imager.Color]; ArtworkEnabled: PROC RETURNS [BOOL]; SetArtworkEnabled: PROC [enabled: BOOL] RETURNS [was: BOOL]; 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]; RegisterHyphenation: PROC [hyphenationClass: ATOM, hyphProc: HyphProc, hyphData: REF] RETURNS [oldProc: HyphProc, oldData: REF]; END. èTEditFormat.mesa Copyright Ó 1985, 1986, 1988 by Xerox Corporation. All rights reserved. Michael Plass, May 23, 1985 9:04:16 am PDT Doug Wyatt, February 15, 1988 1:11:15 pm PST Line formatting A (perhaps slightly generous) bounding box for the line. Paints the line with its origin at the current position. Finds the character pointed to. Finds the position of the indicated character. Returns FIRST[INTEGER] or LAST[INTEGER] if the character occurs before or after the line, respectively. Computes a higher-precision bounding box of characters [start..start+length) of the line, relative to the line's origin. This is how to get working space. Keeps a cache of storage. A promise that the client is done with this LineInfo, and all those chained from it. Use whenever possible to save on allocations. Artwork Character artwork 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. Note: The style may change before paint is called, so the client should extract all needed style info during format call. Global Artwork Controls Controls a global Boolean that says whether or not artwork is formatted and displayed. Does not automatically refresh the screen. Hyphenation 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. 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. ÊϘcodešœ™KšœH™HKšœ*™*K™,K™—šÏk ˜ Kšœœœ˜(Kšœ œ˜(Kšœ œ,˜;Kšœ œ ˜Kšœœ ˜Kšœœ ˜ Kšœ œ ˜Kšœ œ˜K˜—KšÐbl œ˜Kšœ˜head™Kšœ œœ ˜!šœ œœ˜K˜K˜K˜Kšœ˜Kšœ œ˜Kšœ%˜%K˜šœœ˜ K™8—Kšœœ˜ Kšœœ˜Kšœ˜Kšœœ˜Kšœœ˜Kšœ˜KšœœÏc˜!KšœœŸ˜ Kšœ˜Kšœ˜K˜—Kš œ œœœœ˜=Kšœ œœœ ˜(šœ œœœ˜#Kšœœœ˜4Kšœ˜K˜—šœœœ˜Kšœ˜K˜Kšœœ˜Kšœ œ˜K˜Kšœ˜K˜—Kš œœœœœ˜BKšœ œœœ˜,šœœœœ˜%Kšœ˜Kšœœœ˜8Kšœ˜K˜—šœœœ˜ Kšœ˜Kšœœ˜Kšœœ˜Kšœœ˜Kšœœ˜Kšœ œ˜Kšœ,˜,Kšœ.˜.Kšœ˜ Kšœ˜K˜—Kšœœœœ˜0šœœœœ˜'Kšœœœ˜.Kšœ˜K˜—KšÏn œ ˜š œ œœ8œDœœ(˜ÍK˜—Kš œ ˜šœ œœ/˜EKšœ8™8K™—Kš œ˜š œ œœœœ'œœ˜‡Kšœ™K™—Kš  œ˜š œœœœœ œ˜\Kš œ8œœœœA™—K™—Kš  œ˜šœœœœœœœœ˜pKšœx™xK™—š œœœ˜,K™;K™—š œœ˜#K™‚K™——™š œœ˜%K˜—š œœœ˜K˜—š œœœœ˜4K˜—Kšœœœ˜)šœœœ˜ Jšœœ˜ J˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜K˜——™Kšœÿ™ÿK™Kšœœœ˜1šœœœ˜$Jšœœ$˜/Jšœ+˜+Jšœœ ˜ Jšœ œ˜Jšœœ˜Jšœ˜K˜—Kšœœœ˜;šœœœ˜)Jšœœ˜ šœœQœ˜xK™y—Jšœ˜ Jšœ˜K˜—š œœ ˜>K˜—š œœœ˜.K˜—Kš œœœœ˜FK˜š œœœ˜?K˜—š œœŒœ˜¸K˜——™Kš œœœœ˜$š  œœ œœœ˜