DIRECTORY InputFocus USING [GetInputFocus], Rope USING [ROPE], ViewerClasses USING [Viewer, ViewerRec], ViewerOps USING [CreateViewer, FindViewer]; ViewerTools: CEDAR DEFINITIONS IMPORTS InputFocus, ViewerOps = BEGIN OPEN ViewerClasses, ViewerOps; ---------- Finding and Creating Viewers ---------- FindExistingViewer: PROC [fileName: Rope.ROPE] RETURNS [viewer: Viewer] = INLINE {RETURN[FindViewer[fileName]]}; MakeNewTextViewer: PROC [info: ViewerClasses.ViewerRec _ [], paint: BOOL _ TRUE] RETURNS [viewer: Viewer] = INLINE {RETURN[CreateViewer[flavor: $Text, info: info, paint: paint]]}; ---------- 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] = INLINE {viewer.class.set[viewer, selection, TRUE, $SelPos]}; GetSelectedViewer: PROC RETURNS [viewer: Viewer] = INLINE {RETURN[InputFocus.GetInputFocus[].owner]} ; GetSelectionContents: PROC RETURNS [contents: Rope.ROPE] = INLINE { v: Viewer = GetSelectedViewer[]; RETURN[IF v=NIL OR v.class.get=NIL THEN NIL ELSE NARROW[v.class.get[v, $SelChars]]]}; GetSelection: PROC [viewer: Viewer] RETURNS [selection: SelPos] = INLINE {RETURN[NARROW[viewer.class.get[viewer, $SelPos]]]}; ---------- Contents of Viewers ---------- GetContents: PROC [viewer: Viewer] RETURNS [contents: Rope.ROPE] = INLINE { RETURN[IF viewer.class.get=NIL THEN NIL ELSE NARROW[viewer.class.get[viewer]]]}; SetContents: PROC [viewer: Viewer, contents: Rope.ROPE, paint: BOOL _ TRUE] = INLINE { IF viewer.class.set#NIL THEN viewer.class.set[viewer, contents, paint]}; TiogaContents: TYPE = REF TiogaContentsRec ; TiogaContentsRec: TYPE = RECORD [ contents: Rope.ROPE _ NIL, formatting: Rope.ROPE _ NIL ] ; GetTiogaContents: PROC [viewer: Viewer] RETURNS [contents: TiogaContents] = INLINE { RETURN[IF viewer.class.get=NIL THEN NIL ELSE NARROW[viewer.class.get[viewer, $TiogaContents]]]}; SetTiogaContents: PROC [viewer: Viewer, contents: TiogaContents, paint: BOOL _ TRUE] = INLINE { IF viewer.class.set#NIL THEN viewer.class.set[viewer, contents, paint, $TiogaContents]}; InhibitUserEdits: PROC [viewer: Viewer] = INLINE { viewer.class.set[viewer, NIL, TRUE, $ReadOnly]} ; EnableUserEdits: PROC [viewer: Viewer] = INLINE { viewer.class.set[viewer, NIL, TRUE, $ReadWrite]} ; END. ˜ViewerTools.mesa, Written by S. McGregor Edited by McGregor on July 21, 1983 10:50 am Last Edited by: Maxwell, January 3, 1983 12:14 pm Returns NIL if none could be found. Use VirtualDesktops.FindExistingViewer to search past current desktop. 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. -------- 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. Returns the selected viewer. Returns the contents of the selected viewer's selection. Works only when the input focus is in a Tioga and Typescript viewer. Returns the selected viewer and the position of its selection. Works only for Tioga viewers! -------- Works for text and maybe some other classes Returns the contents of a Tioga document (formatting information is omitted). Set the contents of a Tioga document. Returns the contents and formatting of a Tioga document. Set the contents and formatting of a Tioga document. Prevent the user from editing a text viewer. Allow the user to edit a text viewer. -------- Κ– "cedar" style˜JšΟc(™(Jš,™,J™1J™šΟk ˜ Jšœ žœ˜!Jšœžœžœ˜Jšœžœ˜(Jšœ žœ˜+J˜—Jšœ žœžœ˜>J˜Jšžœžœ˜$J˜J˜Jš3˜3J˜šΟnœžœžœžœ˜IJšžœžœ˜&Jšk™kJ˜—šŸœžœ-žœžœ˜PJšžœ˜Jšžœžœ9˜GJšι™ιJ˜—Jš*™*J˜Jš,™,J˜Jš(™(J˜Jš™J˜Jš/˜/J˜Jšœžœžœ ˜šœ žœžœ˜Jšœžœžœ˜ Jšœžœžœ˜Jšœ$˜$J˜—šŸ œžœ&žœž˜EJšœ%žœ ˜5Jš»™»J˜—šŸœžœžœž˜9Jšœžœ%˜,Jš™J˜—š Ÿœžœžœžœžœ˜CJ˜ Jšžœžœžœžœ žœžœžœžœžœ˜UJš~™~J˜—šŸ œžœžœž˜HJšœžœžœ&˜4Jš]™]J˜—Jš™J˜Jš*˜*J˜Jš+™+J˜š Ÿ œžœžœžœžœ˜KJšžœžœžœžœžœžœžœ˜PJšM™MJ˜—š Ÿ œžœ!žœ žœžœžœ˜VJšžœžœžœ,˜HJš%™%J˜—Jšœžœžœ˜,šœžœžœ˜!Jšœžœžœ˜Jšœžœž˜J˜J˜—šŸœžœžœžœ˜Tšžœžœžœžœžœžœžœ˜LJ˜—Jš8™8J˜—š Ÿœžœ2žœžœžœ˜_Jšžœžœžœ<˜XJš4™4J˜—šŸœžœžœ˜2Jšœžœžœ˜1Jš,™,J˜—šŸœžœžœ˜1Jšœžœžœ˜2Jš%™%J˜—Jš™J˜Jšžœ˜J˜J˜—…— ˆ?