form(3X)
β¨ NAME β¨
form β present user-fillable forms in curses windows π
π¦ SYNOPSIS π¦
#include <form.h>
π DESCRIPTION π
okay bestie, listen. the form library is literally the whole reason you can build terminal-independent form screens on character-cell terminals. it's giving β¨structured inputβ¨ and we are obsessed.
it comes with two whole flavors of routines:
- field routines β they create and modify form fields
- form routines β they group fields into forms, display forms on the screen, and handle interaction with the user
the form library uses the curses libraries. so to use it, you link with the options -lform -lcurses. no cap, if you skip that you get nothing.
your program should set up the locale, like:
setlocale(LC_ALL, "");
so that input/output processing will work. it's literally the vibe check for your text.
also, a curses initialization routine such as initscr must be called before using any of these functions. like, before. not after. before. π«Ά
πΈ Current Default Values for Field Attributes πΈ
the form library keeps a default value for field attributes. you can get or set this default by calling the appropriate set_ or retrieval routine with a NULL field pointer.
here's the tea though: changing this default with a set_ function affects future field creations, but does not change the rendering of fields already created. periodt.
π Routine Name Index π
this is the master list of every form routine and the manual page where it lives. routines flagged with * are ncurses-specific, not present in SVr4. iykyk.
current_fieldβform_page(3X)data_aheadβform_data(3X)data_behindβform_data(3X)dup_fieldβform_field_new(3X)dynamic_field_infoβform_field_info(3X)field_argβform_field_validation(3X)field_backβform_field_attributes(3X)field_bufferβform_field_buffer(3X)field_countβform_field(3X)field_foreβform_field_attributes(3X)field_indexβform_page(3X)field_infoβform_field_info(3X)field_initβform_hook(3X)field_justβform_field_just(3X)field_optsβform_field_opts(3X)field_opts_offβform_field_opts(3X)field_opts_onβform_field_opts(3X)field_padβform_field_attributes(3X)field_statusβform_field_buffer(3X)field_termβform_hook(3X)field_typeβform_field_validation(3X)field_userptrβform_field_userptr(3X)form_driverβform_driver(3X)form_driver_wβform_driver(3X)*form_fieldsβform_field(3X)form_initβform_hook(3X)form_optsβform_opts(3X)form_opts_offβform_opts(3X)form_opts_onβform_opts(3X)form_pageβform_page(3X)form_request_by_nameβform_requestname(3X)*form_request_nameβform_requestname(3X)*form_subβform_win(3X)form_termβform_hook(3X)form_userptrβform_userptr(3X)form_winβform_win(3X)free_fieldβform_field_new(3X)free_fieldtypeβform_fieldtype(3X)free_formβform_new(3X)link_fieldβform_field_new(3X)link_fieldtypeβform_fieldtype(3X)move_fieldβform_field(3X)new_fieldβform_field_new(3X)new_fieldtypeβform_fieldtype(3X)new_formβform_new(3X)new_pageβform_new_page(3X)pos_form_cursorβform_cursor(3X)post_formβform_post(3X)scale_formβform_win(3X)set_current_fieldβform_page(3X)set_field_backβform_field_attributes(3X)set_field_bufferβform_field_buffer(3X)set_field_foreβform_field_attributes(3X)set_field_initβform_hook(3X)set_field_justβform_field_just(3X)set_field_optsβform_field_opts(3X)set_field_padβform_field_attributes(3X)set_field_statusβform_field_buffer(3X)set_field_termβform_hook(3X)set_field_typeβform_field_validation(3X)set_field_userptrβform_field_userptr(3X)set_fieldtype_argβform_fieldtype(3X)set_fieldtype_choiceβform_fieldtype(3X)set_form_fieldsβform_field(3X)set_form_initβform_hook(3X)set_form_optsβform_field_opts(3X)set_form_pageβform_page(3X)set_form_subβform_win(3X)set_form_termβform_hook(3X)set_form_userptrβform_userptr(3X)set_form_winβform_win(3X)set_max_fieldβform_field_buffer(3X)set_new_pageβform_new_page(3X)unfocus_current_fieldβform_page(3X)*unpost_formβform_post(3X)
π RETURN VALUE π
so, the rules here are simple and we love them:
routines that return pointers return NULL on error, and set errno to the corresponding error-code returned by functions returning an integer.
routines that return an integer return one of these error codes:
E_OKβ the routine succeeded. slay. πE_BAD_ARGUMENTβ routine detected an incorrect or out-of-range argument.E_BAD_STATEβ routine was called from an initialization or termination function.E_CONNECTEDβ the field is already connected to a form.E_INVALID_FIELDβ contents of a field are not valid.E_NOT_CONNECTEDβ no fields are connected to the form.E_NOT_POSTEDβ the form has not been posted.E_NO_ROOMβ form is too large for its window. πE_POSTEDβ the form is already posted.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.
π NOTES π
fun fact bestie: the header file form.h itself includes curses.h. it's giving self-sufficient. π
π§ PORTABILITY π§
these routines emulate the System V forms library. they were not supported on Version 7 or BSD versions.
a form facility was documented in SVr4.2's Character User Interface Programming document.
it is not part of X/Open Curses.
aside from ncurses, there are few implementations, lowkey:
- systems based on SVr4 source code, e.g., Solaris.
- NetBSD curses.
a few functions in this implementation are extensions added for ncurses, but not provided by other implementations, e.g., form_driver_w, unfocus_current_field.
π«Ά AUTHORS π«Ά
Juergen Pfeifer. Manual pages and adaptation for ncurses by Eric S. Raymond. legends, honestly. π
β SEE ALSO β
curses(3X) and related pages whose names begin βform_β for detailed descriptions of the entry points. go read them, they ate. π₯
that's the whole page babes π this was ncurses 6.6, dated 2025-11-11, and if you made it to the bottom of the routine index you're officially a main character. bye bestie, go build a form π¦πβ¨
π¦ where this page comes from
- alpine 3.24: ncurses-doc 6.6_p20260516-r0 Β· X11
- arch rolling: ncurses 6.6-2 Β· MIT-open-group
- fedora 44: ncurses-devel 6.6-1.fc44 Β· MIT-open-group
- fedora 44: ncurses-devel 6.6-1.fc44 Β· MIT-open-group
- Copyright 2018-2024,2025 Thomas E. Dickey
- Copyright 1998-2016,2017 Free Software Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms