Contents Up Previous Next

Text window

To display a lot of text, use this subwindow as the child of a frame. It is capable of loading and saving files of ASCII text, and under Open Look and Motif, the text can be edited directly.

To allow the user to edit text under Windows as well as the other platforms, either invoke an external editor or create a multi-line text item on a panel.

Under Windows, there is an extended range of functions. Some take character positions - a single integer which can identify a character position - and others take line and character numbers. If you want to use a function that takes one form, but you only have the other, you can convert between them using a function such as text-window-xy-to-position or text-window-position-to-line. Note that line and character numbers start from zero.

The following callbacks are valid for the dialog box class:

OnChar
(Not XView.) The function is called with the text window identifier, key code, and key event identifier. If the event is an ASCII keypress, the code will correspond to the ASCII code; otherwise, the programmer must refer to the constants defined in common.h, in the wxWindows library.

To invoke default processing, call text-window-on-char.

OnSize
The function is called with the text window identifier, width and height.

See also window-add-callback.

text-window-clear
text-window-copy
text-window-cut
text-window-create
text-window-discard-edits
text-window-get-contents
text-window-get-insertion-point
text-window-get-last-position
text-window-get-line-length
text-window-get-line-length
text-window-get-number-of-lines
text-window-load-file
text-window-modified
text-window-on-char
text-window-paste
text-window-position-to-char
text-window-position-to-line
text-window-remove
text-window-replace
text-window-show-position
text-window-save-file
text-window-set-editable
text-window-set-insertion-point
text-window-set-selection
text-window-write
text-window-xy-to-position


text-window-clear

long ( text-window-clear long window-id)

Clears the contents of a text subwindow. Returns 1 if successful, 0 otherwise.


text-window-copy

long ( text-window-copy long window-id)

Copies the selected text to the clipboard.


text-window-cut

long ( text-window-cut long window-id)

Copies the selected text to the clipboard, then removes the selection.


text-window-create

long ( text-window-create long parent-id optional long x optional long y
optional long width optional long height optional string style optional string name)

Creates a text subwindow. parent-id must be a valid frame ID.

style is a bit list of some of the following:

wxBORDER Use this style to draw a thin border in Windows 3 (non-native implementation only).
wxNATIVE_IMPL Use this style to allow editing under MS Windows, albeit with a 64K limitation.

name gives the text window a name that can be retrieved with window-get-name.


text-window-discard-edits

void ( text-window-discard-edits long window-id)

Discard any edits in the text window.


text-window-get-contents

string ( text-window-get-contents long window-id)

Returns the window contents (to a maximum of 1000 characters).


text-window-get-insertion-point

long ( text-window-get-insertion-point long window-id)

Returns the insertion point.


text-window-get-last-position

long ( text-window-get-last-position long window-id)

Returns the final position in the text window.


text-window-get-line-length

long ( text-window-get-line-length long window-id long line-no)

Returns the length of the text at line line-no.


text-window-get-line-length

long ( text-window-get-line-text long window-id long line-no)

Returns the text at line-no.


text-window-get-number-of-lines

long ( text-window-get-number-of-lines long window-id)

Returns the number of lines in the text window.


text-window-load-file

long ( text-window-load-file long window-id string filename)

Load the file onto the text subwindow, returning 1 for success, 0 for failure.


text-window-modified

long ( text-window-modified long window-id)

Returns 1 if the text has been modified, 0 otherwise.


text-window-on-char

long ( text-window-on-char long panel-id long event-id)

The default implementation of the OnChar callback. Call this to pass intercepted characters through to the text window. Note that under Windows, there seems to be an intermittent GPF bug when using this and then closing the window.


text-window-paste

long ( text-window-paste long window-id)

Pastes the text (if any) from the clipboard to the text window.


text-window-position-to-char

long ( text-window-position-to-char long window-id long pos)

Returns the character position (starting from zero) for the given index position.


text-window-position-to-line

long ( text-window-position-to-line long window-id long pos)

Returns the line number (starting from zero) for the given index position.


text-window-remove

long ( text-window-remove long window-id long start-pos long end-pos)

Removes the text between the given span selection.


text-window-replace

long ( text-window-replace long window-id long start-pos long end-pos string text)

Replaces the text between the given span selection with the given text.


text-window-show-position

long ( text-window-show-position long window-id long pos)

Shows the text at the given index position.


text-window-save-file

long ( text-window-save-file long window-id string filename)

Saves the text in the subwindow to the given file, returning 1 for success, 0 for failure.


text-window-set-editable

long ( text-window-set-editable long window-id long editable)

Sets the window editable (editable is 1) or read-only (editable is 0).


text-window-set-insertion-point

long ( text-window-set-insertion-point long window-id long pos)

Sets the insertion point to the given index position.


text-window-set-selection

long ( text-window-set-selection long window-id long start-pos long end-pos)

Sets the selection to the given span of text.


text-window-write

long ( text-window-write long window-id string text)

Writes the given string into the text window, at the current cursor point.


text-window-xy-to-position

long ( text-window-xy-to-position long window-id long char-position long line)

Converts the character and line number (each starting from zero) to a position.