Next: Scrolling Control Up: Text Widgets Previous: Example Text Programs - text.cfile_lister.c

Editing Text

To replace all or parts of text in a Text Widget use XmTextReplace(). It has four arguments:

- The Text Widget.
Start Position (XmTextPosition type)
- a long int (defined in <Xm/Text.h>) measured in bytes. Specifies where to begin inserting text.
End Position (XmTextPosition type)
- The end insertion point. Note:
New text
- the String that will replace existing text.

To Insert text, similarly, use XmTextInsert(). This takes 3 arguments: the Text Widget, the XmTextPosition for the insertion and the text String.

To Search for string in the Text Widget, use XmTextFindString() with

Text Widget
- to be searched,
Start Position
- as before,
Search String,
Search Direction
- a XmTextPosition pointer that returns the position found.

XmTextFindString() returns a Boolean value which is False if no string was found.

To obtain text (in full) from a Text widget use XmTextGetString().

So to save text stored in the Text widget to a file simply:
Tue May 24 16:52:56 BST 1994