Prompt

Table of Contents

## NAME

XfwfPrompt

## DESCRIPTION

The Prompt widget is used for short (no more than a few lines) text entry. It can be used in two modes: either with or without a template. If there is a template, input will be checked against it and only accepted if it matches. A template must be accompanied by a pattern, that gives the acceptable character classes for each position in the tem plate. A template can include literal characters, e.g., "Enter date: __-__-__ (DD-MM-YY)" with pattern "99-99-99" means that the user may enter only digits on the `_' posi tions.

If the pattern and template do not provide enough valida tion, or if there is no template, there is also the possi bility of using a callback after each character is entered. The callback can accept or reject the new text.

The rvStart resource is used as cursor position.

Public variables
______________________________________________________

|
  XfwfPrompt

| Name
  | Class | Type | Default

| XtNtext
  | XtCText | String | NULL | XtNtemplate | XtCTemplate | String | NULL | XtNpattern | XtCPattern | String | NULL | XtNvalidate | XtCValidate | Callback| NULL

| XtNleave
  | XtCLeave | Callback| NULL | XtNactivate | XtCActivate | Callback| NULL | XtNcomplete | XtCComplete | Boolean | True | XtNplaceholder| XtCPlaceholder| char | `_'

|
  | | | |_______________|________________|__________|_________

XtNtext
The text resource is what is modified by the user. If there is a template defined, the text will be the por tion of the template from the first `_' to the last.

XtNtemplate
The template consists of text with at least one `_' (or, to be precise, the value of placeholder). If there is no template, input of any length is accepted (but see the validate callback below).

Note that the label resource that is inherited from XfwfLabel is used to hold the combination of template and text. Setting label has no effect, and, indeed, will cause a warning message to be printed.

XtNpattern
The pattern is only used if there is a template. The length of the pattern must be the length from the first `_' in template to the last. Where the template has a `_', the pattern must have one of:

* `9' only digits are allowed.

* `a' digits, upper- and lowercase letters and spaces.

* `A' digits, uppercase letters and spaces.

* `F' only `safe' file name characters.

* `f' file name character plus `*' `[', `]' and `?'

* `X' any character.

* `z' digits, upper- and lowercase letters (no spaces)

* `Z' digits, uppercase letters (no spaces).

If the pattern is empty or too short, it will be extended with X's.

XtNvalidate
The validate callbacks are called when the text changes, because a letter is added or removed. The callback get a pointer to an XfwfPromptInfo structure as call_data. The structure includes a field reply, which should be set to XfwfReject, XfwfAccept or Xfwf Complete. The first causes the new text to be rejected with a `beep'; the second sets the complete resource to False, to indicate that the text is valid, but not yet complete; the third sets the complete resource to True.

XtNleave
The leave callback is called when the focus leaves the prompt widget. This is usually a sign that the user is ready entering the text. The final text is passed in the call_data argument.

XtNactivate
The activate callback is invoked from the activate action, which is normally bound to the Return key. The call_data argument of the callbacks routines is filled with a pointer to the event that triggered the action. This callback can be used in a dialog box, for example, to activate the default button.

XtNcomplete
The resource complete is always True, unless the most recent call to the validate callback returned XfwfAc cept.

XtNplaceholder
The character thatis used as the placeholder can be changed from the default `_' by setting the placeholder resource. Note that this character will also be used in the text string to indicate open places.

XtNcursor
The cursor is by default a vertical bar, called the `xterm' cursor.

XtNtraversalOn
Since prompts, in contrast to labels, should receive keyboard events, the traversalOn resource is by default

True.

XtNframeWidth
The default frame width is also given a different value.

XtNframeType
As is the frame type

XtNalignment
The default alignment of text is changed to centerleft.

