form_driver(3X)
π form_driver(3X) β Library calls π
okay so bestie, welcome to the form_driver(3X) page. This is a Library calls manual, and it's literally the command-processing loop of the form system. No cap, it's giving "let me handle your input events so you don't have to." π
π NAME π
form_driver, form_driver_w β the command-processing loop of the form system. That's the whole vibe.
β¨ SYNOPSIS β¨
#include <form.h>
int form_driver(FORM *form, int c);
int form_driver_w(FORM *form, int c, wchar_t wc);
πΈ DESCRIPTION πΈ
π¦ form_driver π¦
Once a form has been posted β like, displayed β you should funnel input events to it through form_driver. This routine has three major input cases:
- The input is a form navigation request. Navigation request codes are constants defined in
form.h, which are distinct from the key- and character codes returned bywgetch(3X). - The input is a printable character. Printable characters β which must be positive and less than 256 β are checked according to the program's locale settings.
- The input is the
KEY_MOUSEspecial key associated with a mouse event. π
π form_driver_w π
This extension simplifies using the forms library with wide characters. The input is either a key code (a request) or a wide character returned by get_wch(3X). The type must be passed as well, so the library can determine whether the parameter is a wide character or a request. iykyk β¨
π§Ύ Form Driver Requests π§Ύ
The form driver requests are as follows β all of them, bestie, no skipping:
REQ_BEG_FIELDβ move to the beginning of the field.REQ_BEG_LINEβ move to the beginning of the line.REQ_CLR_EOFβ clear from the cursor to the end of the field.REQ_CLR_EOLβ clear from the cursor to the end of the line.REQ_CLR_FIELDβ clear the entire field.REQ_DEL_CHARβ delete the character at the cursor.REQ_DEL_LINEβ delete the line at the cursor.REQ_DEL_PREVβ delete the character before the cursor.REQ_DEL_WORDβ delete the blank-delimited word at the cursor.REQ_DOWN_CHARβ move down in the field.REQ_DOWN_FIELDβ move down to a field.REQ_END_FIELDβ move to the end of the field.REQ_END_LINEβ move to the end of the line.REQ_FIRST_FIELDβ move to the first field.REQ_FIRST_PAGEβ move to the first page.REQ_INS_CHARβ insert a blank at the cursor.REQ_INS_LINEβ insert a blank line at the cursor.REQ_INS_MODEβ enter insert mode.REQ_LAST_FIELDβ move to the last field.REQ_LAST_PAGEβ move to the last field. (yes, the page says field here; don't come for me π)REQ_LEFT_CHARβ move left in the field.REQ_LEFT_FIELDβ move left to a field.REQ_NEW_LINEβ insert or overlay a new line.REQ_NEXT_CHARβ move to the next char.REQ_NEXT_CHOICEβ display the next field choice.REQ_NEXT_FIELDβ move to the next field.REQ_NEXT_LINEβ move to the next line.REQ_NEXT_PAGEβ move to the next page.REQ_NEXT_PAGEβ move to the next page. (listed twice in the original, so it's here twice too; consistency slay π )REQ_NEXT_WORDβ move to the next word.REQ_OVL_MODEβ enter overlay mode.REQ_PREV_CHARβ move to the previous char.REQ_PREV_CHOICEβ display the previous field choice.REQ_PREV_FIELDβ move to the previous field.REQ_PREV_LINEβ move to the previous line.REQ_PREV_PAGEβ move to the previous page.REQ_PREV_WORDβ move to the previous word.REQ_RIGHT_CHARβ move right in the field.REQ_RIGHT_FIELDβ move right to a field.REQ_SCR_BCHARβ scroll the field backward 1 character.REQ_SCR_BHPAGEβ scroll the field backward Β½ page.REQ_SCR_BLINEβ scroll the field backward 1 line.REQ_SCR_BPAGEβ scroll the field backward 1 page.REQ_SCR_FCHARβ scroll the field forward 1 character.REQ_SCR_FHPAGEβ scroll the field forward Β½ page.REQ_SCR_FLINEβ scroll the field forward 1 line.REQ_SCR_FPAGEβ scroll the field forward 1 page.REQ_SCR_HBHALFβ horizontal scroll the field backward Β½ line.REQ_SCR_HBLINEβ horizontal scroll the field backward 1 line.REQ_SCR_HFHALFβ horizontal scroll the field forward Β½ line.REQ_SCR_HFLINEβ horizontal scroll the field forward 1 line.REQ_SFIRST_FIELDβ move to the sorted first field.REQ_SLAST_FIELDβ move to the sorted last field.REQ_SNEXT_FIELDβ move to the sorted next field.REQ_SPREV_FIELDβ move to the sorted previous field.REQ_UP_CHARβ move up in the field.REQ_UP_FIELDβ move up to a field.REQ_VALIDATIONβ validate the field.
If the second argument is a printable character, the driver places it in the current position in the current field. If it is one of the forms requests listed above, that request is executed. Periodt. β¨
π§ Field Validation π§
The form library makes updates to the window associated with form fields rather than directly to the field buffers.
The form driver provides low-level control over updates to the form fields. The form driver also provides for validating modified fields to ensure that the contents meet whatever constraints an application may attach using set_field_type.
You can validate a field without making any changes to it using REQ_VALIDATION. The form driver also validates a field in these cases:
- a call to
set_current_fieldattempts to move to a different field. - a call to
set_current_pageattempts to move to a different page of the form. - a request attempts to move to a different field.
- a request attempts to move to a different page of the form.
In each case, the move fails if the field is invalid. π«
If the modified field is valid, the form driver copies the modified data from the window associated with the field to the field buffer.
π Mouse Handling π
If the second argument is the KEY_MOUSE special key, the associated mouse event is translated into one of the above pre-defined requests. Currently only clicks in the user window β e.g., inside the form display area or the decoration window β are handled.
If you click above the display region of the form:
- a
REQ_PREV_FIELDis generated for a single click, - a
REQ_PREV_PAGEis generated for a double-click, and - a
REQ_FIRST_FIELDis generated for a triple-click.
If you click below the display region of the form:
- a
REQ_NEXT_FIELDis generated for a single click, - a
REQ_NEXT_PAGEis generated for a double-click, and - a
REQ_LAST_FIELDis generated for a triple-click.
If you click at a field inside the display area of the form:
- the form cursor is positioned to that field.
- If you double-click a field, the form cursor is positioned to that field and
E_UNKNOWN_COMMANDis returned. This return value makes sense, because a double click usually means that a field-specific action should be returned. It is exactly the purpose of this return value to signal that an application-specific command should be executed. - If a translation into a request was done,
form_driverreturns the result of this request.
If you clicked outside the user window or the mouse event could not be translated into a form request, E_REQUEST_DENIED is returned. π
π Application-defined Commands π
If the second argument is neither printable nor one of the above pre-defined form requests, the driver assumes it is an application-specific command and returns E_UNKNOWN_COMMAND. Application-defined commands should be defined relative to MAX_COMMAND, the maximum value of these pre-defined requests.
π RETURN VALUE π
form_driver returns one of the following error codes:
E_OKβ the routine succeeded.E_BAD_ARGUMENTβ the routine detected an incorrect or out-of-range argument.E_BAD_STATEβ the routine was called from an initialization or termination function.E_NOT_POSTEDβ the form has not been posted.E_INVALID_FIELDβ contents of field is invalid.E_NOT_CONNECTEDβ no fields are connected to the form.E_REQUEST_DENIEDβ the form driver could not process the request.E_SYSTEM_ERRORβ system error occurred (seeerrno(3)).E_UNKNOWN_COMMANDβ the form driver code saw an unknown request code.
π«Ά PORTABILITY π«Ά
These routines emulate the System V forms library. They were not supported on Version 7 or BSD versions.
π AUTHORS π
Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S. Raymond.
π₯ SEE ALSO π₯
curses(3X), form(3X), form_fieldtype(3X), form_field_buffer(3X), form_field_validation(3X), form_variables(3X), getch(3X)
okay that's the tea, bestie π« β this page is from ncurses 6.5, dated 2025-10-04, and it's the form_driver(3X) manual. byeee πβ¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright 2018-2024,2025 Thomas E. Dickey
- Copyright 1998-2016,2017 Free Software Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms