notcurses_selector(3)
π NAME π
okay bestie, welcome to notcurses_selector(3) β the manual page for the high-level widget that lets you select from a set β¨. It's giving "choose zero or one thing from a list" and honestly? iconic behavior.
β¨ SYNOPSIS β¨
include it like this, no cap:
#include <notcurses/notcurses.h>
struct ncplane;
struct notcurses;
struct ncselector;
struct ncselector_item {
const char* option;
const char* desc;
};
typedef struct ncselector_options {
const char* title; // title may be NULL, inhibiting riser
const char* secondary; // secondary may be NULL
const char* footer; // footer may be NULL
struct ncselector_item* items; // initial items and descriptions
// default item (selected at start)
unsigned defidx;
// maximum number of options to display at once
unsigned maxdisplay;
// exhaustive styling options
uint64_t opchannels; // option channels
uint64_t descchannels; // description channels
uint64_t titlechannels;// title channels
uint64_t footchannels; // secondary and footer channels
uint64_t boxchannels; // border channels
uint64_t flags; // bitfield over NCSELECTOR_OPTION_*
} ncselector_options;
struct ncselector* ncselector_create(struct ncplane* n, const
ncselector_options* opts);
int ncselector_additem(struct ncselector* n, const struct
ncselector_item* item);
int ncselector_delitem(struct ncselector* n, const char* item);
const char* ncselector_selected(const struct ncselector* n);
struct ncplane* ncselector_plane(struct ncselector* n);
const char* ncselector_previtem(struct ncselector* n);
const char* ncselector_nextitem(struct ncselector* n);
bool ncselector_offer_input(struct ncselector* n, const ncinput* nc);
void ncselector_destroy(struct ncselector* n, char item);**
π¦ DESCRIPTION π¦
A selector widget presents a list of items β possibly more than can be displayed at once π β and it facilitates a choice of zero or one item from the list. That's the whole main-character job. Simple, but slay.
π NOTES π
- The ncplane
nprovided toncselector_createmust not beNULL. It will be freely resized by the new ncselector, and thus cannot be the standard plane. Like, it's literally getting a glow-up whether you're ready or not. ncselector_selectedreturns the currently-selected option.ncselector_additemandncselector_delitemallow items to be added and deleted on the fly (a static set of items can all be provided in thencselector_createcall). The backing plane will be resized as necessary for item changes.ncselector_nextitemandncselector_previtemselect the next (down) or previous (up) option, scrolling if necessary. It is safe to call these functions even if no options are present. no options? still safe. we love a resilient icon.ncselector_planewill return the ncplane on which the widget is drawn.- While the ncselector can be driven entirely by client code, input can be run through
ncselector_offer_inputto take advantage of common controls. It will handle the up and down arrows, along with PageUp and PageDown. If the mouse is enabled, the mouse scrollwheel and mouse clicks on the scroll arrows will be handled. very "it just works" of it. ncselector_destroydestroys the backing ncplane, as doesncselector_createin the event of any error.- As no flags exist, the
flagsoption ought always be0. periodt.
lowkey important: ncselector_create can destroy the ncplane you passed in if it errors, so don't be out here using it after that. π
πΈ RETURN VALUES πΈ
ncselector_createreturnsNULLon an error, in which case the passed ncplane is destroyed.ncselector_selectedreturns a reference to the option part of the selectedncselector_item. If there are no items, it returnsNULL.ncselector_previtemandncselector_nextitemreturn references to the option part of the newly-selectedncselector_item. If there are no items, they returnNULL.
π SEE ALSO π
π AUTHORS π
nick black nickblack@linux.com
okay that's the whole page, bestie π
β footer vibes: version v3.0.17, manual notcurses_selector(3), and the date slot is lowkey empty in this copy. byeee π¦
π¦ where this page comes from
- alpine 3.24: notcurses-doc 3.0.17-r0 Β· Apache-2.0
- ubuntu resolute: libnotcurses-core-dev 3.0.17+dfsg-3 Β· Apache-2.0
- ubuntu stonking: libnotcurses-core-dev 3.0.17+dfsg-3 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms