ViewerTools.mesa
Copyright Ó 1985, 1986, 1991 by Xerox Corporation. All rights reserved.
Edited by McGregor on September 2, 1982 9:34 am
Last Edited by: Maxwell, January 3, 1983 12:14 pm
Doug Wyatt, March 28, 1985 9:28:15 pm PST
DIRECTORY
Rope USING [ROPE],
ViewerClasses USING [Viewer, ViewerRec];
ViewerTools: CEDAR DEFINITIONS
= BEGIN OPEN ViewerClasses;
ROPE: TYPE ~ Rope.ROPE;
Viewer: TYPE ~ ViewerClasses.Viewer;
ViewerRec: TYPE ~ ViewerClasses.ViewerRec;
Finding and Creating Viewers
FindExistingViewer: PROC [fileName: ROPE] RETURNS [viewer: Viewer];
Returns NIL if none could be found.
MakeNewTextViewer: PROC [info: ViewerRec ¬ [], paint: BOOL ¬ TRUE]
RETURNS [viewer: Viewer];
If info.parent=NIL then creates a top-level viewer. Specify name and file in info. Otherwise, pass wx, wy, ww, wh in info for size. For initial contents, pass a rope as the data field in info, or pass a filename in the file field.
See Buttons.mesa for creating new buttons.
See Containers.mesa for creating new labels.
See Labels.mesa for creating new labels.
Operations on Selections
SelPos: TYPE = REF SelPosRec;
SelPosRec: TYPE = RECORD [
start, length: LONG INTEGER ¬ 0,
pendingDelete: BOOL ¬ FALSE,
caretPos: {before, after} ¬ before
];
SetSelection: PROC [viewer: Viewer, selection: SelPos ¬ NIL];
Set and scroll to a selection. For typescripts, NIL => caret at end. For other text viewers, NIL => entire contents in pending-delete mode. Works only for Tioga and Typescript viewers.
GetSelectedViewer: PROC RETURNS [viewer: Viewer];
Returns the selected viewer.
GetSelectionContents: PROC RETURNS [contents: ROPE];
Returns the contents of the selected viewer's selection. Works only when the input focus is in a Tioga and Typescript viewer.
GetSelection: PROC [viewer: Viewer] RETURNS [selection: SelPos];
Returns the selected viewer and the position of its selection. Works only for Tioga viewers!
Contents of Viewers
Works for text and maybe some other classes
GetContents: PROC [viewer: Viewer] RETURNS [contents: ROPE];
Returns the contents of a Tioga document (formatting information is omitted).
SetContents: PROC [viewer: Viewer, contents: ROPE, paint: BOOL ¬ TRUE];
Set the contents of a Tioga document.
TiogaContents: TYPE = REF TiogaContentsRec ;
TiogaContentsRec: TYPE = RECORD [
contents: ROPE ¬ NIL,
formatting: ROPE ¬ NIL
];
GetTiogaContents: PROC [viewer: Viewer] RETURNS [contents: TiogaContents];
Returns the contents and formatting of a Tioga document.
SetTiogaContents: PROC [viewer: Viewer, contents: TiogaContents, paint: BOOL ¬ TRUE];
Set the contents and formatting of a Tioga document.
InhibitUserEdits: PROC [viewer: Viewer];
Prevent the user from editing a text viewer.
EnableUserEdits: PROC [viewer: Viewer];
Allow the user to edit a text viewer.
END.