TEditTouchupImpl.mesa
Copyright Ó 1985, 1987, 1991 by Xerox Corporation. All rights reserved.
Paxton on May 23, 1983 11:27 am
Maxwell, January 6, 1983 11:38 am
Russ Atkinson (RRA) June 4, 1985 1:20:12 am PDT
Michael Plass, October 15, 1987 5:24:26 pm PDT
DIRECTORY
CedarProcess USING [SetPriority],
MonitoredQueue USING [Create, MQ, Remove],
Process USING [Detach, MsecToTicks, SetTimeout],
Rope USING [ROPE],
TEditDocument USING [GetViewerForRoot, SelectionId, SpinAndLock, TEditDocumentData, Unlock],
TEditRefresh USING [],
TEditTouchup USING [],
TextNode USING [Ref],
ViewerClasses USING [Viewer],
ViewerForkers USING [ForkPaint];
TEditTouchupImpl: CEDAR MONITOR
IMPORTS CedarProcess, MonitoredQueue, Process, TEditDocument, ViewerForkers
EXPORTS TEditRefresh, TEditTouchup
=
BEGIN
fullUpdate: PUBLIC REF ANY ¬ $Update;
refresh: PUBLIC REF ANY ¬ $Refresh;
RefreshOver:
PUBLIC
ENTRY
PROC = {
ENABLE
UNWIND =>
NULL;
BROADCAST refreshOver };
LockAfterScroll:
PUBLIC
PROC [tdd: TEditDocument.TEditDocumentData, who: Rope.
ROPE]
RETURNS [ok:
BOOL] = {
RETURN [LockAfter[tdd, who, TRUE]];
};
LockAfterRefresh:
PUBLIC
PROC [tdd: TEditDocument.TEditDocumentData, who: Rope.
ROPE]
RETURNS [ok:
BOOL] = {
RETURN [LockAfter[tdd, who, FALSE]];
};
LockAfter:
PROC [tdd: TEditDocument.TEditDocumentData, who: Rope.
ROPE, scroll:
BOOL]
RETURNS [ok:
BOOL ¬
TRUE] = {
[] ¬ TEditDocument.SpinAndLock[tdd, "LockAfterRefresh"];
SELECT
TRUE
FROM
NOT tdd.dirty => ok ¬ TRUE;
alwaysOK => ok ¬ TRUE;
NOT scroll OR tdd.scroll=no => ok ¬ FALSE;
ENDCASE => ok ¬ TRUE;
IF NOT ok THEN TEditDocument.Unlock[tdd];
};
alwaysOK: BOOL ¬ FALSE;
UnlockAfterRefresh:
PUBLIC PROC [tdd: TEditDocument.TEditDocumentData] = {
IF tdd#NIL THEN TEditDocument.Unlock[tdd];
};
refreshOver: CONDITION; -- Init below
maxCount: NAT ¬ 0;
TEditRefresh implementation
dirtyDocs:
PUBLIC MonitoredQueue.
MQ ¬ MonitoredQueue.Create[];
Refresh:
PROC = {
CedarProcess.SetPriority[normal];
DO
WITH MonitoredQueue.Remove[dirtyDocs]
SELECT
FROM
doc: TextNode.Ref => {
viewer: ViewerClasses.Viewer ¬ TEditDocument.GetViewerForRoot[doc];
IF viewer #
NIL
THEN
WITH viewer.data
SELECT
FROM
tdd: TEditDocument.TEditDocumentData =>
FOR v: ViewerClasses.Viewer ¬ viewer, v.link
WHILE v #
NIL
DO
IF
NOT v.iconic
AND
NOT v.destroyed
THEN
ViewerForkers.ForkPaint[v, client, FALSE, refresh, TRUE];
IF v.link = viewer THEN EXIT;
ENDLOOP;
ENDCASE;
};
ENDCASE;
ENDLOOP;
};
ScrollToEndOfDoc:
PUBLIC
PROC [viewer: ViewerClasses.Viewer, glitch:
BOOL] = {
WITH viewer.data
SELECT
FROM
tdd: TEditDocument.TEditDocumentData => {
tdd.scroll ¬ endofdoc;
tdd.scrollGlitch ¬ glitch;
};
ENDCASE;
};
ScrollToEndOfSel:
PUBLIC
PROC [viewer: ViewerClasses.Viewer, glitch:
BOOL, id: TEditDocument.SelectionId ¬ primary] = {
WITH viewer.data
SELECT
FROM
tdd: TEditDocument.TEditDocumentData => {
tdd.scroll ¬ endofsel;
tdd.scrollGlitch ¬ glitch;
tdd.scrollSelectionId ¬ id;
};
ENDCASE;
};
Startup
TRUSTED {
Process.SetTimeout[@refreshOver, Process.MsecToTicks[50]];
Process.Detach[FORK Refresh[]];
};
END.