_______________________________________________________________________ | XfwfLabel | Name | Class | Type | Default | XtNlabel | XtCLabel | String | NULL | XtNtablist | XtCTablist | String | NULL | XtNfont | XtCFont | FontStruct| XtDefaultFont | XtNforeground | XtCForeground | Pixel | XtDefaultForeground | XtNhlForeground| XtCHlForeground| Pixel | XtDefaultForeground | XtNalignment | XtCAlignment | Alignment | 0 | XtNtopMargin | XtCTopMargin | Dimension | 2 | XtNbottomMargin| XtCBottomMargin| Dimension | 2 | XtNleftMargin | XtCLeftMargin | Dimension | 2 | XtNrightMargin | XtCRightMargin | Dimension | 2 | XtNshrinkToFit | XtCShrinkToFit | Boolean | False | XtNrvStart | XtCRvStart | Int | 0 | XtNrvLength | XtCRvLength | Int | 0 | XtNhlStart | XtCHlStart | Int | 0 | XtNhlLength | XtCHlLength | Int | 0 | | | | |________________|_________________|____________|______________________

_____________________________________________________

|
  XfwfBoard

| Name
  | Class | Type | Default

| XtNabs_x
  | XtCAbs_x | Position | 0

| XtNrel_x
  | XtCRel_x | Float | "0.0"

| XtNabs_y
  | XtCAbs_y | Position | 0

| XtNrel_y
  | XtCRel_y | Float | "0.0" | XtNabs_width | XtCAbs_width | Position | 0 | XtNrel_width | XtCRel_width | Float | "1.0" | XtNabs_height| XtCAbs_height| Position | 0 | XtNrel_height| XtCRel_height| Float | "1.0"

| XtNhunit
  | XtCHunit | Float | "1.0"

| XtNvunit
  | XtCVunit | Float | "1.0" | XtNlocation | XtCLocation | String | NULL | | | | |______________|_______________|___________|_________

________________________________________________________________________________________

|
  XfwfFrame | Name | Class | Type | Default | XtNcursor | XtCCursor | Cursor | None | XtNframeType | XtCFrameType | FrameType | XfwfRaised | XtNframeWidth | XtCFrameWidth | Dimension | 0 | XtNouterOffset | XtCOuterOffset | Dimension | 0 | XtNinnerOffset | XtCInnerOffset | Dimension | 0 | XtNshadowScheme | XtCShadowScheme | ShadowScheme | XfwfAuto | XtNtopShadowColor | XtCTopShadowColor | Pixel | compute_topcolor | XtNbottomShadowColor | XtCBottomShadowColor | Pixel | compute_bottomcolor | XtNtopShadowStipple | XtCTopShadowStipple | Bitmap | NULL | XtNbottomShadowStipple| XtCBottomShadowStipple| Bitmap | NULL | | | | |_______________________|________________________|_______________|______________________

___________________________________________________________________________________

|
  XfwfCommon | Name | Class | Type | Default | XtNtraversalOn | XtCTraversalOn | Boolean | True | XtNhighlightThickness| XtCHighlightThickness| Dimension | 2 | XtNhighlightColor | XtCHighlightColor | Pixel | XtDefaultForeground | XtNhighlightPixmap | XtCHighlightPixmap | Pixmap | None | XtNnextTop | XtCNextTop | Callback | NULL | XtNuserData | XtCUserData | Pointer | NULL | | | | |______________________|_______________________|____________|______________________

_____________________________________________________________
  Composite Name Class Type Default XtNchildren XtCChildren WidgetList NULL insertPosition XtCInsertPosition XTOrderProc NULL numChildren XtCNumChildren Cardinal 0

_____________________________________________________________
  | | | | ___|_______________|___________________|______________|_________|_____ | | | Core | | |

| Na|me || Class | | Type | | De|fault

| Xt|Nx
  || XtCX | | Position | | 0 |

| Xt|Ny
  || XtCY | | Position | | 0 |

| Xt|Nwidth
  || XtCWidth | | Dimension | | 0 |

| Xt|Nheight
  || XtCHeight | | Dimension | | 0 |

| bo|rderWidth
  || XtCBorderWidth | | Dimension | | 0 |

| Xt|Ncolormap
  || XtCColormap | | Colormap | | NU|LL

| Xt|Ndepth
  || XtCDepth | | Int | | 0 | | de|stroyCallback || XtCDestroyCallback| | XTCallback|List | NU|LL | Xt|Nsensitive || XtCSensitive | | Boolean | | Tr|ue

