QueryTEditDocumentsCache2Impl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Edited by Paxton on October 21, 1982 9:33 am
Michael Plass, April 10, 1985 9:59:29 am PST
Doug Terry, April 9, 1987 1:48:37 pm PDT
DIRECTORY
Menus USING [ChangeNumberOfLines],
Rope USING [Equal, Map, ROPE, Size],
TEditDocumentsCache USING [GetList],
TEditProfile USING [showUnsavedDocumentsList],
TiogaAccess USING [Create, Looks, Put, Writer, WriteViewer],
ViewerClasses USING [Viewer],
ViewerOps USING [CreateViewer, DestroyViewer, EstablishViewerPosition, PaintViewer];
QueryTEditDocumentsCache2Impl: CEDAR MONITOR
IMPORTS Menus, Rope, TEditDocumentsCache, TEditProfile, TiogaAccess, ViewerOps
EXPORTS TEditDocumentsCache = BEGIN
ROPE: TYPE ~ Rope.ROPE;
viewer: ViewerClasses.Viewer;
Update: PUBLIC ENTRY PROC = {
ENABLE UNWIND => NULL;
rope: ROPE ← TEditDocumentsCache.GetList[]; -- this is monitored, so get consistent list
viewerName: ROPE = "Unsaved Documents List";
ViewerOk: PROC RETURNS [BOOL] = {
RETURN [viewer # NIL AND NOT viewer.destroyed AND viewer.file=NIL AND
Rope.Equal[viewer.name, viewerName]]
};
writer: TiogaAccess.Writer ~ TiogaAccess.Create[];
looks: TiogaAccess.Looks ← ALL[FALSE];
format: ATOMNIL;
comment: BOOLFALSE;
deltaLevel: INT ← 1;
Put: PROC [rope: ROPE] ~ {
action: PROC [c: CHAR] RETURNS [quit: BOOLFALSE] ~ {
TiogaAccess.Put[writer, [
charSet: 0,
char: c,
looks: looks,
format: format,
comment: comment,
endOfNode: (c = '\n),
deltaLevel: deltaLevel,
propList: NIL
]];
};
[] ← Rope.Map[base: rope, action: action];
};
IF NOT TEditProfile.showUnsavedDocumentsList THEN RETURN;
IF Rope.Size[rope] = 0 THEN {
IF ViewerOk[] THEN ViewerOps.DestroyViewer[viewer];
RETURN
};
IF NOT ViewerOk[] THEN {
viewer ← ViewerOps.CreateViewer[flavor: $QueryText, info: [name: viewerName,
iconic: TRUE], paint: FALSE];
viewer.class.set[self: viewer, data: NIL, op: $ReadOnly];
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]
};
format ← $note;
Put["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"];
format ← $lead;
deltaLevel ← 0;
Put[rope];
Put["\n"];
TiogaAccess.WriteViewer[writer, viewer];
viewer.newVersion ← TRUE; -- set edited bit
ViewerOps.PaintViewer[viewer, caption]
}; -- repaint the caption
END.