TEditSelection.mesa
Copyright (C) 1982, Xerox Corporation. All rights reserved.
Edited by Paxton on December 29, 1982 10:31 am
Michael Plass, December 26, 1984 4:12:42 pm PST
DIRECTORY
Graphics USING [Context],
Rope USING [ROPE],
TEditDocument USING [Selection, SelectionGrain, SelectionId, SelectionPoint, TEditDocumentData],
TextNode USING [Location, Ref, Span],
ViewerClasses USING [ModifyProc, Viewer];
TEditSelection: CEDAR DEFINITIONS = BEGIN
Context: TYPE ~ Graphics.Context;
Selection: TYPE ~ TEditDocument.Selection;
SelectionId: TYPE ~ TEditDocument.SelectionId;
TEditDocumentData: TYPE ~ TEditDocument.TEditDocumentData;
Viewer: TYPE ~ ViewerClasses.Viewer;
pSel, sSel, oldSel, nilSel, fSel: READONLY Selection;
-- 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
------ 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
No one should do pSel^ ← tSel^ or vice versa ... call Copy instead. It's monitored.
------ 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];
lock the selection so that no other process can change it
UnlockSel: PROC [selection: SelectionId];
give up lock on the selection
LockBothSelections: PROC [who: Rope.ROPE]; -- locks primary, then secondary
UnlockBothSelections: PROC;
MakeSelection: PROC [new: Selection ← NIL, selection: SelectionId ← primary,
startValid, endValid: BOOLEANFALSE, forkPaint: BOOLTRUE] ;
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.
CaretVisible: PROC RETURNS [BOOL];
IsDown: PROC [id: SelectionId] RETURNS [BOOL];
ForceDown: PROC [id: SelectionId];
ShowSelection: PROC [id: SelectionId, self: Viewer, context: Context];
TakeDownForRedisplay: PROC [id: SelectionId, self: Viewer, context: Context];
FixUpAfterDisplay: PROC [id: SelectionId, self: Viewer, context: Context, caret: BOOL];
AdjustSelStates: PROC [self: Viewer];
TakeSelectionDown: PROC [id: SelectionId, self: Viewer, context: Context];
PutSelectionUp: PROC [id: SelectionId, self: Viewer, context: Context];
FakeSecondary: PROC [sel: Selection]; -- change sSel without showing it
Deselect: PROC [selection: SelectionId ← primary];
Take down the selection without giving up the input focus.
MarkSelection: PROC [dc: Context, viewer: Viewer, selection: Selection, id: SelectionId] ;
ExtendSelection: PROC [dc: Context, viewer: Viewer,
old, new: Selection, id: SelectionId, updateEnd: BOOLEAN] ;
CannotFindIt: ERROR;
-- can be raised by ComputeSpanLines, ComputePosLine, or ComputePosPoint
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: BOOLEANFALSE]
RETURNS [sp: TEditDocument.SelectionPoint];
FixupSelection: PROC [selection: Selection, viewer: Viewer, start, end: BOOLEANTRUE] ;
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]];
grows until procs return true.
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 [TEditDocument.SelectionGrain];
InvalidateLineCache: PROC;
CharPositionInCachedLine: PROC [viewer: Viewer, tdd: TEditDocumentData, line: INTEGER, pos: TextNode.Location] RETURNS [x, width: INTEGER];
x is LAST[INTEGER] if pos is past the end of the line.
Position: PROC [viewer: Viewer] ;
FindWhere: TYPE = { forwards, backwards, anywhere };
Find: PROC [
viewer: Viewer, findWhere: FindWhere ← anywhere,
def, word: BOOLEANFALSE,
id: SelectionId ← primary,
case: BOOLTRUE -- case => case of characters is significant --
];
FindRope: PROC [viewer: Viewer, rope: Rope.ROPE,
findWhere: FindWhere ← anywhere,
def, word: BOOLEANFALSE,
id: SelectionId ← primary,
case: BOOLTRUE -- case => case of characters is significant --
];
DoFind: PROC [viewer: Viewer, rope: Rope.ROPE,
findWhere: FindWhere ← anywhere,
def, word: BOOLEANFALSE,
id: SelectionId ← primary,
case: BOOLTRUE -- 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, SelectChar, SelectWord, SelectNode, SelectBranch, 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.
Edited on February 24, 1983 9:51 am, by Plass
replaced GetCachedLineInfo with CharPositionInCachedLine, DIRECTORY
Michael Plass, December 26, 1984 9:25:26 am PST
Imager conversion.