Page: | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
---|
The Text widget provides a window that will allow an application to display and edit one or more lines of text. Options are provided to allow the user to add Scrollbars to its window, search for a specific string, and modify the text in the buffer.
The Text widget is made up of a number of pieces; it was modularized to ease customization. The AsciiText widget class (actually not limited to ASCII but so named for compatibility) is be general enough to most needs. If more flexibility, special features, or extra functionality is needed, they can be added by implementing a new TextSource or TextSink, or by subclassing the Text Widget (See Section 5.8 for customization details.)
The words insertion point are used in this chapter to refer to the text caret. This is the symbol that is displayed between two characters in the file. The insertion point marks the location where any new characters will be added to the file. To avoid confusion the pointer cursor will always be referred to as the pointer.
The text widget supports three edit modes, controlling the types of modifications a user is allowed to make:
Read-only mode does not allow the user or the programmer to modify the text in the widget. While the entire string may be reset in read-only mode with XtSetValues, it cannot be modified via with XawTextReplace. Append-only and editable modes allow the text at the insertion point to be modified. The only difference is that text may only be added to or removed from the end of a buffer in append-only mode.
The Text widget provides many of the common keyboard editing commands. These commands allow users to move around and edit the buffer. If an illegal operation is attempted, (such as deleting characters in a read-only texl widget), the X server will beep.
The default key bindings are patterned after those in the EMACS text editor:
Ctrl-a | Beginning Of Line | Meta-b | Backward Word |
Ctrl-b | Backward Character | Meta-f | Forward Word |
Ctrl-d | Delete Next Character | Meta-i | Insert File |
Ctrl-e | End Of Line | Meta-k | Kill To End Of Paragraph |
Ctrl-f | Forward Character | Meta-q | Form Paragraph |
Ctrl-g | Multiply Reset | Meta-v | Previous Page |
Ctrl-h | Delete Previous Character | Meta-y | Insert Current Selection |
Ctrl-j | Newline And Indent | Meta-z | Scroll One Line Down |
Ctrl-k | Kill To End Of Line | Meta-d | Delete Next Word |
Ctrl-l | Redraw Display | Meta-D | Kill Word |
Ctrl-m | Newline | Meta-h | Delete Previous Word |
Ctrl-n | Next Line | Meta-H | Backward Kill Word |
Ctrl-o | Newline And Backup | Meta-< | Beginning Of File |
Ctrl-p | Previous Line | Meta-> | End Of File |
Ctrl-r | Search/Replace Backward | Meta-] | Forward Paragraph |
Ctrl-s | Search/Replace Forward | Meta-[ | Backward Paragraph |
Ctrl-t | Transpose Characters | ||
Ctrl-u | Multiply by 4 | Meta-Delete | Delete Previous Word |
Ctrl-v | NextPage | Meta-ShiftDelete | Kill Previous Word |
Ctrl-w | Kill Selection | Meta-Backspace | Delete Previous Word |
Ctrl-y | Unkill | Meta-Shift Backspace | Kill Previous Word |
Ctrl-z | Scroll One Line Up | ||
Ctrl-\ | Reconnect to input method | ||
Kanji | Reconnect to input method |
In addition, the pointer may be used to cut and paste text:
Button 1 Down | Start Selection | ||
Button l Motion | Adjust Selection | ||
Button 1 Up | End Selection (cut) | ||
Button 2 Down | Insert Current Selection (paste) | ||
Button 3 Down | Extend Current Selection | ||
Button 3 Motion | Adjust Selection | ||
Button 3 Up | End Selection (cut) |
Since all of these key and pointer bindings are set through the translations and resource manager, the user and the application programmer can modify them by changing the Text widget's translations resource.
The Text widget provides a search popup that can be used to search for a string within the current Text widget. The popup can be activated by typing either Control-r or Control-s. If Control-s is used the search will be forward in the file from the current location of the insertion point; if Control-r is used the search will be backward. The activated popup is placed under the pointer. It has a number of buttons that allow both text searches and text replacements to be performed.
At the top of the search popup are two toggle buttons labeled backward and forward. One of these buttons will always be highlighted; this is the direction in which the search will be performed. The user can change the direction at any time by clicking on the appropriate button.
Directly under the buttons there are two text areas, one labeled Search for: and the other labeled Replace with:. If this is a read-only Text widget the Replace with: field will be insensitive and no replacements will be allowed. After each of these labels will be a text field. This field will allow the user to enter a string to search for and the string to replace it with. Only one of these text fields will have a window border around it; this is the active text field. Any key presses that occur when the focus in in the search popup will be directed to the active text field. There are also a few special key sequences:
Carriage Return: | Execute the action, and pop down the search widget. |
Tab: | Execute the action, then move to the next field. |
Shift Carriage Return: | Execute the action, then move to the next field. |
Control-q Tab: | Enter a Tab into a text field. |
Control-c: | Pop down the search popup. |
Using these special key sequences should allow simple searches without ever removing one's hands from the keyboard.
Near the bottom of the search popup is a row of buttons. These buttons allow the same actions to to be performed as the key sequences, but the buttons will leave the popup active. This can be quite useful if many searches are being performed, as the popup will be left on the display. Since the search popup is a transient window, it may be picked up with the window manager and pulled off to the side for use at a later time.
Search | Search for the specified string. |
Replace | Replace the currently highlighted string with the string in the Replace with text field, and move onto the next occurrence of the Search for text field. The functionality is commonly referred to as query-replace. |
Replace-All | Replace all occurrences of the search string with the replace string from the current insertion point position to the end (or beginning) of the file. There is no key sequence to perform this action. |
Cancel | Remove the search popup from the screen. |
Finally, when international resource is True, there may be a pre-edit buffer below the button row, for composing input. Its presence is determined by the X locale in use and the VendorShell's preeditType resource.
The widget hierarchy for the search popup is show below, all widgets are listed by class and instance name.
Text <name of Text widget> TransientShell search Form form Label labell Label label2 Toggle backwards Toggle forwards Label searchLabel Text searchText Label replaceLabel Text replaceText Command search Command replaceOne Command replaceAll Command cancel
To insert a file into a text widget, type the key sequence Meta-i, which will activate the file insert popup. This popup will appear under the pointer, and any text typed while the focus is in this popup will be redirected to the text field used for the filename. When the desired filename has been entered, click on Insert File, or type Carriage Return. The named file will then be inserted in the text widget beginning at the insertion point position. If an error occurs when opening the file, an error message will be printed, prompting the user to enter the filename again. The file insert may be aborted by clicking on CanceI. If Meta-i is typed at a text widget that is read-only, it will beep, as no file insertion is allowed.
The widget hierarchy for the file insert popup is show below; all widgets are listed by class and instance name.
Text <name of Text widget> TransientShell insertFile Form form Label label Text text Command insert Command cancel
The text widgets have a text selection mechanism that allows the user to copy pieces of the text into the PRIMARY selection, and paste into the text widget some text that another application (or text widget) has put in the PRIMARY selection.
One method of selecting text is to press pointer button 1 on the beginning of the text to be selected, drag the pointer until all of the desired text is highlighted, and then release the button to activate the selection. Another method is to click pointer button 1 at one end of the text to be selected, then click pointer button 3 at the other end.
To modify a currently active selection, press pointer button 3 near either the end of the selection that you want to adjust. This end of the selection may be moved while holding down pointer button 3. When the proper area has been highlighted release the pointer button to activate the selection.
The selected text may now be pasted into another application, and will remain active until some other client makes a selection. To paste text that some other application has put into the PRIMARY selection use pointer button 2. First place the insertion point where you would like the text to be inserted, then click and release pointer button 2.
Rapidly clicking pointer button 1 the following number of times will adjust the selection as described.
Two | Select the word under the pointer. A word boundary is defined by the Text widget to be a Space, Tab, or Carriage Return. |
Three | Select the line under the pointer. |
Four | Select the paragraph under the pointer. A paragraph boundary is defined by the text widget as two Carriage Returns in a row with only Spaces or Tabs between them. |
Five | Select the entire text buffer. |
To unset the text selection, click pointer button 1 without moving it.
Home |
---|
All editing functions are performed by translation manager actions that may be specified through the translations resource in the Text widget.
Insert Point Movement Delete forward-character delete-next-character backward-character delete-previous-character forward-word delete-next-word backward-word delete-previous-word forward-paragraph delete-selection backward-paragraph beginning-of-line end-of-line Selection next-line select-word previous-line select-all next-page select-start previous-page select-adjust beginning-of-file select-end end-of-file extend-start scroll-one-line-up extend-adjust scroll-one-line-down extend-end insert-selectionMiscellaneous New Line redraw-display newline-and-indent insert-file newline-and-backup insert-char newline insert-string display-caret focus-in Kill focus-in kill-word search backward-kill-word multiply kill-selection form-paragraph kill-to-end-of-line transpose-characters kill-paragraph no-op kill-to-end-of-paragraph Xaw WMProtocols reconnect-im
Most of the actions take no arguments, and unless otherwise noted you may assume this to be the case.
forward-character( ) | |
backward-character( ) | These actions move the insert point forward or backward one character in the buffer. If the insert point is at the end or beginning of a line this action will move the insert point to the next (or previous) line. |
forward-word( ) | |
backward-word( ) | These actions move the insert point to the next or previous word boundary. A word boundary is defined as a Space, Tab or Carriage Return. |
forward-paragraph( ) | |
backward-paragraph( ) | These actions move the insert point to the next or previous paragraph boundary. A paragraph boundary is defined as two Carriage Returns in a row with only Spaces or Tabs between them. |
beginning - of- line ( ) | |
end-of-line( ) | These actions move to the beginning or end of the current line. If the insert point is already at the end or beginning of the line then no action is taken. |
next-line( ) | |
previous-line( ) | These actions move the insert point up or down one line. If the insert point is currently N characters from the beginning of the line then it will be N characters from the beginning of the next or previous line. If N is past the end of the line, the insert point is placed at the end of the line. |
next-page( ) | |
previous-page( ) | These actions move the insert point up or down one page in the file. One page is defined as the current height of the text widget. The insert point is always placed at the first character of the top line by this action. |
beginning-of-file( ) | |
end-of-file( ) | These actions place the insert point at the beginning or end of the current text buffer. The text widget is then scrolled the minimum amount necessary to make the new insert point location visible. |
scroll-one-line-up( ) | |
scroll-one-line-down( ) | These actions scroll the current text field up or down by one line. They do not move the insert point. Other than the scrollbars this is the only way that the insert point may be moved off of the visible text area. The widget will be scrolled so that the insert point is back on the screen as soon as some other action is executed. |
delete-next-character( ) | |
delete-previous-character( ) | These actions remove the character immediately before or after the insert point. If a Carriage Return is removed then the next line is appended to the end of the current line. |
delete-next-word( ) | |
delete-previous-word( ) | These actions remove all characters between the insert point location and the next word boundary. A word boundary is defined as a Space, Tab or Carriage Return. |
delete-selection( ) | This action removes all characters in the current selection. The selection can be set with the selection actions. |
select-word( ) | This action selects the word in which the insert point is currently located. If the insert point is between words then it will select the previous word. |
select-all( ) | This action selects the entire text buffer. |
select-start( ) | This action sets the insert point to the current pointer location (if triggered by a button event) or text cursor location (if triggered by a key event). It will then begin a selection at this location. If many of these selection actions occur quickly in succession then the selection count mechanism will be invoked (see the section titled Text Selections for Application Programmers for details). |
select-adjust( ) | This action allows a selection started with the select-start action to be modified, as described above. |
select-end(name[,name,...]) | This action ends a text selection that began with the select-start Action, and asserts ownership of the selection or selections specified. A name can be a selection (e.g. PRIMARY) or a cut buffer (e.g CUT_BUFFER0). Note that case is important. If no names are specified, PRIMARY is asserted. |
extend-start( ) | This action finds the nearest end of the current selection, and moves it to the current pointer location (if triggered by a button event) or text cursor location (if triggered by a key event). |
extend-adjust( ) | This action allows a selection started with an extend-start action to be modified. |
extend-end(name[,name,...]) | This action ends a text selection that began with the extend-start action, and asserts ownership of the selection or selections specified. A name can be a selection (e.g. PRIMARY) or a cut buffer (e.g CUT BUFFER0). Note that case is important. If no names are given, PRIMARY is asserted. |
insert-selection(name[,name,...]) | This action retrieves the value of the first (left-most) named selection that exists or the cut buffer that is not empty and inserts it into the Text widget at the current insert point location. A name can be a selection (e.g. PRIMARY) or a cut buffer (e.g CUT BUFFER0). Note that case is important. |
newline-and-indentf( ) | This action inserts a newline into the text and adds spaces to that line to indent it to match the previous line. |
newline-and-backup( ) | This action inserts a newline into the text after the insert point. |
newline( ) | This action inserts a newline into the text before the insert point. |
kill-word( ) | |
backward-kill-word( ) | These actions act exactly like the delete-next-word and delete previous-word actions, but they stuff the word that was killed into the kill buffer (CUT_BUFFER_1). |
kill-selection( ) | This action deletes the current selection and stuffs the deleted text into the kill buffer (CUT_BUFFER_1). |
kill-to-end-of-line( ) | This action deletes the entire line to the right of the insert point position, and stuffs the deleted text into the kill buffer (CUT_BUFFER_1). |
kill-paragraph( ) | This action deletes the current paragraph, if between paragraphs it deletes the paragraph above the insert point, and stuffs the deleted text into the kill buffer (CUT_BUFFER_1). |
kill-to-end-of-paragraph( ) | This action deletes everything between the current insert point location and the next paragraph boundary, and stuffs the deleted text into the kill buffer (CUT_BUFFER_1). |
redraw-display( ) | This action recomputes the location of all the text lines on the display, scrolls the text to vertically center the line containing the insert point on the screen, clears the entire screen, and redisplays it. | ||||
insert-file([filename]) | This action activates the insert file popup. The filename option specifies the default filename to put in the filename buffer of the popup. If no filename is specified the buffer is empty at startup. | ||||
insert-char( ) | This action may only be attached to a key event. When the international resource is false, this action calls XLookupString to translate the event into a (rebindable) Latin-1 character (sequence) and inserts it into the text at the insert point. When the international resource is true, characters are passed to the input method via XwcLookupString, and any committed string returned is inserted into the text at the insert point. | ||||
insert-string(string[,string,...]) | This action inserts each string into the text at the insert point location. Any string beginning with the characters "0x" followed by an even number of hexadecimal digits is interpreted as a hexadecimal constant and the corresponding string is inserted instead. This hexadecimal string may represent up to 50 8-bit characters. When the international resource is true, a hexadecimal string is interpreted as being in a multi-byte encoding, and a hexadecimal or regular string will result in an error message if it is not legal in the current locale. | ||||
display-caret(state,when) | This action allows the insert point to be turned on and off. The state argument specifies the desired state of the insert point. This value may be any of the string values accepted for Boolean resources (e.g. on, True, off, False, etc.). If no arguments are specified, the default value is True. The when argument specifies, for EnterNotify or LeaveNotify events whether or not the focus field in the event is to be examined. If the second argument is not specified, or specified as something other than always then if the action is bound to an EnterNotify or LeaveNotify event, the action will be taken only if the focus field is True. An augmented binding that might be useful is:
| ||||
focus-in( ) | |||||
focus-outf( ) | These actions do not currently do anything. | ||||
search(direction,[string]) | This action activates the search popup. The direction must be specified as either forward or backward. The string is optional and is used as an initial value for the Search for: string. For further explanation of the search widget see the section on Text Searches. | ||||
multiply(value) | The multiply action allows the user to multiply the effects of many of the text actions. Thus the following action sequence multiply(10) delete-next-word( ) will delete 10 words. It does not matter whether these actions take place in one event or many events. Using the default translations the key sequence Control-u, Control-d will delete 4 characters. Multiply actions can be chained, thus multiply(5) multiply(5) is the same as multiply(25). If the string reset is passed to the multiply action the effects of all previous multiplies are removed and a beep is sent to the display. | ||||
form-paragraph( ) | This action removes all the Carriage Returns from the current paragraph and reinserts them so that each line is as long as possible, while still fitting on the current screen. Lines are broken at word boundaries if at all possible. This action currently works only on Text widgets that use ASCII text. | ||||
transpose-characters( ) | This action will swap the position of the character to the left of the insert point with the character to the right of the insert point. The insert point will then be advanced one character. | ||||
no-op([action]) | The no-op action makes no change to the text widget, and is mainly used to override translations. This action takes one optional argument. If this argument is RingBell then a beep is sent to the display. | ||||
XawWMProtocols([wm_protocol_name]) | This action is written specifically for the file insertion and the search and replace dialog boxes. This action is attached to those shells by the Text widget, in order to handle ClientMessage events with the WM_PROTOCOLS atom in the detail field. This action supports WM_DELETE_WINDOW on the Text widget popups, and may support other window manager protocols if necessary in the future. The popup will be dismissed if the window manager sends a WM_DELETE_WINDOW request and there are no parameters in the action call, which is the default. The popup will also be dismissed if the parameters include the string "wm_delete_window," and the event is a ClientMessage event requesting dismissal or is not a ClientMessage event. This action is not sensitive to the case of the strings passed as parameters. | ||||
reconnect-im( ) | When the international resource is true, input is usually passed to an input method, a separate process, for composing. Sometimes the connection to this process gets severed; this action will attempt to reconnect it. Causes for severage include network trouble, and the user explicitly killing one input method and starting a new one. This action may also establish first connection when the application is started before the input method. |
The default behavior of the text selection array is described in the section called Text Selections for Users. To modify the selections a programmer must construct a XawTextSelectType array (called the selection array), containing the selections desired, and pass this as the new value for the selectionTypes resource. The selection array may also be modified using the XawTextSetSelectionArray function. All selection arrays must end with the value XawselectNull. The selectionTypes resource has no converter registered and cannot be modified through the resource manager.
The array contains a list of entries that will be called when the user attempts to select text in rapid succession with the select-start action (usually by clicking a pointer button). The first entry in the selection array will be used when the select-start action is initially called. The next entry will be used when select-start is called again, and so on. If a timeout value (1/10 of a second) is exceeded, the next select-start action will begin at the top of the selection array. When XawselectNull is reached the array is recycled beginning with the first element.
The default selectType array is:
{XawselectPosition, XawselectWord, XawselectLine, XawselectParagraph, XawselectAII, XawselectNull }
The selection array is not copied by the text widgets. The application must allocate space for the array and cannot deallocate or change it until the text widget is destroyed or until a new selection array is set.
Home |
---|
The following translations are defaults built into every Text widget. They can be overridden, or replaced by specifying a new value for the Text widget's translations resource.
Ctrl<Key>A: | beginning-of-line( )\n\ |
Ctrl<Key>B: | backward-character( )\n\ |
Ctrl<Key>D: | delete-next-character( )\n\ |
Ctrl<Key>E: | end-of-line( )\n\ |
Ctrl<Key>F: | forward-character( )\n\ |
Ctrl<Key>G: | multiply(Reset)\n\ |
Ctrl<Key>H: | delete-previous-character( )\n\ |
Ctrl<Key>J: | newline-and-indent( )\n\ |
Ctrl<Key>K: | kill-to-end-of-line( )\n\ |
Ctrl<Key>L: | redraw-display( )\n\ |
Ctrl<Key>M: | newline( )\n\ |
Ctrl<Key>N: | next-line( )\n\ |
Ctrl<Key>O: | newline-and-backup( )\n\ |
Ctrl<Key>P: | previous-line( )\n\ |
Ctrl<Key>R: | search(backward)\n\ |
Ctrl<Key>S: | search(forward)\n\ |
Ctrl<Key>T: | transpose-characters( )\n\ |
Ctrl<Key>U: | multiply(4)\n\ |
Ctrl<Key>V: | next-page( )\n\ |
Ctrl<Key>W: | kill-selection( )\n\ |
Ctrl<Key>Y: | insert-selection(CUT_BUFFERI)\n\ |
Ctrl<Key>Z: | scroll-one-line-up( )\n\ |
Ctrl<Key>\: | reconnect-im( )\n\ |
Meta<Key>B: | backward-word( )\n\ |
Meta<Key>F: | forward-word( )\n\ |
Meta<Key>I: | insert-file( )\n\ |
Meta<Key>K: | kill-to-end-of-paragraph( )\n\ |
MetacKey>Q: | form-paragraph( )\n\ |
Meta<Key>V: | previous-page( )\n\ |
Meta<Key>Y: | insert-selecion(PRIMARY,CUT_BUFFER0)\n\ |
Meta<Key>Z: | scroll-one-line-down( )\n\ |
:Meta<Key>d: | delete-next-word( )\n\ |
:Meta<Key>D: | kill-word( )\n\ |
:MetacKey>h: | delete-previous-word( )\n\ |
:Meta<Key>H: | backward-kill-word( )\n\ |
:Meta<Key>\<: | beginning-of-file( )\n\ |
:Meta<Key>\>: | end-of-file( )\n\ |
:Meta<Key>]: | forward-paragraph( )\n\ |
:Meta<Key>[: | backward-paragraph( )\n\ |
~Shift Meta<Key>Delete: | delete-previous-word( )\n\ |
Shift Meta<Key>Delete: | backward-kill-word( )\n\ |
~Shift Meta<Key>Backspace: | delete-previous-word( )\n\ |
Shift Meta<Key>Backspace: | backward-kill-word( )\n\ |
<Key>Right: | forward-character( )\n\ |
<Key>Left: | backward-character( )\n\ |
<Key>Down: | next-line( )\n\ |
<Key>Up: | previous-line( )\n\ |
<Key>Delete: | delete-previous-character( )\n\ |
<Key>BackSpace: | delete-previous-character( )\n\ |
<Key>Linefeed: | newline-and-indent( )\n\ |
<Key>Retum: | newline( )\n\ |
<Key>: | insert-char( )\n\ |
<Key>Kanji: | reconnect-im( )\n\ |
<FocusIn>: | focus-in( )\n\ |
<FocusOut>: | focus-out( )\n\ |
<BtnlDown>: | select-start( )\n\ |
<BtnlMotion>: | extend-adjust( )\n\ |
<BtnlUp>: | extend-end(PRIMARY, CUT_BUPFER0)\n\ |
<Btn2Down>: | insert-selection(PRIMARY, CUT_BUFFER0)\n\ |
<Btn3Down>: | extend-start( )\n\ |
<Btn3Motion>: | extend-adjust( )\n\ |
<Btn3Up>: | extend-end(PRIMARY, CUT_BUFFER0)\ |
Home |
---|
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, 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 flag indicates whether the data pointed to by ptr is char or wchar_t. When the associated widget has international set to false this field must be XawFmt8Bit. When the associated widget has international set to true this field must be either XawFmt8Bit or XawFmtWide. |
Note: Previous versions of Xaw used FMT8BIT, which has been retained for backwards compatibility. FMT8BIT is deprecated and will eventually be removed from the implementation.
To select a piece of text, use XawTextSetSelection:
w | Specifies the Text widget. |
left | Specifies the character position at which the selection begins. |
right | Specifies the character position at which the selection ends. |
See section 5.4 for a description of XawTextPosition. 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.
To unhighlight previously highlighted text in a widget, use XawTextUnsetSelection:
w | Specifies the Text widget. |
To retrieve the text that has been selected by this text widget use XawTextGetSelectionPos:
w | Specifies the Text widget. |
begin_return | Returns the beginning of the text selection. |
end_return | Returns the end of the text selection. |
See section 5.4 for a description of XawTextPosition. If the returned values are equal, no text is currently selected.
To modify the text in an editable Text widget use XawTextReplace:
w | Specifies the Text widget. |
start | Specifies the starting character position of the text replacement. |
end | Specifies the ending character position of the text replacement. |
text | Specifies the text to be inserted into the file. This function will not be able to replace text in read-only text widgets. It will also only be able to append text to an append-only text widget. |
See section 5.4 for a description of XawTextPosition and XawTextBlock. 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.
To search for a string in the Text widget, use XawTextSearch:
w | Specifies the Text widget. |
dir | Specifies the direction to search in. Legal values are XawsdLeft and XawsdRight. |
text | Specifies a text block structure that contains the text to search for. |
See section 5.4 for a description of XawTextPosition and XawTextBlock. 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.
To redisplay a range of characters, use XawTextInvalidate:
w | Specifies the Text widget. |
from | Specifies the start of the text to redisplay. |
to | Specifies the end of the text to redisplay. |
See section 5.4 for a description of XawTextPosition. The XawTextlnvalidate 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:
w | Specifies the Text widget. |
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.
w | Specifies the Text widget. |
The XawTextDisableRedisplay function causes all changes to be batched until either XawTextDisplay or XawTextEnableRedisplay is called.
To display batched updates, use XawTextDisplay:
w | Specifies the Text widget. |
The XawTextDisplay function forces any accumulated updates to be displayed.
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.
w | Specifies the Text widget. |
To assign a new selection array to a text widget use XawTextSetSelectionArray:
w | Specifies the Text widget. |
sarray | Specifies a selection array as defined in the section called Text Selections for Application Programmers. |
Calling this function is equivalent to setting the value of the selectionTypcs resource.
To move the insertion point to the specified source position, use XawTextSetInscrtionPoint:
w | Specifies the Text widget. |
position | Specifies the new position for the insertion point. |
See section 5.4 for a description of XawTextPosition. 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:
w | Specifies the Text widget. |
See section 5.4 for a description of XawTextPosition. The result is equivalent to retrieving the value of the insertPosition resource.
To replace the text source in the specified widget, use XawTextSetSource:
w | Specifies the Text widget. |
source | Specifies the text source object. |
position | Specifies character position that will become the upper left hand corner of the displayed text. This is usually set to zero. |
See section 5.4 for a description of XawTextPosition. A display update will be performed if redisplay is enabled.
To obtain the current text source for the specified widget, use XawTextGetSource:
w | Specifies the Text widget. |
This function returns the text source that this Text widget is currently using.
To enable and disable the insertion point, use XawTextDisplayCaret:
w | Specifies the Text widget. |
visible | Specifies whether or not the caret should be displayed. |
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.
Home |
---|
Application Header file | <X11/Xaw/AsciiText.h> |
ClassHeader file | <X11/Xaw/AsciiTextP.h> |
Class | asciiTextWidgetClass |
Class Name | Text |
Superclass | Text |
Sink Name | textSink |
Source Name | textSource |
For the ease of internationalization, the AsciiText widget class name has not been changed, although it is actually able support non-ASCII locales. The AsciiText widget is really a collection of smaller parts. It includes the Text widget itself, a "Source" (which supports memory management), and a "Sink" (which handles the display). There are currently two supported sources, the AsciiSrc and MultiSrc, and two supported sinks, the AsciiSink and MultiSink. Some of the resources listed below are not actually resources of the AsciiText, but belong to the associated source or sink. This is noted in the explanation of each resource where it applies. When specifying these resources in a resource file it is necessary to use *AscinText* resource_name instead of *AsciiText.resource_name, since they actually belong to the children of the AsciiText widget, and not the AsciiText widget itself. However, these resources may be set directly on the AsciiText widget at widget creation time, or via XtSetValues.
When creating an AsciiText widget instance, the following resources are retrieved from the argument list or from the resource database:
Name | Class | Type | Notes | Default Value |
---|---|---|---|---|
accelerators | Accelerators | AcceleratorTable | NULL | |
ancestorSensitive | AncestorSensitive | Boolean | D | True |
autoFill | AutoFill | Boolean | False | |
background | Background | Pixel | XtDefaultBackground | |
backgroundPixmap | Pixmap | Pixmap | XtUnspecifiedPixmap | |
borderColor | BorderColor | Pixel | XtDefaultForeground | |
borderPixrnap | Pixmap | Pixmap | XtUnspecifiedPixmap | |
borderWidth | BorderWidth | Dimension | 1 | |
bottomMargin | Margin | Position | 2 | |
callback | Callback | XtCallbackList | NULL | |
colormap | Colorrnap | Colommap | Parent's Colormap | |
cursor | Cursor | Cursor | XC_xterm | |
cursorName | Cursor | String | NULL | |
dataCompression | DataCompression | Boolean | True | |
depth | Depth | int | C | Parent's Depth |
destroyCallback | Callback | XtCallbackList | NULL | |
displayCaret | Output | Boolean | True | |
displayNonprinting | Output | Boolean | True | |
displayPosition | TextPosition | XawTextPosition | 0 | |
echo | Output | Boolean | True | |
editType | EditType | XawTextEditType | XawtextRead | |
font | Font | XFontStruct* | XtDefaultFont | |
fontSet | FontSet | XFontSet | XtDefaultFontSet | |
foreground | Foroground | Pixel | XtDefaultForeground | |
height | Height | Dimension | A | Font height + margins |
insensitiveBorder | Insensitivc | Pixmap | GreyPixmap | |
insertPosilion | TextPosifion | int | 0 | |
international | International | Boolean | C | False |
leftMargin | Margin | Dimension | 2 | |
length | Length | int | A | length of string |
mappedWhenManaged | MappodWhenManaged | Boolean | True | |
pieceSize | PieccSizc | XawTextPosition | BUFSIZ | |
pointerColor | Foreground | Pixcl | XtDefaultForeground | |
pointerColorBackground | Background | Pixel | XtDefaultBackground | |
resize | Resize | XawTextResizeMode | XawtextResizeNever | |
rightMargin | Margin | Position | 2 | |
screen | Screen | Screen | R | Parent's Screen |
saollHorizontal | Scroll | XawTextScrollMode | XawtextScrollNever | |
scrollVenical | Scroll | XawTextSaollMode | XawtextScrollNever | |
selectTypes | SelectTypes | XawTextSelectType* | See above | |
sensilive | Sensitive | Boolean | True | |
string | String | String | NULL | |
textSink | TextSink | Widget | An AsciiSink | |
textSource | TextSource | Widgel | An AsciiSrc | |
topMargin | Margin | Posilion | 2 | |
translalions | Translations | TranslationTable | See above | |
type | Type | XawAsciiType | XawAsciiStnng | |
useStringlnPlace | UseStringlnPlace | Boolean | False | |
width | Widffi | Dimension | 100 | |
wrap | Wrap | WrapMode | XawtextWrapNever | |
x | Position | Posilion | 0 | |
y | Posilion | Posilion | 0 |
accelerators | A list of event to action bindings to be executed by this widget, even though the event occurred in another widget. (See the X Toolkit Intrinsics---C Language Interface for details. |
ancestorSensitive | The sensitivity state of the ancestors of this widget. A widget is insensitive if either it or any of its ancestors is insensitive. This resource should not be changed with XtSetValues, although it may be queried. |
autoFill | If this resource is True the text widget will automatically break a line when the user attempts to type into the right margin. The attribute has no effect on files or text inserted into the text widget. It only checks to see if the action should be taken when a user enters a new character via the insert-character action. |
background | A pixel value which indexes the widget's colormap to derive the back ground color of the widget's window. |
backgroundPixmap | The background pixmap of this widget's window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the background color. |
borderColor | A pixel value which indexes the widget's colormap to derive the border color of the widget's window. |
borderPixmap | The border pixmap of this widget's window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the border color. |
borderWidth | The width of this widget's window border. |
bottom Margin | |
leftMargin | |
rightMargin | |
topMargin | The amount of space, in pixels, between the edge of the window and the corresponding edge of the text within the window. If there is a scrollbar active on this edge, then this is the space between the text and the scrollbar. |
callback | The callbacks registered on this resource will be called every time the text buffer changes, after the text has been updated. This is a resource of the associated source. |
colormap | The colormap that this widget will use. |
cursor | The image that will be displayed as the pointer cursor whenever it is in this widget. The use of this resource is deprecated in favor of cursorName. |
cursorName | The name of the symbol to use to represent the pointer cursor. This resource will override the cursor resource if both are specified. (See 2.5.1) |
dataCompression | The AsciiSrc uses an algorithm that may cause the text buffer to grow to about twice the size of the actual text over time, as the text is edited. On systems where CPU cycles are cheaper than memory, it is helpful to spend some extra time to compress this buffer back to its minimum size. If this resource is True, the AsciiSrc will compress its data to the minimum size required every time the text string is saved, or the value of the string is queried. This is a resource of the associated source. |
depth | The depth of this widget's window. |
destroyCallback | All functions on this list are called when this widget is destroyed. |
displayCaret | Whether or not to display the text insert point. |
displayNonprinting | If this resource is True, the Text widget will display all non-printable characters as the string ^@. If False, the Text widget will just leave a blank space where a non-printable character exists in the text buffer. |
displayPosition | The position in the text buffer of the character that is currently displayed in the upper left hand corner of the text display. |
editType | This is the type of editing that will be allowed in this text widget. Legal values are XawtextRead, XawtextEdit, and XawtextAppend, A converter is registered for this resource that will convert the following strings: read, edit, and append. This is a resource of the associated source. |
echo | Whether or not to echo characters to the screen. The buffer can still be edited, but nothing is displayed. This mode can be useful for entering passwords and other sensitive information. This is a resource of the associated sink. |
font | The text font to use when displaying the string, when the international resource is false. This is a resource of the associated sink. |
font | The text font set to use when displaying the string when the international resource is true. This is a resource of the associated sink. |
foreground | A pixel value which indexes the Text widget's colormap to derive the foreground color used by the text sink. This is a resource of the associated sink. |
height | |
width | The height and width of this widget in pixels. |
insensitiveBorder | This pixmap will be tiled into the widget's border if the widget becomes insensitive. |
insertPosition | This is the location of the insert point. It is expressed in characters from the beginning of the file. The cursor will always be forced to be on the screen. This resource may therefore be used to scroll the text display to a certain character position. |
Iength | If the useStringlnPlace resource is False this attribute has no effect. If that resource is True, however, then the length resource specifies the length of the buffer passed to the text widget in the string resource. This is a resource of the associated source. |
mappedWhenManaged | If this resource is True, then the widget's window will automatically be mapped by the Toolkit when it is realized and managed. |
pointerColor | A pixel value which indexes the widget's colormap to derive the foreground color of the pointer symbol specified by the cursorName resource. |
pointerColorBackground | A pixel value which indexes the widget's colormap to derive the background color of the pointer symbol specified by the cursorName resource. |
pieceSize | This is the size of the internal chunks into which the text buffer is broken down for memory management. The larger this value the less segmented your memory will be, but the slower your editing will be. The text widgets will always allocate a chunk of memory this size to stuff the string into, so when using small strings, having this buffer large can waste memory. This resource has no effect if useStringInPlace is True. This is a resource of the associated source. |
resize | Controls whether or not the Text widget attempts to resize itself when it is no longer able to display the full text buffer in the associated window. Any attempt by the Text widget to resize itself is always subject to the constraints imposed by its parent. The values XawtextResizeNever, XawtextResizeWidth, XawtextResizeHeight, and XawtextResizeBoth are all acceptable for this resource. A converter is registered for this resource that will convert the following strings: never, height, width, and both. |
screen | The screen on which this widget is displayed. This is not a settable resource. |
scrollHorizontal | |
scrollVertical | These resources control the placement of scrollbars on the left and bottom edge of the text widget. These resources accept the values XawtextScrollAlways, XawtextScrollWhenNeeded, and XawtextScrollNever. A converter is registered for this resource that will convert the following strings: always, never, and whenNeeded. If XawtextScrollWhenNeeded is specified, the appropriate scrollbar will only appear when there is text in the buffer that is not able to fit within the bounds of the current window. The scrollbar will disappear when the text once again fits within the window. |
selectTypes | Specifies the selection type array that is used when multi-click is activated (see Text Selections for Application Programmers for details). This resource is used in place, and must not be freed until the widget is destroyed. There is no type converter registered for this resource, so it may not be set from the resource manager. |
sensitive | Whether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False. |
string | If type is XawAsciiString then this string contains the buffer to be displayed in the widget. If type is XawAsciiFile then the string contains the name of the file to be displayed. This string is normally copied by the text widget into internal memory, but may be used in place by setting the useStringInPlace resource. As of X11R4 this is a settable resource. This is a resource of the associated source. When the string resource is queried, using XtGetValues, and useStringInPlace is false, the value returned is valid until the next time the string resource is queried, or until the application writer calls XawAsciiSrcFreeString. If useStringInPlace is true, a pointer to the actual string is returned. See also section 5.6. |
textSink | |
textSource | These are the TextSink or TextSource objects used by this widget. When international is set to true the AsciiText widget initializes these resources to point to an MultiSink and MultiSrc respectively. the AsciiText widget initializes these resources to point to an AsciiSink and AsciiSrc respectively. |
translations | The event bindings associated with this widget. |
type | This resource may be either XawAsciiString or XawAsciiFile. The value of this resource determines whether the string resource contains the name of a file to be opened or a buffer to be displayed by the text widget. A converter has been registered for this resource and accepts the values string and file. This is a resource of the associated source. |
useStringlnPlace | Setting this resource to True will disable the memory management provided by the Text widget, updating the string resource in place. Using the string in place can be much more efficient for text widgets that display static data, or where the programmer wishes to impose strict constraints on the contents of the string. When using the string in place be sure that: the length of the string is specified by setting the length resource, the type of the Text widget is XawAsciiString, and that the string exists for the lifetime of the text widget, or until it has been reset. Note: Since the MultiSrc and AsciiSrc have different data formats, use of this resource forces application code to be cognisant as to which of the two is being used. Application programming is simplified when use of this resource is avoided. This is a resource of the associated source. |
wrap | When the text in any one line is wider than the window there are several possible actions. This resource allows the user to decide what will happen. The accepted values for this resource are XawtextWrapNever, XawtextWrapLine, and XawtextWrapWord. With XawtextWrapLine all text that is beyond the right edge of the window will be displayed on the next line. With XawtextWrapWord the same action occurs but the text is broken at a word boundary if possible. If no wrap ping is enabled then the text will extend off the edge of the window, and a small rectangle will be painted in the right margin to alert the user that this line is too long. A converter is registered for this resource that will convert the following strings: never, word, and line. |
x | |
y | The location of the upper left outside corner of this widget in its parent. |
Home |
---|
Contents | Previous Chapter | Part 2/Chapter 5 |