DIRECTORY Pipal, PipalEdit, PipalInt, PipalInteractiveEdit, PipalReal; PipalTextEditor: CEDAR DEFINITIONS = BEGIN pipalTextClass: Pipal.Class; PipalText: TYPE = REF PipalTextRec; PipalTextRec: TYPE = RECORD [ rope: Pipal.ROPE _ NIL, size: PipalReal.Size _ PipalReal.emptySize]; Location: TYPE = INT; CreatePipalText: PROC [rope: Pipal.ROPE, size: PipalReal.Size _ PipalReal.emptySize] RETURNS [text: PipalText]; GetSelectionInterval: PROC [text: PipalText, position: PipalReal.Position, grain: SelectionGrain] RETURNS [interval: PipalInt.Interval, closerRight: BOOL]; textEditorClass: Pipal.Class; TextEditor: TYPE = REF TextEditorRec; TextEditorRec: TYPE = RECORD [ selections: ARRAY Selections OF Selection, paste: Pipal.ROPE _ NIL]; Selections: TYPE = {primary, secondary}; Selection: TYPE = RECORD [ valid: BOOL _ FALSE, interval: PipalInt.Interval, pendingDelete: BOOL _ FALSE, caretAfter: BOOL _ FALSE, -- invariant: caretAfter => interval.base interval.size=0 SelectionGrain: TYPE = {point, char, word}; Create: PROC [text: PipalText] RETURNS [editor: PipalEdit.Editor]; InsertRope: PROC [editor: PipalEdit.Editor, characters: Pipal.ROPE]; InsertChar: PROC [editor: PipalEdit.Editor, character: CHAR]; Copy: PROC [editor: PipalEdit.Editor]; Transpose: PROC [editor: PipalEdit.Editor]; Delete: PROC [editor: PipalEdit.Editor]; Paste: PROC [editor: PipalEdit.Editor]; Erase: PROC [editor: PipalEdit.Editor]; SetSelection: PROC [editor: PipalEdit.Editor, interval: PipalInt.Interval, selection: Selections _ primary, pendingDelete: BOOL _ FALSE, caretAfter: BOOL _ FALSE, granularity: SelectionGrain _ char]; CancelSelection: PROC [editor: PipalEdit.Editor, selection: Selections _ primary]; InteractiveEditor: PROC [size: PipalReal.Size] RETURNS [viewerData: PipalInteractiveEdit.ViewerData]; END. μPipalTextEditor.mesa Copyright Σ 1988 by Xerox Corporation. All rights reserved. Barth, February 9, 1988 10:25:30 am PST Theory The Pipal text editor. The look and feel is stolen from Tioga. Text Class Convert a 2D position and grain specification into a selection interval and a boolean which indicates if the position was closer the right edge of the selection bounding box than the left edge. Text Editor Class Creation Make an editor object. Manipulation Insert the characters at the primary selection caret location. If pending delete then delete the primary selection, put it into the paste buffer, and reduce the primary selection size to 0. Errors: noPrimarySelection Insert the character at the primary selection caret location. If pending delete then delete the primary selection, put it into the paste buffer, and reduce the primary selection size to 0. Errors: noPrimarySelection Copy the secondary selection to the primary selection caret location. If primary pending delete then delete the primary selection, put it into the paste buffer, and reduce the primary selection size to 0. If secondary pending delete then delete the secondary selection and reduce the secondary selection size to 0. Errors: noPrimarySelection, noSecondarySelection Transpose the primary and secondary selections. Errors: noPrimarySelection, noSecondarySelection Delete the primary selection, put it into the paste buffer, and reduce the primary selection size to 0. Errors: noPrimarySelection Insert the paste buffer at the primary selection caret location. Errors: noPrimarySelection Delete the character before the primary selection caret. Errors: noPrimarySelection, noCharacterToErase Selection Invalidate the selection. Interactive Editor Make an empty editor. Κ7˜– "Cedar" stylešœ™Jšœ<™˜YKšœŸ&˜EK˜—šœœ˜+K˜——™šžœœœ˜BK™K™——™ šž œœ.œ˜DKšœΎ™ΎKšœ™J˜—šž œœ'œ˜=Kšœ½™½Kšœ™J˜—šžœœ˜&KšœΌ™ΌKšœ0™0J˜—šž œœ˜+Kšœ/™/Kšœ0™0J˜—šžœœ˜(Kšœg™gKšœ™J˜—šžœœ˜'Kšœ@™@Kšœ™J˜—šžœœ˜'Kšœ8™8Kšœ.™.J˜——šœ ™ š ž œœiœœœœ&˜ΗK˜—šžœœ=˜RK™K˜——™šžœœœ/˜eK™K˜——Jšœ˜J˜—…—p“