-- TiogaMiscOpsImpl.mesa Edited by Paxton on June 14, 1983 9:23 am
Last Edited by: Maxwell, January 6, 1983 11:33 am
DIRECTORY
LongString USING [AppendChar, AppendString, AppendDecimal],
Rope USING [Fetch, ROPE, Size],
RopeEdit USING [AlphaNumericChar, BlankChar, Concat, Substr],
RopeReader USING [Create, Get, GetIndex, Backwards, ReadOffEnd, Ref, SetPosition],
TextEdit USING [DeleteText, FetchChar, FetchLooks, InsertChar, InsertRope, ReplaceByChar, InsertString, Size],
TiogaLooks USING [Look, Looks, noLooks],
TiogaNode USING [Location, NodeItself, Offset, Ref, RefBranchNode, RefTextNode, Name],
TiogaNodeOps USING [BranchChild, LastLocWithin, NarrowToTextNode, Parent, StepForwardNode, StepBackwardNode],
TiogaDocument USING [BeforeAfter, Selection, SelectionPoint],
TiogaInput USING [CloseEvent, currentEvent],
TiogaInputOps,
TiogaOps,
TiogaRefresh USING [ScrollToEndOfSel],
TiogaSelection USING [CaretVisible, Copy, Deselect, InsertionPoint, LockSel, MakePointSelection, MakeSelection, pSel, SetSelLooks, UnlockSel],
Time USING [Current, Unpack, Unpacked],
TreeFind USING [Finder, CreateFromRope, Try, TryBackwards],
ViewerClasses USING [Viewer],
ViewerTools USING [SetSelection];
TiogaMiscOpsImpl: CEDAR PROGRAM
IMPORTS LongString, Rope, RopeEdit, RopeReader, TextEdit, TiogaNodeOps, TiogaInput, TiogaInputOps, TiogaOps, TiogaRefresh, TiogaSelection, Time, TreeFind, ViewerTools
EXPORTS TiogaInputOps = BEGIN
OPEN TiogaDocument, TiogaSelection, TiogaOps, TiogaInputOps;
InsertChar: PUBLIC PROC [char: CHARACTER] = {
DoInsertChar: PROC [root: TiogaNode.RefBranchNode, tSel: Selection] = {
pos: TiogaNode.Location;
looks: TiogaLooks.Looks ← tSel.looks;
IF tSel.pendingDelete THEN {
DoPendingDelete[];
TiogaSelection.Copy[source: pSel, dest: tSel] };
pos ← InsertionPoint[pSel]; -- need to get insertion point after pending delete
Deselect[primary];
[] ← TextEdit.InsertChar[root: root,
dest: TiogaNodeOps.NarrowToTextNode[pos.node],
char: char, destLoc: pos.where,
inherit: FALSE, looks: looks,
event: TiogaInput.currentEvent];
pos.where ← pos.where+1;
MakePointSelection[tSel, pos];
IF CaretVisible[] THEN TiogaRefresh.ScrollToEndOfSel[tSel.viewer, TRUE] };
CallWithLocks[DoInsertChar] };
InsertRope: PUBLIC PROC [rope: Rope.ROPE] = {
DoInsertRope: PROC [root: TiogaNode.RefBranchNode, tSel: Selection] = {
pos: TiogaNode.Location;
len: TiogaNode.Offset ← Rope.Size[rope];
looks: TiogaLooks.Looks;
IF tSel.pendingDelete THEN {
DoPendingDelete[];
TiogaSelection.Copy[source: pSel, dest: tSel] };
pos ← InsertionPoint[pSel]; -- need to get insertion point after pending delete
looks ← tSel.looks;
Deselect[primary];
[] ← TextEdit.InsertRope[root: root,
dest: TiogaNodeOps.NarrowToTextNode[pos.node],
rope: rope, destLoc: pos.where,
inherit: FALSE, looks: looks,
event: TiogaInput.currentEvent];
pos.where ← pos.where+len;
MakePointSelection[tSel, pos];
IF CaretVisible[] THEN TiogaRefresh.ScrollToEndOfSel[tSel.viewer, TRUE] };
CallWithLocks[DoInsertRope] };
InsertLineBreak: PUBLIC PROC = { -- copy leading blanks from previous line
DoInsertLineBreak: PROC [root: TiogaNode.RefBranchNode, tSel: Selection] = {
pos: TiogaNode.Location;
node: TiogaNode.RefTextNode; 
start, end: TiogaNode.Offset;
rope: Rope.ROPE;
IF tSel.pendingDelete THEN {
DoPendingDelete[];
TiogaSelection.Copy[source: pSel, dest: tSel] };
pos ← InsertionPoint[pSel]; -- need to get insertion point after pending delete
IF (node ← TiogaNodeOps.NarrowToTextNode[pos.node]) = NIL THEN { EditFailed[]; RETURN };
rope ← node.rope;
start ← MAX[0, pos.where];
start ← MIN[start, Rope.Size[rope]];
WHILE start > 0 AND Rope.Fetch[rope,start-1] # 15C DO start ← start-1; ENDLOOP;
end ← start;
WHILE end < pos.where AND RopeEdit.BlankChar[Rope.Fetch[rope,end]] DO
end ← end+1; ENDLOOP;
InsertRope[RopeEdit.Concat["\n",RopeEdit.Substr[rope,start,end-start]]] };
CallWithLocks[DoInsertLineBreak] };
DeleteNextChar: PUBLIC PROC [count: INT ← 1] = {
DoDeleteNextChar: PROC [root: TiogaNode.RefBranchNode, tSel: Selection] = {
flush: TiogaNode.Location ← InsertionPoint[tSel];
node: TiogaNode.RefTextNode;
IF (node ← TiogaNodeOps.NarrowToTextNode[flush.node]) = NIL THEN GOTO Bad;
IF flush.where=TiogaNode.NodeItself THEN GOTO Bad;
IF (count ← MIN[count,TextEdit.Size[node]-flush.where]) <= 0 THEN GOTO Bad;
Deselect[primary];
TextEdit.DeleteText[root, node, flush.where, count, TiogaInput.currentEvent];
MakePointSelection[tSel,flush];
TiogaRefresh.ScrollToEndOfSel[tSel.viewer, TRUE];
EXITS Bad => EditFailed[] };
IF count > 0 THEN CallWithLocks[DoDeleteNextChar] };
GoToNextChar: PUBLIC PROC [count: INT ← 1] = {
DoGoToNextChar: PROC [root: TiogaNode.RefBranchNode, tSel: Selection] = {
loc: TiogaNode.Location ← InsertionPoint[tSel];
node: TiogaNode.RefTextNode;
IF (node ← TiogaNodeOps.NarrowToTextNode[loc.node]) = NIL OR
loc.where=TiogaNode.NodeItself OR
(count ← MIN[count,TextEdit.Size[node]-loc.where]) <= 0 THEN { -- try next node
GoToNextNode; RETURN };
MakePointSelection[tSel,[node,loc.where+count]];
TiogaRefresh.ScrollToEndOfSel[tSel.viewer, TRUE] };
IF count > 0 THEN CallWithLocks[DoGoToNextChar, read] };
GoToPreviousChar: PUBLIC PROC [count: INT ← 1] = {
DoGoToPreviousChar: PROC [root: TiogaNode.RefBranchNode, tSel: Selection] = {
loc: TiogaNode.Location ← InsertionPoint[tSel];
node: TiogaNode.RefTextNode;
IF (node ← TiogaNodeOps.NarrowToTextNode[loc.node]) = NIL OR
loc.where=TiogaNode.NodeItself OR loc.where < count
THEN { GoToPreviousNode; RETURN }; -- try previous node
MakePointSelection[tSel,[node,loc.where-count]];
TiogaRefresh.ScrollToEndOfSel[tSel.viewer, TRUE] };
IF count > 0 THEN CallWithLocks[DoGoToPreviousChar, read] };
FindNextWord: PUBLIC PROC [node: TiogaNode.RefTextNode, start: TiogaNode.Offset]
RETURNS [nChars: CARDINAL] = {
offset: TiogaNode.Offset ← start;
size: TiogaNode.Offset ← TextEdit.Size[node];
nChars ← 1;
WHILE offset<size AND ~RopeEdit.AlphaNumericChar[TextEdit.FetchChar[node, offset]] DO
offset ← offset + 1;
nChars ← nChars + 1;
ENDLOOP;
WHILE offset<size AND RopeEdit.AlphaNumericChar[TextEdit.FetchChar[node, offset]] DO
offset ← offset + 1;
nChars ← nChars + 1;
ENDLOOP;
nChars ← nChars - 1; -- correction: loops overshoot by 1
};
DeleteNextWord: PUBLIC PROC [count: INT ← 1] = {
DoDeleteNextWord: PROC [root: TiogaNode.RefBranchNode, tSel: Selection] = {
pos: TiogaNode.Location ← InsertionPoint[tSel];
node: TiogaNode.RefTextNode;
nChars, start, next: TiogaNode.Offset;
IF (start ← pos.where) = TiogaNode.NodeItself THEN GOTO Bad;
IF (node ← TiogaNodeOps.NarrowToTextNode[pos.node])=NIL THEN GOTO Bad;
next ← start;
FOR garbage:INT IN [0..count) DO next ← next+FindNextWord[node,next]; ENDLOOP;
nChars ← next-start;
Deselect[primary];
TextEdit.DeleteText[root, node, start, nChars, TiogaInput.currentEvent];
MakePointSelection[tSel,pos];
TiogaRefresh.ScrollToEndOfSel[tSel.viewer, TRUE];
EXITS Bad => EditFailed[] };
IF count > 0 THEN CallWithLocks[DoDeleteNextWord] };
GoToNextWord: PUBLIC PROC [count: INT ← 1] = {
DoGoToNextWord: PROC [root: TiogaNode.RefBranchNode, tSel: Selection] = {
pos: TiogaNode.Location ← InsertionPoint[tSel];
node: TiogaNode.RefTextNode;
size, next: TiogaNode.Offset;
IF (node ← TiogaNodeOps.NarrowToTextNode[pos.node])=NIL OR
(next ← pos.where)=TiogaNode.NodeItself THEN { -- try next node
GoToNextNode; RETURN };
size ← TextEdit.Size[node];
FOR garbage:INT IN [0..count) DO
IF next >= size THEN { GoToNextNode; RETURN };
next ← next+FindNextWord[node,next];
ENDLOOP;
MakePointSelection[tSel,[node,next]];
TiogaRefresh.ScrollToEndOfSel[tSel.viewer, TRUE] };
IF count > 0 THEN CallWithLocks[DoGoToNextWord, read] };
GoToNextNode: PUBLIC PROC [count: INT ← 1] = {
DoGoToNextNode: PROC [root: TiogaNode.RefBranchNode, tSel: Selection] = {
pos: TiogaNode.Location ← InsertionPoint[tSel];
node: TiogaNode.Ref ← pos.node;
FOR garbage:INT IN [0..count) DO
IF (node ← TiogaNodeOps.StepForwardNode[node])=NIL THEN { EditFailed[]; RETURN };
ENDLOOP;
MakePointSelection[tSel,[node,0]];
TiogaRefresh.ScrollToEndOfSel[tSel.viewer, TRUE] };
IF count > 0 THEN CallWithLocks[DoGoToNextNode, read] };
GoToPreviousNode: PUBLIC PROC [count: INT ← 1] = {
DoGoToPreviousNode: PROC [root: TiogaNode.RefBranchNode, tSel: Selection] = {
text: TiogaNode.RefTextNode;
pos: TiogaNode.Location ← InsertionPoint[tSel];
node: TiogaNode.Ref ← pos.node;
FOR garbage:INT IN [0..count) DO
IF (node ← TiogaNodeOps.StepBackwardNode[node].back)=NIL OR
TiogaNodeOps.Parent[node]=NIL THEN GOTO Bad;
ENDLOOP;
IF (text ← TiogaNodeOps.NarrowToTextNode[node])=NIL THEN GOTO Bad;
MakePointSelection[tSel,[text,TextEdit.Size[text]]];
TiogaRefresh.ScrollToEndOfSel[tSel.viewer, TRUE];
EXITS Bad => EditFailed[] };
IF count > 0 THEN CallWithLocks[DoGoToPreviousNode, read] };
InsertTime: PUBLIC PROC = {
dateLen: TiogaNode.Offset;
TimeString: PROC RETURNS [time: REF TEXT] = TRUSTED BEGIN OPEN LongString;
s: LONG STRING; -- for convenience;
now: Time.Unpacked = Time.Unpack[Time.Current[]];
time ← NEW[TEXT[30]];
s ← LOOPHOLE[time];
AppendString[s, SELECT now.month FROM
0 => "January"L,
1 => "February"L,
2 => "March"L,
3 => "April"L,
4 => "May"L,
5 => "June"L,
6 => "July"L,
7 => "August"L,
8 => "September"L,
9 => "October"L,
10 => "November"L,
ENDCASE => "December"L];
AppendChar[s, ' ];
AppendDecimal[s, now.day];
AppendString[s , ", "];
AppendDecimal[s, now.year];
dateLen ← s.length; -- remember length of date for selection
AppendChar[s, ' ];
AppendDecimal[s, ((now.hour+11) MOD 12)+1];
AppendChar[s, ':];
AppendDecimal[s, now.minute/10];
AppendDecimal[s, now.minute MOD 10];
AppendString[s, IF now.hour<12 THEN " am" ELSE " pm"];
END;
DoInsertTime: PROC [root: TiogaNode.RefBranchNode, tSel: Selection] = {
resLen: TiogaNode.Offset;
caret: TiogaNode.Location;
dest: TiogaNode.RefTextNode;
looks: TiogaLooks.Looks;
looks ← pSel.looks;
IF pSel.pendingDelete THEN DoPendingDelete[];
caret ← InsertionPoint[pSel];
IF (dest ← TiogaNodeOps.NarrowToTextNode[caret.node])=NIL THEN GOTO Bad;
Deselect[primary];
[----, resLen] ← TextEdit.InsertString[root: root, dest: dest, string: TimeString[],
destLoc: caret.where, inherit: FALSE, looks: looks, event: TiogaInput.currentEvent];
tSel.end.pos.node ← tSel.start.pos.node ← caret.node;
tSel.end.pos.where ← caret.where+resLen-1;
tSel.start.pos.where ← caret.where+dateLen;
tSel.insertion ← after;
tSel.granularity ← char;
tSel.pendingDelete ← FALSE;
MakeSelection[selection: primary, new: tSel];
EXITS Bad => EditFailed[] };
CallWithLocks[DoInsertTime] };
InsertBrackets: PUBLIC PROC [left, right: CHAR] = {
-- insert left char at start of selection, right char after selection
DoInsertBrackets: PROC [root: TiogaNode.RefBranchNode, tSel: Selection] = {
leftEnd, rightEnd: TiogaNode.Location;
leftNode, rightNode: TiogaNode.RefTextNode;
l, r: TiogaNode.Offset;
leftEnd ← tSel.start.pos;
rightEnd ← tSel.end.pos;
IF (leftNode ← TiogaNodeOps.NarrowToTextNode[leftEnd.node])=NIL THEN GOTO Bad;
IF (rightNode ← TiogaNodeOps.NarrowToTextNode[rightEnd.node])=NIL THEN GOTO Bad;
IF (r ← rightEnd.where) = TiogaNode.NodeItself THEN r ← TextEdit.Size[rightNode]
ELSE IF tSel.granularity # point THEN r ← r+1;
IF (l ← leftEnd.where) = TiogaNode.NodeItself THEN l ← 0;
Deselect[primary];
[----, ----] ← TextEdit.InsertChar[
root: root,
dest: rightNode,
char: right,
destLoc: r,
inherit: FALSE, looks: tSel.looks,
event: TiogaInput.currentEvent];
[----, ----] ← TextEdit.InsertChar[
root: root,
dest: leftNode,
char: left,
destLoc: l,
inherit: FALSE, looks: tSel.looks,
event: TiogaInput.currentEvent];
tSel.start.pos.where ← l+1;
IF tSel.granularity = point THEN tSel.end.pos.where ← l+1
ELSE {
tSel.granularity ← char;
IF leftNode=rightNode THEN tSel.end.pos.where ← r};
tSel.pendingDelete ← FALSE;
MakeSelection[selection: primary, new: tSel];
EXITS Bad => EditFailed[] };
CallWithLocks[DoInsertBrackets] };
End: ERROR = CODE; -- private; for use in SelectMatchingBrackets
SelectMatchingBrackets: PUBLIC PROC [left, right: CHAR] = {
IF ~DoSelectMatchingBrackets[left, right] THEN EditFailed["No match."] };
DoSelectMatchingBrackets: PUBLIC PROC [left, right: CHAR] RETURNS [found: BOOL] = {
-- extend selection until includes matching left and right brackets
rdr: RopeReader.Ref ← RopeReader.Create[];
ref, parent: TiogaNode.Ref;
node: TiogaNode.RefTextNode;
GetPreviousNode: PROC RETURNS [n: TiogaNode.RefTextNode] = {
DO -- search for previous text node
[ref,parent] ← TiogaNodeOps.StepBackwardNode[ref,parent];
IF ref=NIL THEN ERROR End;
IF (n ← TiogaNodeOps.NarrowToTextNode[ref]) # NIL THEN RETURN [n];
ENDLOOP };
GetLeftChar: PROC RETURNS [CHAR] = {
RETURN [RopeReader.Backwards[rdr ! RopeReader.ReadOffEnd => {
node ← GetPreviousNode[];
RopeReader.SetPosition[rdr, node.rope, Rope.Size[node.rope]];
RETRY }]] };
GetNextNode: PROC RETURNS [n: TiogaNode.RefTextNode] = {
DO -- search for next text node
IF (ref ← TiogaNodeOps.StepForwardNode[ref])=NIL THEN ERROR End;
IF (n ← TiogaNodeOps.NarrowToTextNode[ref]) # NIL THEN RETURN [n];
ENDLOOP };
GetRightChar: PROC RETURNS [CHAR] = {
RETURN [RopeReader.Get[rdr ! RopeReader.ReadOffEnd => {
node ← GetNextNode[];
RopeReader.SetPosition[rdr, node.rope];
RETRY }]] };
DoSelect: PROC [root: TiogaNode.RefBranchNode, tSel: Selection] = {
leftEnd, rightEnd: TiogaNode.Location;
nest: CARDINAL ← 0;
loc: TiogaNode.Offset;
leftEnd ← tSel.start.pos;
rightEnd ← tSel.end.pos;
ref ← leftEnd.node;
IF (node ← TiogaNodeOps.NarrowToTextNode[ref])=NIL THEN {
IF (node ← GetPreviousNode[])=NIL THEN GOTO NoMatch;
loc ← Rope.Size[node.rope] }
ELSE IF (loc ← leftEnd.where) = TiogaNode.NodeItself THEN loc ← 0;
RopeReader.SetPosition[rdr, node.rope, loc];
DO-- left end
SELECT GetLeftChar[ ! End => GOTO NoMatch] FROM
left => IF nest=0 THEN EXIT ELSE nest ← nest-1;
right => nest ← nest+1;
ENDCASE;
ENDLOOP;
leftEnd.node ← node;
leftEnd.where ← RopeReader.GetIndex[rdr];
ref ← rightEnd.node;
IF (node ← TiogaNodeOps.NarrowToTextNode[ref])=NIL THEN {
IF (node ← GetNextNode[])=NIL THEN GOTO NoMatch;
loc ← 0 }
ELSE IF (loc ← rightEnd.where) = TiogaNode.NodeItself THEN loc ← Rope.Size[node.rope]
ELSE IF pSel.granularity # point THEN loc ← loc+1;
RopeReader.SetPosition[rdr, node.rope, loc];
DO-- right end
SELECT GetRightChar[ ! End => GOTO NoMatch] FROM
right => IF nest=0 THEN EXIT ELSE nest ← nest-1;
left => nest ← nest+1;
ENDCASE;
ENDLOOP;
rightEnd.node ← node;
rightEnd.where ← RopeReader.GetIndex[rdr]-1;
tSel.start.pos ← leftEnd;
tSel.end.pos ← rightEnd;
tSel.granularity ← char;
SetSelLooks[tSel];
MakeSelection[selection: primary, new: tSel];
found ← TRUE;
EXITS NoMatch => found ← FALSE };
CallWithLocks[DoSelect, read] };
NextViewer: PUBLIC PROC [forward: BOOLEAN] = BEGIN
IF ~DoNextViewer[forward] THEN EditFailed["No next viewer."] END;
DoNextViewer: PUBLIC PROC [forward: BOOLEAN] RETURNS [found: BOOL] = BEGIN
OPEN ViewerClasses;
Enumerate: PROC [enum: PROC [Viewer]] = BEGIN
FOR v: Viewer ← pSel.viewer.parent.child, v.sibling UNTIL v=NIL DO
enum[v];
ENDLOOP;
END;
thisViewer: Viewer = pSel.viewer;
nextViewer: Viewer ← NIL;
ConvergeForward: PROC [v: Viewer] = BEGIN
IF v.class.flavor=$Text AND (v.cy > thisViewer.cy
OR (v.cy = thisViewer.cy AND v.cx > thisViewer.cx)) THEN BEGIN
IF nextViewer=NIL OR v.cy < nextViewer.cy THEN {nextViewer ← v; RETURN};
IF v.cy > nextViewer.cy THEN RETURN;
IF (v.cy > thisViewer.cy OR v.cx > thisViewer.cx) AND v.cx < nextViewer.cx THEN
nextViewer ← v; 
END;
END;
ConvergeBackward: PROC [v: Viewer] = BEGIN
IF v.class.flavor=$Text AND (v.cy < thisViewer.cy
OR (v.cy = thisViewer.cy AND v.cx < thisViewer.cx)) THEN BEGIN
IF nextViewer=NIL OR v.cy > nextViewer.cy THEN {nextViewer ← v; RETURN};
IF v.cy < nextViewer.cy THEN RETURN;
IF (v.cy < thisViewer.cy OR v.cx < thisViewer.cx) AND v.cx > nextViewer.cx THEN
nextViewer ← v; 
END;
END;
LockSel[primary, "DoNextViewer"];
{ ENABLE UNWIND => UnlockSel[primary];
IF pSel.viewer=NIL OR pSel.viewer.parent=NIL THEN {
UnlockSel[primary]; EditFailed[]; RETURN [FALSE] };
Enumerate[IF forward THEN ConvergeForward ELSE ConvergeBackward];
IF nextViewer # NIL THEN ViewerTools.SetSelection[nextViewer, NIL];
}; UnlockSel[primary];
RETURN [nextViewer # NIL];
END;
FindPlaceholders: PUBLIC PROCEDURE [next: BOOLEAN] = {
found, wenttoend: BOOL;
[found, wenttoend] ← DoFindPlaceholders[next, TRUE];
IF ~found AND ~wenttoend THEN NextViewer[next] };
DoFindPlaceholders: PUBLIC PROCEDURE [next, gotoend: BOOL,
startBoundaryNode, endBoundaryNode: TiogaNode.Ref ← NIL,
startBoundaryOffset: TiogaNode.Offset ← 0,
endBoundaryOffset: TiogaNode.Offset ← LAST[TiogaNode.Offset]]
RETURNS [found, wenttoend: BOOL] = {
DoFind: PROC [root: TiogaNode.RefBranchNode, tSel: Selection] = {
finder: TreeFind.Finder ← TreeFind.CreateFromRope[IF next THEN "" ELSE ""];
from: TiogaNode.Location;
where: TiogaNode.RefTextNode;
at, atEnd, start: TiogaNode.Offset;
Failed: PROC = {
IF gotoend THEN {
loc: TiogaNode.Location = IF next THEN TiogaNodeOps.LastLocWithin[root]
ELSE [TiogaNodeOps.BranchChild[root],0];
IF loc # from OR tSel.granularity # point THEN {
wenttoend ← TRUE;
RememberCurrentPosition[tSel.viewer];
MakePointSelection[tSel, loc];
TiogaRefresh.ScrollToEndOfSel[tSel.viewer, FALSE] }};
};
from ← InsertionPoint[tSel];
start ← from.where;
IF next AND tSel.insertion=before AND tSel.granularity#point THEN start ← start+1
ELSE IF ~next AND tSel.insertion=after THEN start ← MAX[start-1,0];
[found,where,at,atEnd,,] ← IF next THEN
TreeFind.Try[finder: finder, first: from.node, start: start,
last: endBoundaryNode, lastLen: endBoundaryOffset]
ELSE TreeFind.TryBackwards[finder: finder, first: from.node, len: start,
last: startBoundaryNode, lastStart: startBoundaryOffset];
wenttoend ← FALSE;
IF ~found THEN { Failed[]; RETURN };
MakePointSelection[tSel, [where,IF next THEN at+1 ELSE MAX[at,0]]];
IF ~DoSelectMatchingBrackets[','] THEN { Failed[]; RETURN };
TiogaSelection.Copy[source: pSel, dest: tSel];
tSel.insertion ← before;
tSel.pendingDelete ← TRUE;
RememberCurrentPosition[tSel.viewer];
tSel.looks ← TextEdit.FetchLooks[ -- take looks from first char after the 
TiogaNodeOps.NarrowToTextNode[tSel.start.pos.node], tSel.start.pos.where+1];
MakeSelection[tSel, primary];
TiogaInput.CloseEvent[];
TiogaRefresh.ScrollToEndOfSel[tSel.viewer, FALSE];
};
CallWithLocks[DoFind, read] };
END.