DIRECTORY Imager USING [Context], Rope USING [ROPE], TextNode USING [Location, Ref, Span], TEditDocument USING [Selection, TEditDocumentData, SelectionId, SelectionPoint, SelectionGrain], ViewerClasses USING [ModifyProc, Viewer]; TEditSelection: CEDAR DEFINITIONS = BEGIN Viewer: TYPE = ViewerClasses.Viewer; Selection: TYPE = TEditDocument.Selection; TEditDocumentData: TYPE = TEditDocument.TEditDocumentData; SelectionId: TYPE = TEditDocument.SelectionId; SelectionPoint: TYPE = TEditDocument.SelectionPoint; SelectionGrain: TYPE = TEditDocument.SelectionGrain; pSel, sSel, oldSel, nilSel, fSel: READONLY Selection; ------ Selection Allocating and Access ------ Create: PROC RETURNS [Selection]; -- to create a selection record Alloc: PROC RETURNS [Selection]; -- gets it from a small cache Free: PROC [Selection]; -- returns it to the cache. ok if fail to return. disaster if return twice Copy: PROC [source, dest: Selection]; -- the approved way to access selection records ------ Selection Display and Control ------ PushOrExchangeSelections: PROC; MakePrimary: PROC; MakeSecondary: PROC; CancelPrimary: PROC; CancelSecondary: PROC; CancelFeedback: PROC; CallWithSelAndDocAndTddLocks: PROC [ viewer: Viewer, id: SelectionId _ primary, proc: PROC [tdd: TEditDocumentData, tSel: Selection]]; UnlockDocAndPSel: PROC [root: TextNode.Ref]; LockSel: PROC [selection: SelectionId, who: Rope.ROPE]; UnlockSel: PROC [selection: SelectionId]; LockBothSelections: PROC [who: Rope.ROPE]; -- locks primary, then secondary UnlockBothSelections: PROC; MakeSelection: PROC [new: Selection _ NIL, selection: SelectionId _ primary, startValid, endValid: BOOLEAN _ FALSE, forkPaint: BOOL _ TRUE] ; CaretVisible: PROC RETURNS [BOOL]; IsDown: PROC [id: SelectionId] RETURNS [BOOL]; ForceDown: PROC [id: SelectionId]; ShowSelection: PROC [id: SelectionId, self: Viewer, context: Imager.Context]; TakeDownForRedisplay: PROC [id: SelectionId, self: Viewer, context: Imager.Context]; FixUpAfterDisplay: PROC [id: SelectionId, self: Viewer, context: Imager.Context, caret: BOOL]; AdjustSelStates: PROC [self: Viewer]; TakeSelectionDown: PROC [id: SelectionId, self: Viewer, context: Imager.Context]; PutSelectionUp: PROC [id: SelectionId, self: Viewer, context: Imager.Context]; FakeSecondary: PROC [sel: Selection]; -- change sSel without showing it Deselect: PROC [selection: SelectionId _ primary]; MarkSelection: PROC [dc: Imager.Context, viewer: Viewer, selection: Selection, id: SelectionId] ; ExtendSelection: PROC [dc: Imager.Context, viewer: Viewer, old, new: Selection, id: SelectionId, updateEnd: BOOLEAN] ; CannotFindIt: ERROR; ComputeSpanLines: PUBLIC PROC [viewer: Viewer, span: TextNode.Span] RETURNS [start, end: INTEGER, startClipped, endClipped: BOOLEAN] ; ComputePosLine: PROC [ viewer: Viewer, pos: TextNode.Location, firstLine: INTEGER _ 0] RETURNS [line: INTEGER, clipped: BOOLEAN]; ComputePosPoint: PROC [ viewer: Viewer, pos: TextNode.Location, firstLine: INTEGER _ 0, lineOnly: BOOLEAN _ FALSE] RETURNS [sp: SelectionPoint]; FixupSelection: PROC [selection: Selection, viewer: Viewer, start, end: BOOLEAN _ TRUE] ; FixupCaret: PROC [selection: Selection] ; KillSelection: PROC ; -- including resetting inputFocus MakePointSelection: PROC [selection: Selection, pos: TextNode.Location]; InputModify: ViewerClasses.ModifyProc ; SelectEverything: PROC; -- expand to include everything GrowSelectionToBlanks: PROC; GrowSelectionToSomething: PROC [left, right: PROC [CHAR] RETURNS [BOOLEAN]]; GrowSelection: PROC; PendingDeleteSelection: PROC; NotPendingDeleteSelection: PROC; CaretBeforeSelection: PROC; CaretAfterSelection: PROC; ------ Misc functions ------ SelectionRoot: PROC [s: Selection _ pSel] RETURNS [root: TextNode.Ref]; InsertionPoint: PROC [s: Selection _ pSel] RETURNS [ip: TextNode.Location]; GetSelectionGrain: PROC [sel: Selection] RETURNS [SelectionGrain]; InvalidateLineCache: PROC ; CharPositionInCachedLine: PROC [viewer: Viewer, tdd: TEditDocumentData, line: INTEGER, pos: TextNode.Location] RETURNS [x, width: INTEGER]; Position: PROC [viewer: Viewer] ; FindWhere: TYPE = { forwards, backwards, anywhere }; Find: PROC [ viewer: Viewer, findWhere: FindWhere _ anywhere, def, word: BOOLEAN _ FALSE, id: SelectionId _ primary, case: BOOL _ TRUE -- case => case of characters is significant -- ]; FindRope: PROC [viewer: Viewer, rope: Rope.ROPE, findWhere: FindWhere _ anywhere, def, word: BOOLEAN _ FALSE, id: SelectionId _ primary, case: BOOL _ TRUE -- case => case of characters is significant -- ]; DoFind: PROC [viewer: Viewer, rope: Rope.ROPE, findWhere: FindWhere _ anywhere, def, word: BOOLEAN _ FALSE, id: SelectionId _ primary, case: BOOL _ TRUE -- case => case of characters is significant -- ] RETURNS [found: BOOL]; ------ Screen to viewbox transforms ------ SelectProc: TYPE = PROC [viewer: Viewer, tdd: TEditDocumentData, x,y: INTEGER, sel: SelectionId, pDel: BOOLEAN] ; SelectPoint: SelectProc; SelectChar: SelectProc; SelectWord: SelectProc; SelectNode: SelectProc; SelectBranch: SelectProc; Update: SelectProc; LevelChange: TYPE = {reduce, expand, same}; Extend: PROC [ viewer: Viewer, tdd: TEditDocumentData, x,y: INTEGER, sel: SelectionId, pDel: BOOLEAN, changeLevel: LevelChange, saveEnds: BOOLEAN]; SetSelLooks: PROC [sel: Selection]; END. -- TEditSelection.mesa, Edited by Paxton on December 29, 1982 10:31 am Last Edited by: Plass, October 10, 1983 5:21 pm -- pSel and sSel are the global primary and secondary selections -- fSel is the global feedback selection -- oldSel is old secondary selection saved for Repeat's -- nilSel is for deselecting No one should do pSel^ _ tSel^ or vice versa ... call Copy instead. It's monitored. lock the selection so that no other process can change it give up lock on the selection start and end valid are if metrics were precomputed and can be trusted by the selection display code. forkPaint is false for selection display code; true for edit ops and others. Take down the selection without giving up the input focus. -- can be raised by ComputeSpanLines, ComputePosLine, or ComputePosPoint grows until procs return true. x is LAST[INTEGER] if pos is past the end of the line. Edited on February 24, 1983 9:51 am, by Plass replaced GetCachedLineInfo with CharPositionInCachedLine, DIRECTORY Plass, August 9, 1983 2:27 pm: Imager conversion Ê5˜JšÏcF™FJ™/šÏk ˜ Jšœžœ ˜Jšœžœžœ˜Jšœ žœ˜%JšœžœM˜`Jšœžœ˜)J˜—Jšœžœž˜)J˜Jšœžœ˜$Jšœ žœ˜*Jšœžœ#˜:Jšœ žœ˜.Jšœžœ ˜4šœžœ ˜4J˜—šœ"žœ ˜5Jš@™@Jšœ!™(Jš7™7Jš™J˜—Jš-˜-J˜JšÏnœžœžœ˜BJ˜JšŸœžœžœ˜?J˜JšŸœžœL˜dJ˜šŸœžœ/˜UJ™T—J˜Jš+˜+J˜JšŸœžœ˜JšŸ œžœ˜JšŸ œžœ˜JšŸ œžœ˜JšŸœžœ˜šŸœžœ˜J˜—šŸœžœ˜$Jšœ1žœ,˜aJ˜—JšŸœžœ˜,J˜šŸœžœ$žœ˜7J™9—J˜šŸ œžœ˜)J™J™—JšŸœžœ žœ ˜KJ˜JšŸœžœ˜J˜šŸ œžœžœ#˜LJš œžœžœ žœžœ˜@Jš³™³J˜—JšŸ œžœžœžœ˜"J˜Jš Ÿœžœžœžœž˜.J˜JšŸ œžœž˜"J˜JšŸ œžœ9ž˜MJ˜JšŸœžœ:˜TJ˜JšŸœžœAžœ˜^J˜JšŸœžœž˜%J˜JšŸœžœ9ž˜QJ˜JšŸœžœ9ž˜NJ˜JšŸ œžœ!˜GJ˜šŸœžœ$˜2Jšœ:™:—J˜šŸ œžœN˜aJ˜—šŸœžœ%˜:Jšœ1žœ˜;J˜—šœžœ˜JšH™HJ˜—šŸœžœžœ&˜CJšžœžœžœ˜BJ˜—šŸœžœ˜Jšœ3žœ˜?Jšžœžœ žœ˜*J˜—šŸœžœ˜J˜'Jšœ žœžœžœ˜2Jšžœ˜J˜—JšŸœžœ4žœžœ˜YJ˜JšŸ œžœ˜)J˜JšŸ œžœ!˜7J˜šŸœžœ0˜HJ˜—JšŸ œ˜'J˜JšŸœžœ˜7J˜JšŸœžœ˜J˜š Ÿœžœžœžœžœžœ˜LJ™—J˜JšŸ œžœ˜J˜JšŸœžœ˜J˜JšŸœžœ˜ J˜JšŸœžœ˜J˜JšŸœžœ˜J˜J˜Jš˜J˜JšŸ œžœžœ˜GJ˜JšŸœžœžœ˜KJ˜JšŸœžœžœ˜BJ˜JšŸœžœ˜J˜š Ÿœžœ0žœžœ žœ˜‹Jšœžœžœ%™6J˜—JšŸœžœ˜!J˜Jšœ žœ%˜4J˜šŸœžœ˜ Jšœ0˜0Jšœ žœž˜J˜Jšœžœžœ,œ˜DJ˜—šŸœžœžœ˜0Jšœ ˜ Jšœ žœž˜J˜Jšœžœžœ,œ˜DJ˜—šŸœžœžœ˜.Jšœ ˜ Jšœ žœž˜J˜Jšœžœžœ,œ˜CJšžœ žœ˜J˜—Jš*˜*J˜šŸ œžœžœ)˜@Jšœžœžœ˜0J˜—JšŸ œ ˜JšŸ œ ˜JšŸ œ ˜JšŸ œ ˜JšŸ œ ˜JšŸœ ˜J˜Jšœ žœ˜+šŸœžœ˜J˜J˜Jšœžœ˜ J˜Jšœžœ˜J˜Jšœ žœ˜J˜—JšŸ œžœ˜#J˜Jšžœ˜J˜™-Jšœ8Ïr ™C—J™0J™—…—è 9