The RichEdit class implements the RichEdit control, which is a text input and display control with advanced formatting capabilities, including support for multiple fonts, colors, and styles. Typically, you set the 'selection' properties such as selcolor and selfont to choose a text format, and then output some text using the seltext property. You can then change the format and output some more text. The RichEdit control can also be used for advanced word-processing type applications.
The main RichEdit properties are:
style: The style is a set of flags:
1 = centered 2 = right justified 4 = multiline 16 = vertical scroll bar 32 = inhibit auto horizontal scroll (ie word wrap if multiline) 64 = horizontal scroll bar 1024 = show selection even when control does not have focus (Windows only) 4096 = read only 8192 = allow Enter characters to be input (multi-line only) 65536 = disable unnecessary scroll bars rather than removing them (Windows and MacOS only) 131072 = allow Tab characters to be input, instead of tabbing to next control (Windows and MacOS only)
text: A character vector containing the text of the whole control. Writing to the text property replaces all the current text in the control. (Under Windows, you can also use the rtf property which is the same except that the text is in Rich Text Format and includes formatting information.)
selection: A two-element integer vector (start, length) giving the current selection start position (in index origin 0) and length. Writing to the selection property changes the selection on the screen, and determines where the next text will be output (i.e. the insertion point). A length of 0 means that no text is selected. A length of
seltext: A character vector containing the text of the selected part of the control. If there is no selection, this is an empty vector. Writing to the seltext property deletes any current selection and inserts the text you write, in the current selection font, style and color. (Under Windows, you can also use the selrtf property which is the same except that the text is in Rich Text Format and includes formatting information.)
selcolor: The current selection color, in the same format as the color property.
selfont: The current selection font and style, in the same format as the font property.
selstyle: The current selection style, as a 5-element vector: bold, italic, underline, strikeout, and protected. Valid values for each are
selalign: The current paragraph alignment, as a character vector keyword. One of 'left', 'right', 'center' (or 'centre')
selbullet: The current paragraph bullet style, as a character vector keyword or boolean scalar. One of 'none' (or 0), 'bullet' (or 1)
selindents: A three-element numeric vector giving the left, bullet and right indents in the current scale of the control
seltabs: A numeric vector giving the tab positions in the current scale of the control. (Windows only)
linecount: (Read-only) The number of lines of text in the control
range: (Read-only) A two-element integer vector. The first element is the line number of the first visible line, and the second is the count of lines visible in the control.
The main RichEdit methods are:
Clear: Delete the currently-selected text.
Cut: Cut the currently-selected text to the clipboard.
Copy: Copy the currently-selected text to the clipboard.
Paste: Replace the currently-selected text with the contents of the clipboard.
Undo: Undo the last change.
Print: Print the contents of the control (with formatting), to the current printer. Can optionally be called with a character-vector argument, which is the print-job name. (You can use the Setup and Job dialogs in the Printer object to allow the user to configure the printer.)
Save: Saves the contents of the rich-edit control to a file. You can specify the file name as the argument, or specify an empty vector in which case a dialog is displayed to allow the user to specify the file name. You can also optionally pass a second argument, to indicate whether the saved file should include formatting information. The valid values are 0 (no formatting, save as plain text), 1 (under Windows, save in Rich Text Format as a .rtf file), or 2 (under MacOS, save as Styled text).
Load: Loads the contents of a file into the rich-edit control. You can specify the file name as the argument, or specify an empty vector in which case a dialog is displayed to allow the user to choose a file name. Under Windows, the file can be in Rich Text Format (.rtf), in which case formatted text is loaded.
Linetochar: Takes a line number, and returns the position within the text of the first character of the line. Both are in index origin 0.
Chartoline: Takes a character position within the text, and returns the number of the line containing the character. Both are in index origin 0.
Linelength: Takes a line number (in index origin 0), and returns the length of the line in characters.
∇DEMO_RichEdit;TEXT;DEMO  ⍝ Sample function demonstrating use of the RichEdit object  DEMO←'⎕' ⎕NEW 'Window' ⋄ DEMO.title←'RichEdit Example'  DEMO.myRichEdit.New 'RichEdit' ⋄ DEMO.myRichEdit.align←¯1  DEMO.myRichEdit.scale←3 ⋄ DEMO.myRichEdit.border←0  DEMO.myRichEdit.selindents←20 20 20  ⍝  DEMO.myRichEdit.selection←0  DEMO.myRichEdit.selfont←'Times New Roman' 18 1  DEMO.myRichEdit.selcolor←220  DEMO.myRichEdit.seltext←('Quotation',⎕R)  ⍝  DEMO.myRichEdit.selfont←'Times New Roman' 12 0  DEMO.myRichEdit.selcolor←0  TEXT←⎕R,'Let me not to the marriage of true minds',⎕R  TEXT←TEXT,'Admit impediments. Love is not love',⎕R  TEXT←TEXT,'Which alters when it alteration finds,',⎕R  TEXT←TEXT,'Or bends with the remover to remove.',⎕R,⎕R  DEMO.myRichEdit.seltext←TEXT  ⍝  DEMO.myRichEdit.selfont←'Times New Roman' 10 2  DEMO.myRichEdit.selalign←'right'  DEMO.myRichEdit.seltext←'William Shakespeare'  ⍝  ⍝ Wait for the user to close the window  0 0⍴⎕WE DEMO ∇
align anchors aquaadjust autodraw border canundo caption children class color data doublebuffered dragsource droptarget enabled events extent font handle limit linecount maxsize methods minsize name opened order pointer properties rtf scale selalign selbullet selcolor selection self selfont selindents selrtf selstyle seltabs seltext size sourceformats style tabstop targetformats text tie units visible where winptr
onChange onClick onClose onDblClick onDestroy onDragDrop onDragEnd onDragEnter onDragLeave onDragOver onDragStart onFocus onHide onKeyDown onKeyPress onKeyUp onMouseDown onMouseMove onMouseUp onOpen onSend onShow onUnFocus
Copyright © 1996-2010 MicroAPL Ltd