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: ATOM ← NIL;
comment: BOOL ← FALSE;
deltaLevel: INT ← 1;
Put:
PROC [rope:
ROPE] ~ {
action:
PROC [c:
CHAR]
RETURNS [quit:
BOOL ←
FALSE] ~ {
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: $Text, 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