home *** CD-ROM | disk | FTP | other *** search
Wrap
Oberon Document | 1994-06-07 | 7.4 KB | 180 lines | [ oODC/obnF]
Documents.StdDocumentDesc Documents.DocumentDesc Containers.ViewDesc Views.ViewDesc Stores.StoreDesc Documents.ModelDesc Containers.ModelDesc Models.ModelDesc Stores.ElemDesc TextViews.StdViewDesc TextViews.ViewDesc TextModels.StdModelDesc TextModels.ModelDesc TextModels.AttributesDesc Geneva TextRulers.StdRulerDesc TextRulers.RulerDesc TextRulers.StdStyleDesc TextRulers.StyleDesc TextRulers.AttributesDesc Geneva Geneva 6.6 TextControllers DEFINITION TextControllers; IMPORT Models, Views, Containers, TextModels, TextViews; CONST noAutoScroll = 16; noAutoIndent = 17; none = -1; TYPE LONGCHAR = INTEGER; Controller = POINTER TO ControllerDesc; ControllerDesc = RECORD (Containers.ControllerDesc) view-: TextViews.View; text-: TextModels.Model; PROCEDURE (c: Controller) Clone (): Controller; PROCEDURE (c: Controller) InitView (v: Views.View); PROCEDURE (c: Controller) CaretPos (): LONGINT; PROCEDURE (c: Controller) SetCaret (pos: LONGINT); PROCEDURE (c: Controller) GetSelection (VAR beg, end: LONGINT); PROCEDURE (c: Controller) SetSelection (beg, end: LONGINT) END; Directory = POINTER TO DirectoryDesc; DirectoryDesc = RECORD (Containers.DirectoryDesc) PROCEDURE (d: Directory) NewController (opts: SET): Controller; PROCEDURE (d: Directory) New (): Controller END; ModelMessage = RECORD (Models.Message) END; SetCaretMsg = RECORD (ModelMessage) pos: LONGINT END; SetSelectionMsg = RECORD (ModelMessage) beg, end: LONGINT END; VAR dir-, stdDir-: Directory; PROCEDURE SetDir (d: Directory); PROCEDURE Install; PROCEDURE Focus (): Controller; PROCEDURE SetCaret (text: TextModels.Model; pos: LONGINT); PROCEDURE SetSelection (text: TextModels.Model; beg, end: LONGINT); END TextControllers. TextControllers are the standard controllers for text views as defined in TextViews. CONST noAutoScroll Possible element of controller option set. If included, automatic scrolling of views is disabled. Autoscrolling is used to show the caret position or to show the position of the modification performed most recently. CONST noAutoIndent Possible element of controller option set. If included, automatic indentation after entering a line character is disabled. CONST none Possible argument to controller.SetCaret and controller.SetSelection to indicate removal of the caret or the selection, respectively. Likewise, controller.CarPos and controller.GetSelection may return none to indicate the absense of a caret or selection, respectively. TYPE LONGCHAR = INTEGER Type of long characters. TYPE Controller Interface, Extension Standard controllers for text views. view-: TextViews.View The view to which the controller is connected. text-: TextModels.Model view # NIL => text = view.ThisText() The text displayed by the controlled view; cached for easy access. PROCEDURE (c: Controller) Clone (): Controller Default, Extension Result type is narrowed. PROCEDURE (c: Controller) InitView (v: Views.View) Default, Extension Strengthened preconditions! c.init 20 v = NIL # c.view = NIL 21 c.view = NIL v IS TextViews.View 22 v # NIL c.view = v c.text = c.view.ThisModel() v = NIL c.view = NIL c.text = NIL PROCEDURE (c: Controller) CaretPos (): LONGINT Interface Current position of the caret, or none if not set. result = none OR 0 <= result <= c.text.Length() PROCEDURE (c: Controller) SetCaret (pos: LONGINT) Interface Set the caret at position pos, or remove the caret if pos = none. pos = none OR 0 <= pos 20 pos <= c.text.Length() 21 c.CarPos() = pos PROCEDURE (c: Controller) GetSelection (VAR beg, end: LONGINT) Interface Get the currently selected stretch [beg, end), or beg = end if none exists. beg = end OR 0 <= beg <= end <= c.text.Length() PROCEDURE (c: Controller) SetSelection (beg, end: LONGINT) Interface Set the stretch to be selected to [beg, end), or remove the selection if beg = end. beg = end OR 0 <= beg < end <= c.text.Length() 20 c.GetSelection(b, e): b = beg, e = end TYPE Directory Directory for controllers. PROCEDURE (d: Directory) NewController (opts: SET): Controller Interface Return new controller with options opts. PROCEDURE (d: Directory) New (): Controller Default, Extension Result type is narrowed. Except for performance, equivalent to: RETURN d.NewController({}) TYPE ModelMessage Interface Messages to control virtual model extensions, such as marks (e.g. caret or selection). TYPE SetCaretMsg Extension Set the caret in a view displaying text model msg.model. pos: LONGINT Set the caret at position pos. TYPE SetSelectionMsg Extension Set the caret in a view displaying text model msg.model. beg, end: LONGINT Set the selection to cover the stretch [beg, end). VAR dir-, stdDir-: Directory dir # NIL, stdDir # NIL, stable stdDir = d Directory and standard directory objects for controllers. PROCEDURE SetDir (d: Directory) Set the directory object. d # NIL 20 dir = d PROCEDURE Install Install the current controller directory object in TextViews. Except for performance, equivalent to: TextViews.SetCtrlDir(dir) PROCEDURE Focus (): Controller Return the text controller that currently has the focus, if any. Except for performance, equivalent to: VAR v: Views.View; c: Controllers.Controller; v := Controllers.FocusView(); IF (v # NIL) & (v IS TextViews.View) THEN c := v(TextViews.View).ThisController(); IF (c # NIL) & (c IS Controller) THEN RETURN c(Controller) ELSE RETURN NIL END ELSE RETURN NIL PROCEDURE SetCaret (text: TextModels.Model; pos: LONGINT) In all views displaying text, set the caret to position pos. text # NIL 20 pos = none OR 0 <= pos 21 pos <= text.Length() 22 Except for performance, equivalent to: VAR cm: SetCaretMsg; cm.pos := pos; Models.Broadcast(text, cm) PROCEDURE SetSelection (text: TextModels.Model; beg, end: LONGINT) In all views displaying text, set the selection to the stretch [beg, end). text # NIL 20 beg # end 0 <= beg 21 beg < end 22 end <= text.Length() 23 Except for performance, equivalent to: VAR sm: SetSelectionMsg; sm.beg := beg; sm.end := end; Models.Broadcast(text, sm) TextControllers.StdCtrlDesc TextControllers.ControllerDesc Containers.ControllerDesc Controllers.ControllerDesc Geneva Documents.ControllerDesc