.\" Automatically generated by Pandoc 2.9.2.1 .\" .TH "notcurses_tree" "3" "v3.0.0" "" "" .hy .SH NAME .PP notcurses_tree - high-level hierarchical line-based data .SH SYNOPSIS .PP \f[B]#include \f[R] .IP .nf \f[C] struct nctree; struct ncplane; typedef struct nctree_item { void* curry; struct nctree_item* subs; unsigned subcount; } nctree_item; typedef struct nctree_options { const nctree_item* items; // top-level nctree_item array unsigned count; // size of |items| int (*nctreecb)(struct ncplane*, void*, int); // item callback int indentcols; // columns to indent per hierarchy uint64_t flags; // bitfield of NCTREE_OPTION_* } nctree_options; \f[R] .fi .PP \f[B]struct nctree* nctree_create(struct ncplane* \f[R]\f[I]n\f[R]\f[B], const nctree_options* \f[R]\f[I]opts\f[R]\f[B]);\f[R] .PP \f[B]struct ncplane* nctree_plane(struct nctree* \f[R]\f[I]n\f[R]\f[B]);\f[R] .PP \f[B]int nctree_redraw(struct nctree* \f[R]\f[I]n\f[R]\f[B]);\f[R] .PP \f[B]bool nctree_offer_input(struct nctree* \f[R]\f[I]n\f[R]\f[B], const ncinput* \f[R]\f[I]ni\f[R]\f[B]);\f[R] .PP \f[B]void* nctree_focused(struct nctree* \f[R]\f[I]n\f[R]\f[B]);\f[R] .PP \f[B]void* nctree_next(struct nctree* \f[R]\f[I]n\f[R]\f[B]);\f[R] .PP \f[B]void* nctree_prev(struct nctree* \f[R]\f[I]n\f[R]\f[B]);\f[R] .PP \f[B]void* nctree_goto(struct nctree* \f[R]\f[I]n\f[R]\f[B], const int* \f[R]\f[I]spec\f[R]\f[B], size_t \f[R]\f[I]specdepth\f[R]\f[B], int* \f[R]\f[I]failspec\f[R]\f[B]);\f[R] .PP \f[B]void nctree_destroy(struct nctree* \f[R]\f[I]n\f[R]\f[B]);\f[R] .SH DESCRIPTION .PP \f[B]nctree\f[R]s organize static hierarchical items, and allow them to be browsed. Each item can have arbitrary subitems. Items can be collapsed and expanded. The display supports scrolling and searching. Items cannot be added or removed, however; they must be provided in their entirety at creation time. .PP An \f[B]nctree\f[R] cannot be empty. \f[B]count\f[R] must be non-zero, and \f[B]items\f[R] must not be \f[B]NULL\f[R]. The callback function \f[B]nctreecb\f[R] must also be non-\f[B]NULL\f[R]. .PP The callback function \f[B]nctreecb\f[R] is called on tree items when the tree is redrawn. It will be called on each visible item, and any item which has become hidden. If the item is newly hidden, the \f[B]ncplane\f[R] argument will be \f[B]NULL\f[R]. If the item is newly visible, the \f[B]ncplane\f[R] argument will be an empty plane. If the item was already visible, the \f[B]ncplane\f[R] argument will be the same plane passed before. If the item has not changed since the last time the callback was invoked, there is no need to change the plane, and the callback can return immediately. Otherwise, the plane ought be drawn by the callback. Any unused rows ought be trimmed away using \f[B]ncplane_resize\f[R]. If the plane is expanded in the callback, it will be shrunk back down by the widget. The \f[B]int\f[R] parameter indicates distance from the focused item. If the parameter is negative, the item is before the focused item; a positive parameter implies that the item follows the focused item; the focused item itself is passed zero. .SH RETURN VALUES .PP \f[B]nctree_create\f[R] returns \f[B]NULL\f[R] for invalid options. This includes a \f[B]NULL\f[R] \f[B]items\f[R] or \f[B]nctreecb\f[R] field, or a zero \f[B]count\f[R] field. .PP \f[B]nctree_next\f[R] and \f[B]nctree_prev\f[R] both return the \f[B]curry\f[R] pointer from the newly-focused item. \f[B]nctree_focused\f[R] returns the \f[B]curry\f[R] pointer from the already-focused item. .SH NOTES .PP \f[B]nctree\f[R] shares many properties with \f[B]notcurses_reel\f[R]. Unlike the latter, \f[B]nctree\f[R]s support arbitrary hierarchical levels, but they do not allow elements to come and go across the lifetime of the widget. .SH SEE ALSO .PP \f[B]notcurses(3)\f[R], \f[B]notcurses_input(3)\f[R], \f[B]notcurses_plane(3)\f[R], \f[B]notcurses_reel(3)\f[R] .SH AUTHORS nick black .