form_field_new(3X)

πŸ’– form_field_new(3X) β€” bestie edition πŸ’–

Library calls ✨ so this is the one about making and unmaking form fields, iykyk.


🌸 NAME 🌸

new_field, dup_field, link_field, free_field β€” create and destroy form fields πŸŽ€


✨ SYNOPSIS ✨

#include <form.h>

FIELD *new_field(int height, int width,
                 int toprow, int leftcol,
                 int offscreen, int nbuffers);
FIELD *dup_field(FIELD *field, int toprow, int leftcol);
FIELD *link_field(FIELD *field, int toprow, int leftcol);
int free_field(FIELD *field);

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so new_field is the main character here πŸ‘‘ β€” it allocates a brand new field and initializes it from the parameters you hand it: height, width, the row of the upper-left corner, the column of the upper-left corner, the number of off-screen rows, and the number of additional working buffers. That's the whole vibe check. πŸ’…

Then dup_field β€” it duplicates a field at a new location, no cap. Most attributes get copied over, and bestie that list is long: current contents, size, validation type, buffer count, growth threshold, justification, foreground, background, pad character, options, and user pointer. All of it, copied. 😌

But NOT everything, and this is important: field status and the field page bit are not copied. πŸ™ˆ

link_field acts like dup_field, but with a twist 🧚 β€” the new field shares buffers with its parent. The attribute data, though? Separate. Independent. Living its own life. ✨

And free_field de-allocates the storage associated with a field. Bye babe 🫢


πŸ’€ RETURN VALUE πŸ’€

new_field, dup_field, and link_field return NULL on error, and they set errno according to their success:

  • E_OK β€” the routine succeeded. slay πŸ’–
  • E_BAD_ARGUMENT β€” routine detected an incorrect or out-of-range argument. 😭
  • E_SYSTEM_ERROR β€” system error occurred, e.g., malloc failure. πŸ’€

And free_field returns one of these:

  • E_OK β€” the routine succeeded. ✨
  • E_BAD_ARGUMENT β€” routine detected an incorrect or out-of-range argument. 🫠
  • E_CONNECTED β€” field is connected. πŸ”—

🌈 PORTABILITY 🌈

These routines emulate the System V forms library. They were not supported on Version 7 or BSD versions β€” so if you're on one of those, that's a no from the universe. πŸ™…

Also, ngl, it may be unwise to count on the set of attributes copied by dup_field being portable β€” the System V forms library documents are not very explicit about what gets copied and what does not. So like… don't build your whole personality on it. 😬

πŸ‘‘ AUTHORS πŸ‘‘

Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S. Raymond. legends, fr fr 🫢


πŸ“ SEE ALSO πŸ“

curses(3X), form(3X) β€” go read those next bestie, they're giving lore πŸ“š


Okay that's the whole page!! This was ncurses 6.6, dated 2024-12-28 β€” mwah, kissing you goodbye πŸ’‹πŸ’œ

πŸ“¦ where this page comes from