DIRECTORY
AMModel USING [Context, Section],
AMModelBridge USING [LoadedSection],
BcdDefs USING [VersionStamp],
Rope USING [ROPE],
RTBasic USING [TV],
ViewerClasses USING [Viewer],
WorldVM USING [World];
AMViewerOps:
CEDAR
DEFINITIONS
= BEGIN OPEN Rope, RTBasic, WorldVM;
Section: TYPE = AMModel.Section;
LoadedSection: TYPE = AMModelBridge.LoadedSection;
SourceError: PUBLIC ERROR [reason: ROPE];
... occurs when we can't make a viewer from a global frame TV. The reason explains why (at least at a gross level).
SelectionOption:
TYPE = {primary, feedback};
primary => use primary selection
feedback => use feedback selection
Viewers/Section translations
ViewerFromSection:
PROC
[section: AMModel.Section, report: ReportProc] RETURNS [viewer: ViewerClasses.Viewer];
... returns an open viewer for the given LoadedSection; Reports through report if not possible.
SectionFromSource:
PROC
[world: World ← NIL, name: ROPE ← NIL, index: INT ← 0]
RETURNS [section: AMModel.Section, contexts: LIST OF AMModel.Context];
... returns a section for the given source (the name can be a long path name); ERROR SourceError if this cannot be done. If world = NIL then world ← LocalWorld. warn = TRUE => the version of the source file for the given location does not correspond to the viewer (although this is no guarantee that the wrong thing happened). The name given MUST be for an open viewer, and the index given MUST be in the proper source range.
SectionFromSelection:
PROC
[world: World ← NIL, which: SelectionOption ← primary]
RETURNS [section: AMModel.Section, contexts: LIST OF AMModel.Context];
... returns a loaded section for the given viewer; ERROR SourceError if this cannot be done. If world = NIL then world ← LocalWorld. warn = TRUE => the version of the source file for the given location does not correspond to the viewer (although this is no guarantee that the wrong thing happened). The name given MUST be for an open viewer, and the index given MUST be in the proper source range.
**** Utility routines ****
These routines are hardly essential
SourceFromSelection:
PROC
[which: SelectionOption ← primary]
RETURNS [name: ROPE ← NIL, index: INT ← -1];
... returns the file name and position within the file for the selected viewer (returns [NIL, -1] if no valid Tioga viewer is selected). This is not essential here, but it can be useful.
GFToVersionStamps:
PUBLIC
PROC
[gf: TV] RETURNS [source,object: BcdDefs.VersionStamp];
... returns the source and object version stamps for the given global frame TV, or returns BcdDefs.NullVersion for both if this cannot be done.
FileVersion:
PUBLIC
PROC
[name: ROPE] RETURNS [version: BcdDefs.VersionStamp];
... returns the version stamp (create date) for the named file (the path name can be long). This routine does not return the correct version stamp for a BCD file, but after all, this module just supports source mapping!
SourceFromTV:
PROC [tv:
TV, report: ReportProc]
RETURNS [name:
ROPE, index:
INT];
... gets the source file name and the source index for the given TV, which must be a local frame or global frame; if not successful, then name = NIL & index < 0.
OpenSource:
PROC [name:
ROPE, index:
INT, chars:
INT ← 2, report: ReportProc];
... uses the results of GetSource to open a viewer on the source. If index >= 0, then also set the feedback selection to the given index (for chars characters).
ReportProc:
TYPE =
PROC [msg:
ROPE, severity: Severity];
... is the type of user-supplied procedure used to report results in above operations
ReportError:
ERROR [msg:
ROPE, severity: Severity];
... is the error used if supplied ReportProc = NIL and severity IN [warning..fatal]
Severity:
TYPE = {success, comment, warning, fatal};
success => operation is completed
comment => intermediate information
warning => something is wrong, but not fatal
fatal => operation is completed, but did not succeed
END.