---
name: "notcurses_selector"
section: "3"
platform: "linux"
package: "notcurses"
version: "3.0.17-3"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/notcurses_selector"
---

# notcurses\_selector(3)

high level widget for selecting from a set

## NAME

notcurses\_selector - high level widget for selecting from a set

## SYNOPSIS

**#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). It facilitates a choice of zero or one item from the list.

## NOTES

The **ncplane** **n** provided to **ncselector\_create** must not be **NULL**. It will be freely resized by the new **ncselector**, and thus cannot be the standard plane. **ncselector\_selected** returns the currently-selected option. **ncselector\_additem** and **ncselector\_delitem** allow items to be added and deleted on the fly (a static set of items can all be provided in the **ncselector\_create** call). The backing plane will be resized as necessary for item changes.

**ncselector\_nextitem** and **ncselector\_previtem** select the next (down) or previous (up) option, scrolling if necessary. It is safe to call these functions even if no options are present.

**ncselector\_plane** will 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\_input** to 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.

**ncselector\_destroy** destroys the backing **ncplane**, as does **ncselector\_create** in the event of any error.

As no flags exist, the **flags** option ought always be 0.

## RETURN VALUES

**ncselector\_create** returns **NULL** on an error, in which case the passed **ncplane** is destroyed.

**ncselector\_selected** returns a reference to the **option** part of the selected **ncselector\_item**. If there are no items, it returns **NULL**.

**ncselector\_previtem** and **ncselector\_nextitem** return references to the **option** part of the newly-selected **ncselector\_item**. If there are no items, they return **NULL**.

## SEE ALSO

**[notcurses(3)](/notcurses/3.md)**, **[notcurses\_input(3)](/notcurses_input/3.md)**, **[notcurses\_multiselector(3)](/notcurses_multiselector/3.md)**, **[notcurses\_plane(3)](/notcurses_plane/3.md)**, **[notcurses\_stdplane(3)](/notcurses_stdplane/3.md)**

## AUTHORS

nick black ⟨nickblack@linux.com⟩\\c.
