field_opts(3FORM)

πŸ’– field_opts β€” bestie, let's talk field options πŸ’–

okay so this is field_opts(3FORM) from the Library calls section of the manual, and it's literally all about setting and getting the options on a FIELD in ncurses forms. it's giving "tiny API, big power", and honestly? we're obsessed. πŸŽ€


✨ NAME ✨

set_field_opts, field_opts_on, field_opts_off, field_opts β€” set and get field options 🫢


✨ SYNOPSIS ✨

#include <form.h>

int set_field_opts(FIELD *field, Field_Options opts);
Field_Options field_opts(const FIELD *field);

int field_opts_on(FIELD *field, Field_Options opts);
int field_opts_off(FIELD *field, Field_Options opts);

✨ DESCRIPTION ✨

okay so here's the vibe. four functions, one job: wrangling your field's option bits. πŸ¦‹

  • set_field_opts β€” sets all the given field's option bits. and bestie, field option bits can be logically "or"-ed together, so you can stack them up like charms on a bracelet. ✨
  • field_opts_on β€” turns on the given option bits, and leaves all the others alone. no touching, no drama.
  • field_opts_off β€” turns off the given option bits, and leaves all the others alone. same energy, opposite direction. πŸ’…
  • field_opts β€” returns the field's current option bits. it's the "what's the vibe rn" function. returns a Field_Options.

🌸 standard options (all on by default) 🌸

these are the OGs, and yes, all of them are on by default. main character defaults fr fr.

  • O_ACTIVE β€” the field is visited during processing. if this option is off, the field will not be reachable by navigation keys. ⚠️ and just so you know: an invisible field appears to be inactive also. iykyk.
  • O_AUTOSKIP β€” skip to the next field when this one fills. auto-advance, no cap. ⭐
  • O_BLANK β€” the field is cleared whenever a character is entered at the first position. clean slate behavior. 🧚
  • O_EDIT β€” the field can be edited. that's it, that's the whole thing.
  • O_NULLOK β€” allow a blank field. empty is a valid vibe. πŸ“
  • O_PASSOK β€” validate field only if modified by user.
  • O_PUBLIC β€” the field contents are displayed as data is entered. live updates, we love to see it.
  • O_STATIC β€” field buffers are fixed to the field's original size. turn this option off to create a dynamic field. glow-up unlocked. ✨
  • O_VISIBLE β€” the field is displayed. if this option is off, display of the field is suppressed. ghost mode, basically. πŸ‘» (well, not literally, but you get it)
  • O_WRAP β€” words that do not fit on a line are wrapped to the next line. and heads up: words are blank-separated. πŸŽ€

πŸ’œ extension options (off by default) πŸ’œ

these are the extra-special bonus features, and ngl, extensions are off by default. you gotta opt in.

  • O_DYNAMIC_JUSTIFY β€” permit dynamic fields to be justified, like static fields. letting the dynamic girlies have what the static girlies have. πŸ’…
  • O_NO_LEFT_STRIP β€” preserve leading whitespace in the field buffer, which is normally discarded. keeping the space, literally.
  • O_EDGE_INSERT_STAY β€” when inserting into a field up to the boundary position, optionally delay the scrolling, so that the last inserted character remains visible, but advance the cursor to reflect the insertion. and the reason this slays? it allows the form library to display the inserted character in one-character fields as well as allowing the library to maintain consistent state. πŸ”₯
  • O_INPUT_FIELD β€” the set_max_field function checks for this extension, which allows a dynamic field to shrink if the new limit is smaller than the current field size. shrinking is allowed, periodt.

✨ RETURN VALUE ✨

so except for field_opts, each routine returns one of the following:

  • E_OK β€” the routine succeeded. πŸŽ‰ slay.
  • E_BAD_ARGUMENT β€” routine detected an incorrect or out-of-range argument. πŸ’€
  • E_CURRENT β€” the field is the current field.
  • E_SYSTEM_ERROR β€” system error occurred (see errno(3)). 😭

✨ PORTABILITY ✨

these routines emulate the System V forms library. they were not supported on Version 7 or BSD versions. so like, if you're time-traveling, know that. πŸ•°οΈ


✨ AUTHORS ✨

Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S. Raymond. absolute icons, we thank them for their service. πŸ‘‘


✨ SEE ALSO ✨

ncurses(3NCURSES), form(3FORM), field_just(3FORM) 🌈


and that's the whole page bestie!! this was field_opts(3FORM) from ncurses 6.6, dated 2025-01-18. go forth and set your option bits, you've got this πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from