field_info(3FORM)

✨ field_info β€” it's giving "tell me everything about my field" πŸ’…

okay bestie, so this is a page from the ncurses Library calls girlies (yes, section 3FORM, we're fancy like that) and it's literally just two little functions whose whole job is spilling the tea about a FIELD πŸ«–βœ¨


πŸŽ€ NAME πŸŽ€

dynamic_field_info, field_info β€” retrieve field characteristics

like… they get the deets on your field. that's the whole gig. periodt.


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <form.h>

int field_info(const FIELD *field,
               int *rows, int *cols,
               int *frow, int *fcol,
               int *nrow, int *nbuf);

int dynamic_field_info(const FIELD *field,
                       int *rows, int *cols, int *max);

no cap, that's the whole vibe. two functions, one header, and a lot of int * pointers bestie 😭


πŸ’– DESCRIPTION πŸ’–

so, field_info returns the sizes and other attributes that were passed in to the field at its creation time. it's giving "receipts from the day you were born" πŸ‘‘

the attributes are: height, width, row of upper-left corner, column of upper-left corner, number off-screen rows, and number of working buffers.

meanwhile dynamic_field_info is the main character who tells you the actual size of the field and its maximum possible size. very "current situation + your full potential" energy 🌈

and here's the lil plot twist: if the field has no size limit, the location addressed by the third argument gets set to 0. so like, unlimited. no ceiling. free. ✨

a field can be made dynamic by turning off the O_STATIC option with field_opts_off. that's the whole ritual, bestie πŸ•―οΈ


πŸ’… RETURN VALUE πŸ’…

these routines return one of the following, and you will be checking, because ignoring return values is not the vibe:

  • E_OK β€” the routine succeeded. ate. no notes. πŸ‘‘
  • E_SYSTEM_ERROR β€” a system error occurred (see errno(3)). something went wrong in the machine and it's not your fault, go touch grass 🌸
  • E_BAD_ARGUMENT β€” the routine detected an incorrect or out-of-range argument. bestie. bestie. what did you pass in. πŸ’€

🧚 PORTABILITY 🧚

these routines emulate the System V forms library. they were not supported on Version 7 or BSD versions β€” so if you're time-traveling, that's a you problem, not a them problem πŸ™ˆ

also, a null (zero pointer) is accepted for any of the return values, to ignore that value. so you can be like "i only care about rows, the rest is background noise" and it will simply not write to the ones you nulled. iconic behaviour tbh.

but β€” and this is the important part β€” not all implementations allow this, e.g., Solaris 2.7 does not. so like, check before you get cute with nulls on other platforms, iykyk 🚨


πŸ’œ AUTHORS πŸ’œ

Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S. Raymond.

(we stan them. legends. thank you for your service 🫢)


⭐ SEE ALSO ⭐

ncurses(3NCURSES) and related pages whose names begin β€œform_” for detailed descriptions of the entry points.

like if this page wasn't enough for you (fair), go read the form_ girlies, they have the full lore πŸ“š


okay that's the page!! and a lil sign-off: this is from ncurses 6.6, dated 2024-03-16, filed under field_info(3FORM). stay safe, read your return values, and don't forget to null out the args you don't need πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from