TEditDocumentsCache2Impl.mesa; Edited by Paxton on October 21, 1982 9:33 am
DIRECTORY
Menus USING [ChangeNumberOfLines],
Rope USING [Concat, Equal, ROPE],
TEditDocumentsCache,
TEditDocumentPrivate,
TEditProfile USING [showUnsavedDocumentsList],
ViewerClasses USING [Viewer],
ViewerOps USING [CreateViewer, DestroyViewer, EstablishViewerPosition, PaintViewer],
ViewerTools USING [SetContents];
TEditDocumentsCache2Impl: CEDAR MONITOR
IMPORTS Menus, Rope, TEditProfile, ViewerOps, ViewerTools, TEditDocumentsCache
EXPORTS TEditDocumentsCache =
BEGIN OPEN TEditDocumentsCache, TEditDocumentPrivate;
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 ~TEditProfile.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.