2020-04-24 07:17:34 +00:00
% notcurses_plane(3)
2020-01-02 02:23:11 +00:00
% nick black < nickblack @ linux . com >
2021-04-04 01:26:04 +00:00
% v2.2.5
2020-01-02 02:23:11 +00:00
# NAME
2020-04-24 07:17:34 +00:00
notcurses_plane - operations on ncplanes
2020-01-02 02:23:11 +00:00
# SYNOPSIS
2020-04-19 22:46:32 +00:00
**#include < notcurses / notcurses . h > **
2020-01-02 02:23:11 +00:00
2020-09-20 09:30:17 +00:00
```c
2021-03-27 10:01:51 +00:00
#define NCPLANE_OPTION_HORALIGNED 0x0001ull
#define NCPLANE_OPTION_VERALIGNED 0x0002ull
#define NCPLANE_OPTION_MARGINALIZED 0x0004ull
2020-09-20 09:30:17 +00:00
typedef struct ncplane_options {
2020-11-15 08:02:44 +00:00
int y; // vertical placement relative to parent plane
int x; // horizontal placement relative to parent plane
2020-09-20 09:30:17 +00:00
int rows; // number of rows, must be positive
int cols; // number of columns, must be positive
void* userptr; // user curry, may be NULL
const char* name; // name (used only for debugging), may be NULL
2020-11-17 07:25:40 +00:00
int (*resizecb)(struct ncplane*); // called on parent resize
2020-09-20 09:30:17 +00:00
uint64_t flags; // closure over NCPLANE_OPTION_*
2021-03-27 10:01:51 +00:00
int margin_b, margin_r; // bottom and right margins
2020-09-20 09:30:17 +00:00
} ncplane_options;
```
2020-11-06 21:49:35 +00:00
**struct ncplane* ncplane_create(struct ncplane* ** *n***, const ncplane_options* ** *nopts***);**
2020-09-20 09:30:17 +00:00
2020-11-24 01:31:39 +00:00
**struct ncplane* ncpile_create(struct notcurses* ** *n***, const ncplane_options* ** *nopts***);**
2020-11-06 21:49:35 +00:00
**struct ncplane* notcurses_top(struct notcurses* ** *n***);**
2020-08-25 12:55:30 +00:00
2020-11-06 21:49:35 +00:00
**struct ncplane* notcurses_bottom(struct notcurses* ** *n***);**
2020-08-25 12:55:30 +00:00
2020-12-03 05:25:29 +00:00
**struct ncplane* ncpile_top(struct ncplane* ** *n***);**
**struct ncplane* ncpile_bottom(struct ncplane* ** *n***);**
2020-11-06 21:49:35 +00:00
**struct ncplane* ncplane_reparent(struct ncplane* ** *n***, struct ncplane* ** *newparent***);**
2020-08-09 21:40:59 +00:00
2020-11-22 07:52:18 +00:00
**struct ncplane* ncplane_reparent_family(struct ncplane* ** *n***, struct ncplane* ** *newparent***);**
2020-12-09 05:18:47 +00:00
**int ncplane_descendant_p(const struct ncplane* ** *n***, const struct ncplane* ** *ancestor***);**
2020-11-18 12:49:22 +00:00
**int ncplane_resize_realign(struct ncplane* ** *n***);**
2021-03-27 10:01:51 +00:00
**int ncplane_resize_maximize(struct ncplane* ** *n***);**
2021-03-27 10:22:13 +00:00
**int ncplane_resize_marginalized(struct ncplane* ** *n***);**
2021-03-27 10:01:51 +00:00
2020-11-18 12:49:22 +00:00
**void ncplane_set_resizecb(struct ncplane* ** *n***, int(*resizecb)(struct ncplane*));**
2020-11-18 13:00:02 +00:00
**int (*ncplane_resizecb(const struct ncplane* ** *n***))(struct ncplane*);**
2020-11-06 21:49:35 +00:00
**struct ncplane* ncplane_dup(struct ncplane* ** *n***, void* ** *opaque***);**
2020-01-15 17:22:10 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_resize(struct ncplane* ** *n***, int ** *keepy***, int ** *keepx***, int ** *keepleny***, int ** *keeplenx***, int ** *yoff***, int ** *xoff***, int ** *ylen***, int ** *xlen***);**
2020-01-02 02:23:11 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_move_yx(struct ncplane* ** *n***, int ** *y***, int ** *x***);**
2020-01-02 02:23:11 +00:00
2020-11-06 21:49:35 +00:00
**void ncplane_yx(const struct ncplane* ** *n***, int* restrict ** *y***, int* restrict ** *x***);**
2020-01-02 02:23:11 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_y(const struct ncplane* ** *n***);**
2020-08-29 19:50:45 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_x(const struct ncplane* ** *n***);**
2020-08-29 19:50:45 +00:00
2021-01-13 09:49:55 +00:00
**void ncplane_abs_yx(const struct ncplane* ** *n***, int* ** *y***, int* ** *x***);**
2021-01-15 05:32:55 +00:00
**int ncplane_abs_y(const struct ncplane* ** *n***);**
**int ncplane_abs_x(const struct ncplane* ** *n***);**
2020-11-06 21:49:35 +00:00
**struct ncplane* ncplane_parent(struct ncplane* ** *n***);**
2020-08-09 21:40:59 +00:00
2020-11-06 21:49:35 +00:00
**const struct ncplane* ncplane_parent_const(const struct ncplane* ** *n***);**
2020-08-09 21:40:59 +00:00
2020-12-13 05:19:24 +00:00
**int ncplane_set_base_cell(struct ncplane* ** *ncp***, const nccell* ** *c***);**
2020-01-02 02:23:11 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_set_base(struct ncplane* ** *ncp***, const char* ** *egc***, uint32_t ** *stylemask***, uint64_t ** *channels***);**
2020-01-30 13:55:01 +00:00
2020-12-13 05:19:24 +00:00
**int ncplane_base(struct ncplane* ** *ncp***, nccell* ** *c***);**
2020-01-02 02:23:11 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_move_top(struct ncplane* ** *n***);**
2020-01-02 02:23:11 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_move_bottom(struct ncplane* ** *n***);**
2020-01-02 02:23:11 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_move_above(struct ncplane* restrict ** *n***, struct ncplane* restrict ** *above***);**
2020-01-02 02:23:11 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_move_below(struct ncplane* restrict ** *n***, struct ncplane* restrict ** *below***);**
2020-01-02 02:23:11 +00:00
2020-11-06 21:49:35 +00:00
**struct ncplane* ncplane_below(struct ncplane* ** *n***);**
2020-01-02 02:23:11 +00:00
2020-11-06 21:49:35 +00:00
**struct ncplane* ncplane_above(struct ncplane* ** *n***);**
2020-08-25 12:55:30 +00:00
2020-11-06 21:49:35 +00:00
**char* ncplane_at_cursor(struct ncplane* ** *n***, uint16_t* ** *stylemask***, uint64_t* ** *channels***);**
2020-01-02 02:23:11 +00:00
2020-12-13 05:19:24 +00:00
**int ncplane_at_cursor_cell(struct ncplane* ** *n***, nccell* ** *c***);**
2020-04-18 04:09:14 +00:00
2020-11-06 21:49:35 +00:00
**char* ncplane_at_yx(const struct ncplane* ** *n***, int ** *y***, int ** *x***, uint16_t* ** *stylemask***, uint64_t* ** *channels***);**
2020-04-18 04:09:14 +00:00
2020-12-13 05:19:24 +00:00
**int ncplane_at_yx_cell(struct ncplane* ** *n***, int ** *y***, int ** *x***, nccell* ** *c***);**
2020-01-02 02:23:11 +00:00
2021-04-08 08:12:01 +00:00
**uint32_t* ncplane_as_rgba(const struct ncplane* ** *nc***, int ** *begy***, int ** *begx***, int ** *leny***, int ** *lenx***, int* ** *pxdimy***, int* ** *pxdimx***);**
2020-05-07 01:40:24 +00:00
2020-11-06 21:49:35 +00:00
**char* ncplane_contents(const struct ncplane* ** *nc***, int ** *begy***, int ** *begx***, int ** *leny***, int ** *lenx***);**
2020-05-08 23:45:47 +00:00
2020-11-06 21:49:35 +00:00
**void* ncplane_set_userptr(struct ncplane* ** *n***, void* ** *opaque***);**
2020-01-02 02:23:11 +00:00
2020-11-06 21:49:35 +00:00
**void* ncplane_userptr(struct ncplane* ** *n***);**
2020-01-02 02:23:11 +00:00
2020-11-06 21:49:35 +00:00
**void ncplane_dim_yx(const struct ncplane* ** *n***, int* restrict ** *rows***, int* restrict ** *cols***);**
2020-01-04 12:21:54 +00:00
2020-11-06 21:49:35 +00:00
**static inline int ncplane_dim_y(const struct ncplane* ** *n***);**
2020-01-04 12:21:54 +00:00
2020-11-06 21:49:35 +00:00
**static inline int ncplane_dim_x(const struct ncplane* ** *n***);**
2020-01-02 02:23:11 +00:00
2020-11-06 21:49:35 +00:00
**void ncplane_cursor_yx(const struct ncplane* ** *n***, int* restrict ** *y***, int* restrict ** *x***);**
2020-01-02 02:23:11 +00:00
2020-11-06 21:49:35 +00:00
**void ncplane_translate(const struct ncplane* ** *src***, const struct ncplane* ** *dst***, int* restrict ** *y***, int* restrict ** *x***);**
2020-02-21 11:26:57 +00:00
2020-11-06 21:49:35 +00:00
**bool ncplane_translate_abs(const struct ncplane* ** *n***, int* restrict ** *y***, int* restrict ** *x***);**
2020-03-03 06:04:28 +00:00
2020-11-06 21:49:35 +00:00
**uint64_t ncplane_channels(const struct ncplane* ** *n***);**
2020-01-04 09:34:29 +00:00
2020-11-06 21:49:35 +00:00
**void ncplane_set_channels(struct ncplane* ** *nc***, uint64_t ** *channels***);**
2020-05-09 00:20:01 +00:00
2020-11-06 21:49:35 +00:00
**static inline unsigned ncplane_bchannel(struct ncplane* ** *nc***);**
2020-01-04 09:34:29 +00:00
2020-11-06 21:49:35 +00:00
**static inline unsigned ncplane_fchannel(struct ncplane* ** *nc***);**
2020-01-04 09:34:29 +00:00
2020-11-06 21:49:35 +00:00
**static inline unsigned ncplane_fg_rgb8(struct ncplane* ** *nc***);**
2020-01-04 09:34:29 +00:00
2020-11-06 21:49:35 +00:00
**static inline unsigned ncplane_bg_rgb8(struct ncplane* ** *nc***);**
2020-01-04 09:34:29 +00:00
2020-11-06 21:49:35 +00:00
**static inline unsigned ncplane_fg_alpha(struct ncplane* ** *nc***);**
2020-01-04 09:34:29 +00:00
2020-11-06 21:49:35 +00:00
**static inline unsigned ncplane_bg_alpha(struct ncplane* ** *nc***);**
2020-01-04 09:34:29 +00:00
2020-11-06 21:49:35 +00:00
**static inline unsigned ncplane_fg_rgb8(struct ncplane* ** *n***, unsigned* ** *r***, unsigned* ** *g***, unsigned* ** *b***);**
2020-01-04 09:34:29 +00:00
2020-11-06 21:49:35 +00:00
**static inline unsigned ncplane_bg_rgb8(struct ncplane* ** *n***, unsigned* ** *r***, unsigned* ** *g***, unsigned* ** *b***);**
2020-01-04 09:34:29 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_set_fg_rgb8(struct ncplane* ** *n***, int ** *r***, int ** *g***, int ** *b***);**
2020-01-12 09:12:43 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_set_bg_rgb8(struct ncplane* ** *n***, int ** *r***, int ** *g***, int ** *b***);**
2020-01-12 09:12:43 +00:00
2020-11-06 21:49:35 +00:00
**void ncplane_set_fg_rgb8_clipped(struct ncplane* ** *n***, int ** *r***, int ** *g***, int ** *b***);**
2020-01-12 09:12:43 +00:00
2020-11-06 21:49:35 +00:00
**void ncplane_set_bg_rgb8_clipped(struct ncplane* ** *n***, int ** *r***, int ** *g***, int ** *b***);**
2020-01-04 09:34:29 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_set_fg_rgb8(struct ncplane* ** *n***, uint32_t ** *channel***);**
2020-01-12 09:12:43 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_set_bg_rgb8(struct ncplane* ** *n***, uint32_t ** *channel***);**
2020-01-04 09:34:29 +00:00
2020-11-06 21:49:35 +00:00
**void ncplane_set_fg_default(struct ncplane* ** *n***);**
2020-01-12 09:12:43 +00:00
2020-11-06 21:49:35 +00:00
**void ncplane_set_bg_default(struct ncplane* ** *n***);**
2020-01-04 09:34:29 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_set_fg_alpha(struct ncplane* ** *n***, unsigned ** *alpha***);**
2020-01-12 09:12:43 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_set_bg_alpha(struct ncplane* ** *n***, unsigned ** *alpha***);**
2020-01-04 09:34:29 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_set_fg_palindex(struct ncplane* ** *n***, int ** *idx***);**
2020-01-19 01:42:29 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_set_bg_palindex(struct ncplane* ** *n***, int ** *idx***);**
2020-01-19 01:42:29 +00:00
2020-11-06 21:49:35 +00:00
**uint16_t ncplane_styles(const struct ncplane* ** *n***);**
2020-09-29 17:03:09 +00:00
2020-11-06 21:49:35 +00:00
**void ncplane_set_styles(struct ncplane* ** *n***, unsigned ** *stylebits***);**
2020-01-12 09:12:43 +00:00
2020-11-06 21:49:35 +00:00
**void ncplane_on_styles(struct ncplane* ** *n***, unsigned ** *stylebits***);**
2020-01-12 09:12:43 +00:00
2020-11-06 21:49:35 +00:00
**void ncplane_off_styles(struct ncplane* ** *n***, unsigned ** *stylebits***);**
2020-01-04 09:34:29 +00:00
2020-11-06 21:49:35 +00:00
**void ncplane_greyscale(struct ncplane* ** *n***);**
2020-01-17 09:31:46 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_blit_bgrx(struct ncplane* ** *nc***, int ** *placey***, int ** *placex***, int ** *linesize***, ncblitter_e ** *blitter***, const unsigned char* ** *data***, int ** *begy***, int ** *begx***, int ** *leny***, int ** *lenx***);**
2020-02-02 07:20:01 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_blit_rgba(struct ncplane* ** *nc***, int ** *placey***, int ** *placex***, int ** *linesize***, ncblitter_e ** *blitter***, const unsigned char* ** *data***, int ** *begy***, int ** *begx***, int ** *leny***, int ** *lenx***);**
2020-02-02 07:20:01 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_destroy(struct ncplane* ** *ncp***);**
2020-03-05 09:49:56 +00:00
2020-11-06 21:49:35 +00:00
**void notcurses_drop_planes(struct notcurses* ** *nc***);**
2020-02-15 23:40:43 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_mergedown(const struct ncplane* ** *src***, struct ncplane* ** *dst***, int ** *begsrcy***, int ** *begsrcx***, int ** *leny***, int ** *lenx***, int ** *dsty***, int ** *dstx***);**
2020-08-21 03:51:35 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_mergedown_simple(const struct ncplane* restrict ** *src***, struct ncplane* restrict ** *dst***);**
2020-03-21 04:11:45 +00:00
2020-11-06 21:49:35 +00:00
**void ncplane_erase(struct ncplane* ** *n***);**
2020-03-21 04:11:45 +00:00
2020-11-06 21:49:35 +00:00
**bool ncplane_set_scrolling(struct ncplane* ** *n***, bool ** *scrollp***);**
2020-04-06 00:29:30 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_rotate_cw(struct ncplane* ** *n***);**
2020-05-04 15:05:52 +00:00
2020-11-06 21:49:35 +00:00
**int ncplane_rotate_ccw(struct ncplane* ** *n***);**
2020-05-04 15:05:52 +00:00
2021-04-10 04:34:38 +00:00
**void ncplane_pixelgeom(struct notcurses* ** *n***, int* restrict ** *pxy***, int* restrict ** *pxx***, int* restrict ** *celldimy***, int* restrict ** *celldimx***, int* restrict ** *maxbmapy***, int* restrict ** *maxbmapx***);**
2020-01-02 02:23:11 +00:00
## DESCRIPTION
Ncplanes are the fundamental drawing object of notcurses. All output functions
2020-01-03 09:18:44 +00:00
take a **struct ncplane** as an argument. They can be any size, and placed
2020-12-13 05:19:24 +00:00
anywhere. In addition to its framebuffer--a rectilinear matrix of **nccell**s
2020-12-16 10:40:14 +00:00
(see **notcurses_cell(3)** )--an ncplane is defined by:
2020-01-02 02:23:11 +00:00
2020-12-13 05:19:24 +00:00
* a base **nccell** , used for any cell on the plane without a glyph,
* the egcpool backing its **nccell**s,
2020-01-02 02:23:11 +00:00
* a current cursor location,
* a current style, foreground channel, and background channel,
* its geometry,
* a configured user pointer,
2020-08-01 03:01:34 +00:00
* position relative to the standard plane,
* the plane, if any, to which it is bound,
* the next plane bound by the plane to which it is bound,
2020-09-20 09:30:17 +00:00
* the head of the list of its bound planes,
2021-03-27 10:01:51 +00:00
* its resize methodology,
2020-09-20 09:30:17 +00:00
* its z-index, and
* a name (used only for debugging).
New planes can be created with **ncplane_create** . If a plane is bound to
another, x and y coordinates are relative to the plane to which it is bound,
and if this latter plane moves, all its bound planes move along with it. When a
plane is destroyed, all planes bound to it (directly or transitively) are
2020-11-22 07:52:18 +00:00
destroyed.
2021-03-26 07:47:19 +00:00
If the **NCPLANE_OPTION_HORALIGNED** flag is provided, ** *x*** is interpreted
as an **ncalign_e** rather than an absolute position. If the
**NCPLANE_OPTION_VERALIGNED** flag is provided, ** *y*** is interpreted as an
**ncalign_e** rather than an absolute postiion. Either way, all positions
2021-03-27 10:01:51 +00:00
are relative to the parent plane. **ncplane_resize_realign** should usually be
used together with these flags, so that the plane is automatically realigned
upon a resize of its parent.
If the **NCPLANE_OPTION_MARGINALIZED** flag is provided, neither
**NCPLANE_OPTION_HORALIGNED** nor **NCPLANE_OPTION_VERALIGNED** may be
provided, and ** *rows*** and ** *cols*** must both be 0. ** *y*** and ** *x***
will be interpreted as top and left margins. ** *margin_b*** and ** *margin_r***
will be interpreted as bottom and right margins. The plane will take the maximum
space possible subject to its parent planes and these margins. The plane cannot
become smaller than 1x1 (the margins are best-effort).
2021-03-27 10:22:13 +00:00
**ncplane_resize_marginalized** should usually be used together with this flag,
2021-03-27 10:01:51 +00:00
so that the plane is automatically resized.
2021-03-26 07:47:19 +00:00
2021-01-04 02:22:38 +00:00
**ncplane_reparent** detaches the plane ** *n*** from any plane to which it is
bound, and binds it to ** *newparent***. Its children are reparented to its
previous parent. The standard plane cannot be reparented. If ** *newparent*** is
2020-11-22 07:52:18 +00:00
**NULL**, the plane becomes the root plane of a new, unrendered stack. When
2021-01-04 02:22:38 +00:00
**ncplane_reparent_family** is used, all planes bound to ** *n*** move along with
2020-11-22 07:52:18 +00:00
it during a reparenting operation. See [Piles][] below.
2020-03-27 06:06:58 +00:00
**ncplane_destroy** destroys a particular ncplane, after which it must not be
used again. **notcurses_drop_planes** destroys all ncplanes other than the
stdplane. Any references to such planes are, of course, invalidated. It is
undefined to destroy a plane concurrently with any other operation involving
that plane, or any operation involving the z-axis.
It is an error for two threads to concurrently mutate a single ncplane. So long
2020-02-19 01:03:20 +00:00
as rendering is not taking place, however, multiple threads may safely output
2020-03-27 06:06:58 +00:00
to multiple ncplanes. So long as all threads are readers, multiple threads may
work with a single ncplane. A reading function is any which accepts a **const
struct ncplane**.
2020-02-19 01:03:20 +00:00
2021-01-13 09:49:55 +00:00
**ncplane_yx** returns the coordinates of the specified plane's origin, relative
to the plane to which it is bound. Either or both of ** *y*** and ** *x*** may
be **NULL** . **ncplane_y** and **ncplane_x** allow a single component of this
location to be retrieved. **ncplane_abs_yx** returns the coordinates of the
specified plane's origin relative to its pile.
2020-03-22 21:33:08 +00:00
**ncplane_translate** translates coordinates expressed relative to the plane
2021-01-04 02:22:38 +00:00
***src***, and writes the coordinates of that cell relative to ** *dst***. The cell
need not intersect with ** *dst***, though this will yield coordinates which are
invalid for writing or reading on ** *dst***. If ** *dst*** is **NULL** , it is taken
2020-03-22 21:33:08 +00:00
to refer to the standard plane. **ncplane_translate_abs** takes coordinates
expressed relative to the standard plane, and returns coordinates relative to
2021-01-04 02:22:38 +00:00
***dst***, returning **false** if the coordinates are invalid for ** *dst***.
2020-03-22 21:33:08 +00:00
2021-01-04 02:22:38 +00:00
**ncplane_mergedown** writes to ** *dst*** the frame that would be rendered if only
***src*** and ** *dst*** existed on the z-axis, ad ** *dst*** represented the entirety
of the rendering region. Only those cells where ** *src*** intersects with ** *dst***
2020-03-21 04:11:45 +00:00
might see changes. It is an error to merge a plane onto itself.
2020-05-09 05:25:00 +00:00
**ncplane_erase** zeroes out every cell of the plane, dumps the egcpool, and
2020-12-03 05:25:29 +00:00
homes the cursor. The base cell is preserved, as are the active attributes.
2020-05-09 05:25:00 +00:00
2020-09-20 10:58:18 +00:00
When a plane is resized (whether by **ncplane_resize** , **SIGWINCH** , or any
2020-09-20 12:54:29 +00:00
other mechanism), a depth-first recursion is performed on its children.
2020-09-20 10:58:18 +00:00
Each child plane having a non-**NULL** **resizecb** will see that callback
invoked following resizing of its parent's plane. If it returns non-zero, the
resizing cascade terminates, returning non-zero. Otherwise, resizing proceeds
recursively.
2021-01-02 07:56:17 +00:00
## Base cells
Each plane has a base cell, initialized to all zeroes. When rendering, the
cells of the plane are examined in turn. Each cell has three independent
rendering elements--its EGC, its foreground channel, and its background
channel. Any default channel is replaced with the corresponding channel from
that plane's base cell. **ncplane_erase** has no effect on the base cell.
Calling **ncplane_erase** on a plane whose base cell is a purple 'A' results
(for rendering purposes) in a plane made up entirely of purple 'A's.
**ncplane_set_base_cell** uses the **nccell** ** *c*** (which must be bound to
the **ncplane** ** *ncp***, and must be the first **nccell** of a multicolumn
sequence) to set the base cell. **ncplane_set_base** does the same with
***egc***, ** *stylemask***, and ** *channels***.
2020-11-22 07:52:18 +00:00
## Piles
A single **notcurses** context is made up of one or more piles. A pile is a
set of one or more **ncplane**s, including the partial orderings made up of
their binding and z-axis pointers. A pile has a top and bottom **ncplane**
(this might be a single plane), and one or more root planes (planes which are
bound to themselves). Multiple threads can concurrently operate on distinct
piles, even changing one while rendering another.
Each plane is part of one and only one pile. By default, a plane is part of the
2020-11-24 01:31:39 +00:00
same pile containing that plane to which it is bound. If **ncpile_create** is
used in the place of **ncplane_create** , the returned plane becomes the root
2020-11-22 08:38:49 +00:00
plane, top, and bottom of a new pile. As a root plane, it is bound to itself. A
new pile can also be created by reparenting a plane to itself, though if the
plane is already a root plane, this is a no-op.
2020-11-22 07:52:18 +00:00
When a plane is moved to a different pile (whether new or preexisting), any
planes which were bound to it are rebound to its previous parent. If the plane
was a root plane of some pile, any bound planes become root planes. The new
plane is placed immediately atop its new parent on its new pile's z-axis.
When `ncplane_reparent_family()` is used, all planes bound to the reparented
plane are moved along with it. Their relative z-order is maintained.
2020-04-06 01:33:12 +00:00
## Scrolling
All planes, including the standard plane, are created with scrolling disabled.
Control scrolling on a per-plane basis with **ncplane_set_scrolling** .
Attempting to print past the end of a line will stop at the plane boundary, and
indicate an error. On a plane 10 columns wide and two rows high, printing
"0123456789" at the origin should succeed, but printing "01234567890" will by
default fail at the eleventh character. In either case, the cursor will be left
at location 0x10; it must be moved before further printing can take place. If
scrolling is enabled, the first row will be filled with 01234546789, the second
row will have 0 written to its first column, and the cursor will end up at 1x1.
Note that it is still an error to manually attempt to move the cursor
off-plane, or to specify off-plane output. Boxes do not scroll; attempting to
draw a 2x11 box on our 2x10 plane will result in an error and no output. When
scrolling is enabled, and output takes place while the cursor is past the end
of the last row, the first row is discarded, all other rows are moved up, the
last row is cleared, and output begins at the beginning of the last row. This
does not take place until output is generated (i.e. it is possible to fill a
plane when scrolling is enabled).
2020-04-06 00:29:30 +00:00
2021-04-10 04:34:38 +00:00
**ncplane_pixelgeom** retrieves pixel geometry details. **pxy** and **pxx**
return the size of the plane in pixels. **celldimy** and **celldimx** return
the size of a cell in pixels (these ought be the same across planes).
**maxbmapy** and **maxbmapx** describe the largest bitmap which can be
displayed in the plane. This function transitively calls
**notcurses_check_pixel_support**, possibly leading to terminal interrogation
(see **notcurses_capabilities(3)** for why this may be undesirable). Any
parameter (save **n** ) may be **NULL** .
2020-01-02 02:23:11 +00:00
# RETURN VALUES
2020-11-15 08:02:44 +00:00
**ncplane_create** and **ncplane_dup** return a new **struct ncplane** on
success, or **NULL** on failure.
2020-01-02 02:23:11 +00:00
2020-03-27 06:06:58 +00:00
**ncplane_userptr** returns the configured user pointer for the ncplane, and
2020-02-10 20:18:28 +00:00
cannot fail.
2020-01-02 02:23:11 +00:00
2020-03-27 06:06:58 +00:00
**ncplane_below** returns the plane below the specified ncplane. If the provided
2020-01-02 02:23:11 +00:00
plane is the bottommost plane, NULL is returned. It cannot fail.
2020-04-06 00:29:30 +00:00
**ncplane_set_scrolling** returns **true** if scrolling was previously enabled,
and **false** otherwise.
2020-12-03 05:25:29 +00:00
**ncpile_top** and **ncpile_bottom** return the topmost and bottommost planes,
respectively, of the pile containing their argument. **notcurses_top** and
**notcurses_bottom** do the same for the standard pile.
2020-04-18 04:09:14 +00:00
**ncplane_at_yx** and **ncplane_at_cursor** return a heap-allocated copy of the
2020-12-13 05:19:24 +00:00
EGC at the relevant cell, or **NULL** if the cell is invalid. The caller should free
2020-04-18 04:09:14 +00:00
this result. **ncplane_at_yx_cell** and **ncplane_at_cursor_cell** instead load
2021-01-04 02:22:38 +00:00
these values into an **nccell** , which is invalidated if the associated plane is
2020-12-13 05:19:24 +00:00
destroyed. The caller should release this **nccell** with **cell_release** .
2020-04-18 04:09:14 +00:00
2021-04-08 08:12:01 +00:00
**ncplane_as_rgba** returns a heap-allocated array of **uint32_t** values,
each representing a single RGBA pixel, or **NULL** on failure.
2020-01-02 02:23:11 +00:00
Functions returning **int** return 0 on success, and non-zero on error.
2020-02-15 23:40:43 +00:00
All other functions cannot fail (and return **void** ).
2020-01-02 02:23:11 +00:00
2020-01-04 12:21:54 +00:00
# NOTES
2020-11-22 07:52:18 +00:00
**ncplane_new** is defined as a deprecated wrapper around **ncplane_create** .
It should not be used in new code.
2021-03-31 12:40:49 +00:00
# BUGS
**ncplane_at_yx** doesn't yet account for bitmap-based graphics (see
**notcurses_visual**).
2020-01-02 02:23:11 +00:00
# SEE ALSO
2021-03-31 12:40:49 +00:00
**notcurses(3)**,
2021-04-10 04:34:38 +00:00
**notcurses_capabilities(3)**,
2021-03-31 12:40:49 +00:00
**notcurses_cell(3)**,
**notcurses_output(3)**,
**notcurses_stdplane(3)**,
**notcurses_visual(3)**