notcurses_reader(3)
π NAME π
okay bestie, so notcurses_reader(3) is the notcurses high level widget for collecting input, and it's giving main character energy for free-form text entry. β¨
β¨ SYNOPSIS β¨
copy these exactly, no cap:
#include <notcurses/notcurses.h>
struct ncplane;
struct ncreader;
struct notcurses;
#define NCREADER_OPTION_HORSCROLL 0x0001
#define NCREADER_OPTION_VERSCROLL 0x0002
#define NCREADER_OPTION_NOCMDKEYS 0x0004
#define NCREADER_OPTION_CURSOR 0x0008
typedef struct ncreader_options {
uint64_t tchannels; // channels used for input
uint32_t tattrword; // attributes used for input
uint64_t flags; // bitfield over NCREADER_OPTION_*
} ncreader_options;
struct ncreader* ncreader_create(struct notcurses* nc, const
ncreader_options* opts);
int ncreader_clear(struct ncreader* n);
struct ncplane* ncreader_plane(struct ncreader* n);
int ncreader_move_left(struct ncreader* n);
int ncreader_move_right(struct ncreader* n);
int ncreader_move_up(struct ncreader* n);
int ncreader_move_down(struct ncreader* n);
int ncreader_write_egc(struct ncreader* n, const char* egc);
bool ncreader_offer_input(struct ncreader* n, const ncinput* ni);
char* ncreader_contents(const struct ncreader* n);
void ncreader_destroy(struct ncreader* n, char contents);**
πΈ DESCRIPTION πΈ
okay so the ncreader widget supports free-form, multi-line input. It supports navigation with the arrow keys and scrolling. While the visible portion of the ncreader is always the same size (defined by the provided ncplane), the actual text backing this visible region can grow arbitrarily large if scrolling is enabled. no cap, it can get huge in there. π¦
The following option flags are supported:
NCREADER_OPTION_HORSCROLLβ the visual area will be backed by a plane that can grow arbitrarily wide. πNCREADER_OPTION_VERSCROLLβ the visual area will be backed by a plane that can grow arbitrarily high. (but lowkey check NOTES, bestie β it's not yet implemented.)NCREADER_OPTION_NOCMDKEYSβ the typical keyboard shortcuts (see below) will not be honored.NCREADER_OPTION_CURSORβ the terminal's cursor will be made visible across the life of thencreader, and its location will be managed. π
The contents of the ncreader can be retrieved with ncreader_contents. slay.
The ncreader consists of at least one ncplane (the visible editing area). If the ncreader supports scrolling, it will consist of two ncplanes, one of which will be kept outside the rendering area (and will thus be invisible). ncreader_plane always returns the visible plane. that's the one you actually see, iykyk. β¨
ncreader_clear drops all input from the ncreader, restoring it to the same pristine condition in which it was returned by ncreader_create. factory reset vibes, fr fr. π§
Unlike most widgets' input handlers, ncreader_offer_input will consume most inputs. The arrow keys navigate. Backspace consumes the EGC to the left of the cursor, if one exists. Enter moves to the first column of the next line (if the cursor is already on the bottom line, the plane must have scrolling enabled, or the cursor will not advance, though the Enter will still be consumed). Otherwise, most inputs will be reproduced onto the ncreader (though see NOTES below). it's giving hungry little input monster, but politely. π
All the ncreader's content is returned from ncreader_contents, preserving whitespace. yes, even your chaotic little spaces. π«Ά
"Emacs-style" keyboard shortcuts similar to those supported by readline(3) and most shells are supported unless NCREADER_OPTION_NOCMDKEYS is provided to ncreader_create. shell girlies stay winning. π
π§ NOTES π§
- Support for
NCREADER_OPTION_VERSCROLLis not yet implemented. not me pointing at the docs like π ncreaderdoes not buffer inputs in order to assemble EGCs from them. If inputs are to be processed as EGCs (as they should), the caller would need assemble the grapheme clusters. Of course, there is not yet any API through which multi-codepoint EGCs could be supplied toncreader. that's the whole situation, bestie. π¦- There is not yet any support for word-wrapping. This will likely come in the future. future icon behavior, manifesting it. β
π«Ά RETURN VALUES π«Ά
ngl, this section is literally empty in the source β no return values are documented here. that's the whole vibe. π
π SEE ALSO π
notcurses(3), notcurses_input(3), notcurses_plane(3), readline(3) go read those too, bestie. π
π AUTHORS π
nick black nickblack@linux.com the icon behind the icon. π
okay that's the whole page, bestie β this cuteness came from the v3.0.17 edition of notcurses_reader(3), and the footer has no date on it, so no date to report. periodt. π
π¦ 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