TiogaDocumentsCache2Impl.mesa; Edited by Paxton on October 21, 1982 9:33 am
DIRECTORY
Menus USING [ChangeNumberOfLines],
Rope USING [Concat, Equal, ROPE],
TiogaDocumentsCache,
TiogaDocumentPrivate,
TiogaProfile USING [showUnsavedDocumentsList],
ViewerClasses USING [Viewer],
ViewerOps USING [CreateViewer, DestroyViewer, EstablishViewerPosition, PaintViewer],
ViewerTools USING [SetContents];
TiogaDocumentsCache2Impl: CEDAR MONITOR
IMPORTS Menus, Rope, TiogaProfile, ViewerOps, ViewerTools, TiogaDocumentsCache
EXPORTS TiogaDocumentsCache =
BEGIN OPEN TiogaDocumentsCache, TiogaDocumentPrivate;
viewer: ViewerClasses.Viewer;
Update: PUBLIC ENTRY PROC = {
ENABLE UNWIND => NULL;
rope: ROPE ← GetList[]; -- this is monitored, so get consistent list
viewerName: ROPE = "Unsaved Documents List";
ViewerOk: PROC RETURNS [BOOL] = {
RETURN [viewer # NIL AND ~viewer.destroyed AND viewer.file=NIL AND
Rope.Equal[viewer.name, viewerName]] };
IF ~TiogaProfile.showUnsavedDocumentsList THEN RETURN;
IF rope=NIL THEN {
IF ViewerOk[] THEN ViewerOps.DestroyViewer[viewer];
RETURN };
IF ~ViewerOk[] THEN {
viewer ← ViewerOps.CreateViewer[flavor: $Text, info: [name: viewerName,
iconic: TRUE], paint: FALSE];
Menus.ChangeNumberOfLines[viewer.menu, 0]; -- don't let user mess with it
ViewerOps.EstablishViewerPosition[viewer, viewer.wx, viewer.wy, viewer.ww, viewer.wh];
ViewerOps.PaintViewer[viewer, all] };
rope ← Rope.Concat["The following files were edited but not saved. They may still be restored with edits intact simply by loading them. If you really want to get rid of the edits, load the file and hit Reset.\n", rope];
ViewerTools.SetContents[viewer, rope];
viewer.newVersion ← TRUE; -- set edited bit
ViewerOps.PaintViewer[viewer, caption] }; -- repaint the caption
END.