| Xt|Ntm
  || XtCTm | | XTTMRec | | NU|LL | an|cestorSensitive|| XtCAncestorSensiti|ve| Boolean | | Fa|lse | ac|celerators || XtCAccelerators | | XTTranslat|ions | NU|LL

| bo|rderColor
  || XtCBorderColor | | Pixel | | 0 | | bo|rderPixmap || XtCBorderPixmap | | Pixmap | | NU|LL

| ba|ckground
  || XtCBackground | | Pixel | | 0 | | ba|ckgroundPixmap || XtCBackgroundPixma|p | Pixmap | | NU|LL | ma|ppedWhenManaged|| XtCMappedWhenManag|ed| Boolean | | Tr|ue

| Xt|Nscreen
  || XtCScreen | | Screen * | | NU|LL | | || | | | | | |___|______________||___________________|_|____________|____|____|____ | | | | | | | | Expo|rts | | | T|he XfwfPromptIn|f_o is what is passe|d to the valida|t_e call b|ack after the te|xt has changed. It c|ontains pointer|s to the o|ld and the new t|ext and a boolean fi|eld result that|is ini t|ially set to Xfw|f_Complete, but that |may be changed |by the c|allback routine|, when the new t|ext is unaccept|able, or a|cceptable but no|t complete. | | | | | | | | | | | | | | | | | | t|ype | | |

|XfwfPromptInfoRe|sult = enum {
  | |

|
  | | XfwfReject,|XfwfAccep|t, XfwfComplete | |} | | | | | | | | | | t|ype | | |

|XfwfPromptInfo =|struct {
  | |

|
  | String olds|tring; String newstring; Boolean result; }

Translations
The traversal code is added, except for <Key>Left: traverse Left() and <Key>Right: traverseRight(), which are used for other purposes.

<FocusIn>: focusIn()

<FocusOut>: leave() focusOut()

removed:
trans <Visible>: visibil ity()

removed:
trans <Unmap>: unmap()

<Key>Up: traverseUp()

<Key>Down: traverseDown()

<Key>Next: traverseNext()

~Shift<Key>Tab: traverseNext()

<Key>Prior: traversePrev()

Shift<Key>Tab: traversePrev()

<Key>KP_Enter: traverseNextTop()

<Key>Home: traverseHome()

Shift<Btn1Down>: extend_select()

<Btn1Down>: traverseCurrent() start_select()

<Btn1Motion>: extend_select()

<Btn1Up>: end_select()

<Btn2Down>,<Btn2Up>: paste()

<Key>BackSpace: cut() backspace()

Ctrl<Key>d: cut() delete()

<Key>Right: unselect() right()

<Key>Left: unselect() left()

Ctrl<Key>a: unselect() bol()

Ctrl<Key>e: unselect() eol()

<Key>Return: activate()

<Key>: cut() self_insert()

leave

The leave action calls the leave callbacks with the current text as call_data.

start_select

The start_select action sets the cursor position as close as possible to the mouse position, but only if the mouse actually points at some text. It also removes any previous selection, preparing for a new one.

extend_select

The extend_select action extends the selection to the current cursor position.

end_select

The end_select action copies the selected text to the clipboard.

paste

The paste action requests the contents of the clipboard in string-format and tries to insert it into the text.

unselect

The unselect action restores the text that was shown in reverse to normal.

cut The cut action deletes the highlighted portion from the text.

self_insert

The self_insert function inserts the key that was pressed into the text. If the key is not a printable key, it does nothing. If the key doesn't match the pat tern, it does nothing. If the callback validate returns XfwfReject, it does nothing.

bol
  The bol action moves the cursor to the leftmost place holder.

eol The eol action moves the cursor to the end of the label, if it isn't there already.

left The left action moves the cursor one position to the left, unless there are no more placeholders in that direction.

right

The right action moves the cursor one position to the right, unless it is already at the end of the template.

delete

The delete action removes the character to the right of the cursor, if there is any. The rest of the characters in the same run will shift to the left.

backspace

The backspace action removes the character to the left of the cursor, if there is any. The cursor moves left and all characters in the same run move left.

Table of Contents

- NAME
- DESCRIPTION