_________________________________________________________XawPlus

Text Functions

The following functions are provided as convenience routines for use with the Text widget. Although many of these actions can be performed by modifying resources, these interfaces are frequently more efficient.

These data structures are defined in the Text widget's public header file, <X11/Xaw/Text.h>.

typedef long XawTextPosition;

Character positions in the Text widget begin at 0 and end at n+1, where n is the number of characters in the Text source widget.

firstPos The first position, or index, to use within the ptr field. The value is commonly zero.
length The number of characters to be used from the ptr field. The number of characters used is commonly the number of characters in ptr, and must not be greater than the length of the string in ptr.
ptr Contains the string to be referenced by the Text widget.
format This field is not currently used, but should be specified as XawFmt8Bit.

Selecting Text

To select a piece of text, use XawTextSetSelection():

If redisplay is enabled, this function highlights the text and makes it the PRIMARY selection. This function does not have any effect on CUT_BUFFER0.

Unhighlighting Text

To unhighlight previously highlighted text in a widget, use XawTextUnsetSelection():

Getting Current Text Selection

To retrieve the text that has been selected by this text widget use XawTextGetSelectionPos():

If the returned values are equal, no text is currently selected.

Replacing Text

To modify the text in an editable Text widget use XawTextReplace():

This function may return the following values:

XawEditDone The text replacement was successful.
XawPositionError The edit mode is XawtextAppend and start is not the position of the last character of the source.
XawEditError Either the Source was read-only or the range to be deleted is larger than the length of the Source.

The XawTextReplace arguments start and end represent the text source character positions for the existing text that is to be replaced by the text in the text block. The characters from start up to but not including end are deleted, and the characters specified on the text block are inserted in their place. If start and end are equal, no text is deleted and the new text is inserted after start.

Searching for Text

To search for a string in the Text widget, use XawTextSearch():

The XawTextSearch() function will begin at the insertion point and search in the direction specified for a string that matches the one passed in text. If the string is found the location of the first character in the string is returned. If the string could not be found then the value XawTextSearchError is returned.

Redisplaying Text

To redisplay a range of characters, use XawTextInvalidate():

The XawTextInvalidate function causes the specified range of characters to be redisplayed immediately if redisplay is enabled or the next time that redisplay is enabled.

To enable redisplay, use XawTextEnableRedisplay():

The XawTextEnableRedisplay() function flushes any changes due to batched updates when XawTextDisableRedisplay() was called and allows future changes to be reflected immediately.

To disable redisplay while making several changes, use XawTextDisableRedisplay().

The XawTextDisableRedisplay() function causes all changes to be batched until either XawTextDisplay() or XawTextEnableRedisplay() is called. To display batched updates, use XawTextDisplay():

The XawTextDisplay() function forces any accumulated updates to be displayed.

Resources Convenience Routines

To obtain the character position of the left-most character on the first line displayed in the widget (the value of the displayPosition resource), use XawTextTopPosition().

To assign a new selection array to a text widget use XawTextSetSelectionArray():

Calling this function is equivalent to setting the value of the selectionTypes resource.

To move the insertion point to the specified source position, use XawTextSetInsertionPoint():

The text will be scrolled vertically if necessary to make the line containing the insertion point visible. Calling this function is equivalent to setting the insertPosition resource.

To obtain the current position of the insertion point, use XawTextGetInsertionPoint():

The result is equivalent to retrieving the value of the insertPosition resource.

To replace the text source in the specified widget, use XawTextSetSource():

A display update will be performed if redisplay is enabled.

To obtain the current text source for the specified widget, use XawTextGetSource():

This function returns the text source that this Text widget is currently using.

To enable and disable the insertion point, use XawTextDisplayCaret():

If visible is False the insertion point will be disabled. The marker is re-enabled either by setting visible to True, by calling XtSetValues(), or by executing the display-caret action routine.

Differences between Xaw and XawPlus

None.

XawPlus_________________________________________________________