DIRECTORY Atom USING [PropList], Graphics USING [Context], TIPUser USING [TIPTable], TiogaLooks USING [Looks, noLooks], TiogaNode; TiogaItemClass: CEDAR DEFINITIONS = BEGIN OPEN TiogaNode; ItemClass: TYPE = REF ItemClassRec; ItemClassRec: TYPE = RECORD [ length: ItemLengthProc _ NIL, notify: ItemNotifyProc _ NIL, edit: ItemEditProc _ NIL, compose: ItemComposeProc _ NIL, display: ItemDisplayProc _ NIL, incrDisplay: ItemIncrementalDisplayProc _ NIL, cachedDisplayTable: ItemCachedDisplayTableProc _ DefaultItemCachedDisplayTableProc, setSelection: ItemSetSelectionProc _ NIL, get: ItemGetProc _ NIL, set: ItemSetProc _ NIL, copy: ItemCopyProc _ NIL, init: ItemInitProc _ NIL, destroy: ItemDestroyProc _ NIL, tipTable: TIPUser.TIPTable _ NIL, flavor: ItemFlavor _ NIL, props: Atom.PropList _ NIL ]; ItemFlavor: TYPE = ATOM ; Item: TYPE = RefItemNode ; defaultTextClassID: ItemClassID = TiogaNode.defaultTextClassID; invalidItemID: ItemClassID = TiogaNode.invalidItemClassID; ItemLengthProc: TYPE = PROC [self: Item] RETURNS [length: Offset] ; ItemNotifyProc: TYPE = PROC [self: Item, events: LIST OF REF ANY] ; ItemEditProc: TYPE = PROC [self: Item, edit: EditRecord] ; EditRecord: TYPE = RECORD [ op: ATOM, primary: SubNode _ nullSubNode, secondary: Span _ nullSpan, data: REF _ NIL, count: INTEGER _ 0, looks: TiogaLooks.Looks _ TiogaLooks.noLooks ] ; ItemInitProc: TYPE = PROC [self: Item] ; ItemDestroyProc: TYPE = PROC [self: Item] ; ItemCopyProc: TYPE = PROC [self, new: Item] ; ItemSetSelectionProc: TYPE = PROC [self: Item, selection: REF ANY] ; ItemSetProc: TYPE = PROC [self: Item, op: ATOM _ NIL, data: REF ANY, finalise: BOOL _ TRUE] ; ItemGetProc: TYPE = PROC [self: Item, op: ATOM _ NIL] RETURNS [data: REF ANY] ; ItemComposeProc: TYPE = PROC [ self: Item, startLoc: TiogaNode.Location, -- note that startLoc.path.node could be a child of self composingStick: ComposingStick, startIndex: NAT _ 0, -- first index to use on the composing stick direction: LayoutDirection _ horizontal ] RETURNS [ end: TiogaNode.Location, -- should be either within self or in a child of self why: Break _ eon, endIndex: NAT -- last index used on the composing stick ] ; ItemDisplayProc: TYPE = PROC [ self: Item, dc: Graphics.Context, composingStick: ComposingStick, startIndex: NAT _ 0, endIndex: NAT, clear: BOOL _ TRUE ] ; ---------- LayoutDirection: TYPE = { horizontal, vertical } _ horizontal; Break: TYPE = { eon, cr, wrap, hyphen } _ eon; Distance: TYPE = INTEGER _ 0; unbounded: Distance = LAST[Distance] ; Metrics: TYPE = RECORD [ leftExtent, rightExtent: Distance _ 0, -- size before and after the x=0 baseline topExtent, bottomExtent: Distance _ 0 -- size above and below the y=0 baseline ] ; FlexOrder: TYPE = [0..3]; KerfIndex: TYPE = [0..LAST[CARDINAL]/SIZE[Kerf]-7]; Penalty: TYPE = INTEGER; Glue: TYPE = RECORD [ size: Distance, stretch: Distance, stretchOrder: FlexOrder, shrink: Distance, shrinkOrder: FlexOrder ]; ComposingStick: TYPE = REF ComposingStickRec; ComposingStickRec: TYPE = RECORD [ elements: ElementSeq, kerfs: KerfSeq, results: LineBreakSeq ]; ElementSeq: TYPE = REF ElementSeqRec; ElementSeqRec: TYPE = RECORD [ length: NAT, seq: SEQUENCE maxLength: NAT OF Element ]; OfElement: TYPE = {box, glue, tab, kerf}; Element: TYPE = RECORD [ SELECT kind: OfElement FROM box => [metrics: Metrics], glue => [ stretchOrder, shrinkOrder: FlexOrder, size, stretch, shrink: Distance ], tab => [distanceFromStartOfLine: Distance], kerf => [kerfIndex: KerfIndex, offset: Offset], ENDCASE ]; KerfSeq: TYPE = REF KerfSeqRec; KerfSeqRec: TYPE = RECORD [ length: KerfIndex, seq: SEQUENCE maxLength: KerfIndex OF Kerf ]; Kerf: TYPE = RECORD [ join, prebreak, postbreak: Glue, penalty: Penalty, node: Ref ]; LineBreakSeq: TYPE = REF LineBreakRec; LineBreakRec: TYPE = RECORD [ length: NAT, seq: SEQUENCE maxLength: NAT OF LineBreak ]; LineBreak: TYPE = RECORD [ node: Ref, offset: Offset, glueSet: Distance ]; ItemIncrementalDisplayProc: TYPE = PROC [ self: Item, dc: Graphics.Context, whatChanged: REF, growProc: GrowProc, clear: BOOL _ TRUE ] RETURNS [ metrics: Metrics, okToBLTX, okToBLTY: BOOL _ TRUE ] ; ItemGrowProc: TYPE = PROC [ self: Item, metrics: Metrics, okToBLTToNewLoc: BOOL _ TRUE ] RETURNS [ metrics: Metrics, clear: BOOL _ TRUE ] ; ItemCachedDisplayTableProc: TYPE = PROC [parent, child: Item] RETURNS [dt: REF --TiogaDisplayTable.DisplayTable--]; DefaultItemCachedDisplayTableProc: ItemCachedDisplayTableProc; END. ώTiogaItemClass.mesa; Written by Scott McGregor. May 1983 Edited by McGregor. September 1, 1983 4:12 pm Item Classes Returns the maximum node offset plus one for an item. All mouse and keyboard input is passed to the item implementor in the form of a list of REF ANY generated either by the item class' TIPTable or by the Tioga selection TIPTable. The ItemNotifyProc accepts user interface operations, whereas the ItemEditProc accepts direct edit operations, where all of the parameters are tightly bound. Format the node contents into boxes and separators. Display composed contents. Attempt an efficient display updatefor minor edits (classes should not implement this interface without providing the more general ItemDisplayProc interface as well). For children to notify parent that displayed data may have become invalid. Called in order to force selection to a particular item. This will typically be called by a child item when expanding the selection in the Tioga document tree. Fetch the contents of an item. Set new contents for an item. Copy the relevent data from one item to another. Called first thing on node creation. Notification to the implementor that the item is being removed from the document tree. Item specific user input. Each item class has a unique name to distinguish it from other implementations. Implementor private class operations, data, etc. ---------- Returns number of distinguishable positions within a node (length = 0 implies empty node). ---------- ---------- Passed a list of event notifications from either the item class' TIPTable or the Tioga system TIPTable. ---------- ---------- Direct access to the editing routines for a node class. The EditProc is not responsible for repainting, but must invalidate displayed nodes such that subsequent repaint would correctly display the changes. The edit record can be thought of as a virtual machine instruction for the node editor, where the op is the operation to be performed and the remaining fields are optional parameters. While it is up to each node implementation to determine which operations it will support and what their semantics are, the following are suggested: $Delete - primary bounds the portion to delete. $Insert - primary is the insertion point, secondary is the material to be copied. $Append - primary is the append point, secondary is the material to be copied. $InsertRope - primary is the insertion point, data is the rope to be inserted. $AppendRope - primary is the append point, data is the rope to be appended. $SetLooks - primary bounds the affected portion, looks contains the new looks bits. The count field is included for operations such as BackSpace where it may be more efficient for the edit implementation to implement the operation multiple times rather than making multiple calls on the edit virtual machine. ---------- ---------- Called immediately after creation of a node. ---------- ---------- Called to free any resources held by a node when it has been destroyed (only resources that the GC is unable to return need be freed). ---------- ---------- Copy private node data. ---------- ---------- Force selection into a node. By convention, if selection is NIL then the entire node is selected. ---------- ---------- Called to set the contents or other attributes of a node. By convention, if op=$Restore then data is a Rope.ROPE obtained from a previous call on self.get and stored out on disk. ---------- ---------- Called to query the contents or other attributes of a node. By convention, if op=$Save then data returned should be a Rope.ROPE representation of the item's private data in a form suitable for saving on disk and passing to a item.set with op=$Restore. ---------- ---------- ---------- ---------- ---------- Data structures relevent to composition and display A box is somthing that occupies a fixed amount of space in the line. Glue is something that occupies a variable amount of space in the line. It has three components: its normal size, the amount by which it should be allowed to grow without a large penalty, and the amount by which it is allowed to shrink. The stretch and shrink have an order of infinity associated with them. A kerf is a place in the line where a break is possible. It has three major parts, the join, the prebreak, and the postbreak. The join describes the size and flexibility of what is to go into the line if no break occurs at the kerf. If a break does occur at the kerf, the prebreak describes what goes before the break (i.e., at the end of the line), and the postbreak describes what goes at the beginning of the next line. A kerf also has an associated penalty to be charged if the break is taken, and some extra information to allow the positions of the chosen breaks to be communicated back to the client. ---------- ---------- ---------- ---------- When a node has become invalidated because of an edit, it must make sure that it invalidates any DisplayTable entries that might include it. A child node is expected to call this procedure in its parent and if the table returned is non-nil, it must set the invalid bit for any display table entries that include the edited region. The parent node must likewise call its parent. For simple item classes that do not keep a private DisplayTable ---------- See TiogaNodeOps for registration of Item Classes Κ Y˜Jšœ8™8Jšœ-™-J˜šΟk ˜ Iprocšœœ ˜Kšœ œ ˜Jšœœ ˜Kšœ œ˜"Kšœ ˜ J˜—Jš œœ œœœ ˜9J˜™ K˜Kšœ œœ˜#K˜šœœœ˜šœœ˜Kšœ5™5—šœœ˜KšœXœQ™°—šœœ˜Kšœ™—šœœ˜K™3—šœœ˜K™—šœ*œ˜.Kšœ¦™¦—šœS˜SK™J—šœ%œ˜)Kšœ ™ —šœœ˜Kšœ™—šœœ˜Kšœ™—šœœ˜Kšœ0™0—šœœ˜Kšœ$™$—šœœ˜KšœV™V—šœœ˜!Kšœ™—šœœ˜KšœO™O—šœ˜Kšœ0™0—Kšœ˜—K˜Kšœ œœ˜K˜Kšœœ˜K˜Kšœ?˜?Kšœ:˜:K˜Kšœ ™ šΟnœœœœ˜CKšœZ™Z—šΟc ™ K™—KšŸ ™ šžœœœœœœœ˜CKšœg™g—KšŸ ™ K˜KšŸ ™ šž œœœ!˜:KšœΞ™Ξ—˜šœ œœ˜Kšœœ˜ Kšœ˜Kšœ˜Kšœœœ˜Kšœœ˜Kšœ,˜,K˜šœΜ™ΜKšœ1™1KšœS™SKšœP™PKšœO™OKšœK™KKšœU™U—Kšœα™α——KšŸ ™ J˜KšŸ ™ šž œœœ˜(Jšœ,™,—KšŸ ™ J˜KšŸ ™ šžœœœ˜+Jšœ†™†—KšŸ ™ J˜KšŸ ™ šž œœœ˜-Jšœ™—KšŸ ™ J˜Jšœ ™ š žœœœœœ˜DJšœ=œ"™b—Jšœ ™ J˜Jšœ ™ šž œœœœœœœ œœ˜]JšœmœB™³—Jšœ ™ J˜Jšœ ™ šž œœœœœœœœ˜OJšœ|œ|™ό—Jšœ ™ J˜KšŸ ™ šžœœœ˜Jšœ ˜ JšœŸ8˜VJšœ˜Jšœ œŸ,˜AJšœ'˜'Jšœ˜—šœ˜ JšœŸ5˜NJšœ˜Jšœ œŸ)˜7Jšœ˜—KšŸ ™ J˜KšŸ ™ šžœœœ˜Jšœ!˜!Jšœ˜Jšœ œ˜Jšœ œ˜Jšœœ˜Jšœ˜—KšŸ ™ J˜JšŸ ˜ Jšœ3™3J˜Jšœœ)˜>Jšœœ#˜.J˜Jšœ œœ˜Jšœœ ˜&J˜šœ œœ˜JšœP˜PJšœN˜NJšœ˜—J˜Jšœ œ ˜Jš œ œœœœ ˜3Jšœ œœ˜J˜šœœœ˜Jšœ˜Jšœ+˜+Jšœ(˜(J˜—J˜Jšœœœ˜-šœœœ˜"J˜J˜J˜Jšœ˜—J˜Jšœ œœ˜%šœœœ˜Jšœœ˜ Jšœœ œœ˜'Jšœ˜—J˜Jšœ œ˜)šœ œœ˜šœ˜šœ˜JšœΟzœ?™D—šœ ˜ Jšœ%˜%Jšœ˜J˜Jš œ±™΅—Jšœ+˜+šœ/˜/Jš œ œR œ œ   œΜ œ“™γ—Jš˜—Jšœ˜—J˜Jšœ œœ ˜šœ œœ˜Jšœ˜Jšœœœ˜*Jšœ˜—šœœœ˜Jšœ ˜ J˜Jšœ ˜ Jšœ˜—J˜Jšœœœ˜&šœœœ˜Jšœœ˜ Jšœœ œœ ˜)Jšœ˜—šœ œœ˜Jšœ ˜ Jšœ˜J˜Jšœ˜—Jšœ ™ J˜Jšœ ™ šžœœœ˜)Jšœ ˜ Jšœ˜Jšœ œ˜Jšœ˜Jšœœ˜Jšœ˜—šœ˜ Jšœ˜Jšœœ˜Jšœ˜—˜šž œœœ˜Jšœ ˜ Jšœ˜Jšœœ˜Jšœ˜—šœ˜ Jšœ˜Jšœœ˜Jšœ˜——Jšœ ™ J˜Jšœ ™ š žœœœœœŸ"œ˜sKšœϋ™ϋJ˜šž!œ˜>Jšœ?™?——Jšœ ™ J˜J˜J™1J™—J™Jšœ˜J˜J˜—…—‚/Ω