DIRECTORY TEditRefresh, MonitoredQueue USING [Create, MQ, Remove], Process USING [Detach, SetPriority, priorityNormal], TEditDocument USING [GetViewerForRoot, SelectionId, TEditDocumentData], TEditLocks USING [LockDocAndTdd, UnlockDocAndTdd], TextNode USING [pZone, Ref], TEditTouchup USING [refresh, RefreshOver], ViewerClasses USING [Viewer], ViewerOps USING [PaintViewer]; TEditRefreshImpl: CEDAR MONITOR IMPORTS MonitoredQueue, Process, TextNode, TEditDocument, TEditLocks, TEditTouchup, ViewerOps EXPORTS TEditRefresh = BEGIN dirtyDocs: PUBLIC MonitoredQueue.MQ _ MonitoredQueue.Create[TextNode.pZone]; processCount, scrollProcessCount: INTEGER _ 0; maxProcesses: INTEGER = 10; -- max number of concurrent refresh processes done: CONDITION; DecCount: ENTRY PROC = { processCount _ processCount-1; NOTIFY done }; Refresh: PROC = { TRUSTED {Process.SetPriority[Process.priorityNormal]}; DO doc: TextNode.Ref; viewer: ViewerClasses.Viewer; RefreshIt: ENTRY PROC [viewer: ViewerClasses.Viewer] = { WHILE processCount >= maxProcesses DO WAIT done; ENDLOOP; processCount _ processCount+1; TRUSTED {Process.Detach[FORK RefreshViewer[viewer ! ABORTED => CONTINUE]]} }; doc _ NARROW[MonitoredQueue.Remove[dirtyDocs]]; viewer _ TEditDocument.GetViewerForRoot[doc]; IF viewer=NIL THEN LOOP; RefreshIt[viewer]; IF viewer.link # NIL THEN FOR v: ViewerClasses.Viewer _ viewer.link, v.link UNTIL v=viewer DO RefreshIt[v]; ENDLOOP; ENDLOOP }; RefreshViewer: PROC [viewer: ViewerClasses.Viewer] = { tdd: TEditDocument.TEditDocumentData = NARROW[viewer.data]; IF tdd = NIL THEN RETURN; [] _ TEditLocks.LockDocAndTdd[tdd, "RefreshViewer", read]; tdd.invisible _ TRUE; -- will be reset by our paint proc if it is called ViewerOps.PaintViewer[viewer, client, FALSE, TEditTouchup.refresh]; IF tdd.invisible THEN TEditTouchup.RefreshOver[]; DecCount[]; TEditLocks.UnlockDocAndTdd[tdd] }; ScrollToEndOfDoc: PUBLIC PROC [viewer: ViewerClasses.Viewer, glitch: BOOL] = { tdd: TEditDocument.TEditDocumentData = NARROW[viewer.data]; IF tdd=NIL THEN RETURN; tdd.scroll _ endofdoc; tdd.scrollGlitch _ glitch }; ScrollToEndOfSel: PUBLIC PROC [viewer: ViewerClasses.Viewer, glitch: BOOL, id: TEditDocument.SelectionId _ primary] = { tdd: TEditDocument.TEditDocumentData = NARROW[viewer.data]; IF tdd=NIL THEN RETURN; tdd.scroll _ endofsel; tdd.scrollGlitch _ glitch; tdd.scrollSelectionId _ id }; TRUSTED {Process.Detach[FORK Refresh[]]}; END. Ú-- TEditRefreshImpl.mesa Edited by Paxton on December 28, 1982 2:06 pm Last Edited by: Maxwell, January 6, 1983 11:35 am Last Edited by: Wyatt, December 9, 1983 3:17 pm in case we're waiting in LockAfterRefresh Êù˜JšÏcF™FJ™1J™/J™šÏk ˜ J˜ Jšœžœ žœ˜*Jšœžœ'˜4Jšœžœ4˜GJšœ žœ"˜2Jšœ žœ˜Jšœ žœ˜*Jšœžœ ˜Jšœ žœ˜J˜—Jšœž ˜J˜JšžœV˜]Jšžœž˜J˜Jšœ žœžœ)˜LJ˜Jšœ"žœ˜.Jšœžœ-˜IJšœž œ˜J˜šÏnœžœžœ˜Jšœžœ˜-—J˜šŸœžœ˜Jšžœ/˜6šž˜Jšœ˜Jšœ˜šŸ œžœžœ#˜8Jšžœžœžœžœ˜9Jšœž˜Jšžœžœžœžœ˜M—Jšœžœ#˜/Jšœ-˜-Jšžœžœžœžœ˜Jšœ˜šžœžœž˜šžœ/žœ ž˜CJšœžœ˜——Jšžœ˜ ——J˜šŸ œžœ#˜6Jšœ'žœ˜;Jšžœžœžœžœ˜Jšœ:˜:Jšœžœ2˜HJšœ&žœ˜Cšžœžœ˜1Jš)™)—Jšœ ˜ Jšœ"˜"J˜—šŸœž œ(žœ˜NJšœ'žœ˜;Jšžœžœžœžœ˜Jšœ3˜3J˜—šŸœž œ(žœ˜JJšœ,˜,Jšœ'žœ˜;Jšžœžœžœžœ˜JšœO˜OJ˜—Jšžœžœ ˜)J˜Jšžœ˜J˜J˜—…— € S