2020-04-24 07:17:34 +00:00
|
|
|
% notcurses_plane(3)
|
2020-01-02 02:23:11 +00:00
|
|
|
% nick black <nickblack@linux.com>
|
2020-04-27 01:25:23 +00:00
|
|
|
% v1.3.3
|
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
|
|
|
|
|
|
|
**struct ncplane* ncplane_new(struct notcurses* nc, int rows, int cols, int yoff, int xoff, void* opaque);**
|
|
|
|
|
2020-03-27 06:06:58 +00:00
|
|
|
**struct ncplane* ncplane_bound(struct ncplane* n, int rows, int cols, int yoff, int xoff, void* opaque);**
|
|
|
|
|
|
|
|
**struct ncplane* ncplane_reparent(struct ncplane* n, struct ncplane* newparent);**
|
|
|
|
|
2020-01-02 02:23:11 +00:00
|
|
|
**struct ncplane* ncplane_aligned(struct ncplane* n, int rows, int cols, int yoff, ncalign_e align, void* opaque);**
|
|
|
|
|
2020-01-15 17:22:10 +00:00
|
|
|
**struct ncplane* ncplane_dup(struct ncplane* n, void* opaque);**
|
|
|
|
|
2020-01-02 02:23:11 +00:00
|
|
|
**int ncplane_resize(struct ncplane* n, int keepy, int keepx, int keepleny, int keeplenx, int yoff, int xoff, int ylen, int xlen);**
|
|
|
|
|
|
|
|
**int ncplane_move_yx(struct ncplane* n, int y, int x);**
|
|
|
|
|
|
|
|
**void ncplane_yx(const struct ncplane* n, int* restrict y, int* restrict x);**
|
|
|
|
|
2020-01-30 13:55:01 +00:00
|
|
|
**int ncplane_set_base_cell(struct ncplane* ncp, const cell* c);**
|
2020-01-02 02:23:11 +00:00
|
|
|
|
2020-04-18 04:09:14 +00:00
|
|
|
**int ncplane_set_base(struct ncplane* ncp, const char* egc, uint32_t attrword, uint64_t channels);**
|
2020-01-30 13:55:01 +00:00
|
|
|
|
|
|
|
**int ncplane_base(struct ncplane* ncp, cell* c);**
|
2020-01-02 02:23:11 +00:00
|
|
|
|
|
|
|
**int ncplane_move_top(struct ncplane* n);**
|
|
|
|
|
|
|
|
**int ncplane_move_bottom(struct ncplane* n);**
|
|
|
|
|
|
|
|
**int ncplane_move_above(struct ncplane* n, struct ncplane* above);**
|
|
|
|
|
|
|
|
**int ncplane_move_below(struct ncplane* n, struct ncplane* below);**
|
|
|
|
|
|
|
|
**struct ncplane* ncplane_below(struct ncplane* n);**
|
|
|
|
|
2020-04-18 04:09:14 +00:00
|
|
|
**char* ncplane_at_cursor(struct ncplane* n, uint32_t* attrword, uint64_t* channels);**
|
2020-01-02 02:23:11 +00:00
|
|
|
|
2020-04-18 04:09:14 +00:00
|
|
|
**int ncplane_at_cursor_cell(struct ncplane* n, cell* c);**
|
|
|
|
|
|
|
|
**char* ncplane_at_yx(struct ncplane* n, int y, int x, uint32_t* attrword, uint64_t* channels);**
|
|
|
|
|
|
|
|
**int ncplane_at_yx_cell(struct ncplane* n, int y, int x, cell* c);**
|
2020-01-02 02:23:11 +00:00
|
|
|
|
2020-05-07 01:40:24 +00:00
|
|
|
**uint32_t* ncplane_rgba(const struct ncplane* nc, int begy, int begx, int leny, int lenx);**
|
|
|
|
|
2020-01-02 02:23:11 +00:00
|
|
|
**void* ncplane_set_userptr(struct ncplane* n, void* opaque);**
|
|
|
|
|
|
|
|
**void* ncplane_userptr(struct ncplane* n);**
|
|
|
|
|
2020-02-19 01:03:20 +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-02-19 01:03:20 +00:00
|
|
|
**static inline int ncplane_dim_y(const struct ncplane* n);**
|
2020-01-04 12:21:54 +00:00
|
|
|
|
2020-02-19 01:03:20 +00:00
|
|
|
**static inline int ncplane_dim_x(const struct ncplane* n);**
|
2020-01-02 02:23:11 +00:00
|
|
|
|
2020-03-15 01:15:19 +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-02-21 11:26:57 +00:00
|
|
|
**void ncplane_translate(const struct ncplane* src, const struct ncplane* dst, int* restrict y, int* restrict x);**
|
|
|
|
|
2020-03-03 06:04:28 +00:00
|
|
|
**bool ncplane_translate_abs(const struct ncplane* n, int* restrict y, int* restrict x);**
|
|
|
|
|
2020-01-12 09:12:43 +00:00
|
|
|
**uint64_t ncplane_channels(struct ncplane* n);**
|
2020-01-04 09:34:29 +00:00
|
|
|
|
2020-01-12 09:12:43 +00:00
|
|
|
**uint32_t ncplane_attr(struct ncplane* n);**
|
2020-01-04 09:34:29 +00:00
|
|
|
|
2020-01-12 09:12:43 +00:00
|
|
|
**static inline unsigned ncplane_bchannel(struct ncplane* nc);**
|
2020-01-04 09:34:29 +00:00
|
|
|
|
2020-01-12 09:12:43 +00:00
|
|
|
**static inline unsigned ncplane_fchannel(struct ncplane* nc);**
|
2020-01-04 09:34:29 +00:00
|
|
|
|
2020-01-12 09:12:43 +00:00
|
|
|
**static inline unsigned ncplane_fg(struct ncplane* nc);**
|
2020-01-04 09:34:29 +00:00
|
|
|
|
2020-01-12 09:12:43 +00:00
|
|
|
**static inline unsigned ncplane_bg(struct ncplane* nc);**
|
2020-01-04 09:34:29 +00:00
|
|
|
|
2020-01-12 09:12:43 +00:00
|
|
|
**static inline unsigned ncplane_fg_alpha(struct ncplane* nc);**
|
2020-01-04 09:34:29 +00:00
|
|
|
|
2020-01-12 09:12:43 +00:00
|
|
|
**static inline unsigned ncplane_bg_alpha(struct ncplane* nc);**
|
2020-01-04 09:34:29 +00:00
|
|
|
|
2020-01-12 09:12:43 +00:00
|
|
|
**static inline unsigned ncplane_fg_rgb(struct ncplane* n, unsigned* r, unsigned* g, unsigned* b);**
|
2020-01-04 09:34:29 +00:00
|
|
|
|
2020-01-12 09:12:43 +00:00
|
|
|
**static inline unsigned ncplane_bg_rgb(struct ncplane* n, unsigned* r, unsigned* g, unsigned* b);**
|
2020-01-04 09:34:29 +00:00
|
|
|
|
2020-01-12 09:12:43 +00:00
|
|
|
**int ncplane_set_fg_rgb(struct ncplane* n, int r, int g, int b);**
|
|
|
|
|
|
|
|
**int ncplane_set_bg_rgb(struct ncplane* n, int r, int g, int b);**
|
|
|
|
|
|
|
|
**void ncplane_set_fg_rgb_clipped(struct ncplane* n, int r, int g, int b);**
|
|
|
|
|
|
|
|
**void ncplane_set_bg_rgb_clipped(struct ncplane* n, int r, int g, int b);**
|
2020-01-04 09:34:29 +00:00
|
|
|
|
|
|
|
**int ncplane_set_fg(struct ncplane* n, unsigned channel);**
|
2020-01-12 09:12:43 +00:00
|
|
|
|
2020-01-04 09:34:29 +00:00
|
|
|
**int ncplane_set_bg(struct ncplane* n, unsigned channel);**
|
|
|
|
|
|
|
|
**void ncplane_set_fg_default(struct ncplane* n);**
|
2020-01-12 09:12:43 +00:00
|
|
|
|
2020-01-04 09:34:29 +00:00
|
|
|
**void ncplane_set_bg_default(struct ncplane* n);**
|
|
|
|
|
2020-01-12 09:12:43 +00:00
|
|
|
**int ncplane_set_fg_alpha(struct ncplane* n, int alpha);**
|
|
|
|
|
|
|
|
**int ncplane_set_bg_alpha(struct ncplane* n, int alpha);**
|
2020-01-04 09:34:29 +00:00
|
|
|
|
2020-01-19 01:42:29 +00:00
|
|
|
**int ncplane_set_fg_palindex(struct ncplane* n, int idx);**
|
|
|
|
|
|
|
|
**int ncplane_set_bg_palindex(struct ncplane* n, int idx);**
|
|
|
|
|
2020-01-04 09:34:29 +00:00
|
|
|
**void ncplane_styles_set(struct ncplane* n, unsigned stylebits);**
|
2020-01-12 09:12:43 +00:00
|
|
|
|
2020-01-04 09:34:29 +00:00
|
|
|
**void ncplane_styles_on(struct ncplane* n, unsigned stylebits);**
|
2020-01-12 09:12:43 +00:00
|
|
|
|
2020-01-04 09:34:29 +00:00
|
|
|
**void ncplane_styles_off(struct ncplane* n, unsigned stylebits);**
|
|
|
|
|
2020-02-19 01:03:20 +00:00
|
|
|
**unsigned ncplane_styles(const struct ncplane* n);**
|
2020-01-04 09:34:29 +00:00
|
|
|
|
2020-01-17 09:31:46 +00:00
|
|
|
**void ncplane_greyscale(struct ncplane* n);**
|
|
|
|
|
2020-02-12 01:36:42 +00:00
|
|
|
**int ncblit_bgrx(struct ncplane* nc, int placey, int placex, int linesize, const unsigned char* data, int begy, int begx, int leny, int lenx);**
|
2020-02-02 07:20:01 +00:00
|
|
|
|
2020-02-12 01:36:42 +00:00
|
|
|
**int ncblit_rgba(struct ncplane* nc, int placey, int placex, int linesize, const unsigned char* data, int begy, int begx, int leny, int lenx);**
|
2020-02-02 07:20:01 +00:00
|
|
|
|
2020-03-05 09:49:56 +00:00
|
|
|
**int ncplane_destroy(struct ncplane* ncp);**
|
|
|
|
|
2020-02-15 23:40:43 +00:00
|
|
|
**void notcurses_drop_planes(struct notcurses* nc);**
|
|
|
|
|
2020-03-21 04:11:45 +00:00
|
|
|
**int ncplane_mergedown(struct ncplane* restrict src, struct ncplane* restrict dst);**
|
|
|
|
|
|
|
|
**void ncplane_erase(struct ncplane* n);**
|
|
|
|
|
2020-04-06 00:29:30 +00:00
|
|
|
**bool ncplane_set_scrolling(struct ncplane* n, bool scrollp);**
|
|
|
|
|
2020-05-04 15:05:52 +00:00
|
|
|
**int ncplane_rotate_cw(struct ncplane* n);**
|
|
|
|
|
|
|
|
**int ncplane_rotate_ccw(struct ncplane* n);**
|
|
|
|
|
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-01-02 02:23:11 +00:00
|
|
|
anywhere. In addition to its framebuffer--a rectilinear matrix of cells
|
|
|
|
(see **notcurses_cell(3)**)--an ncplane is defined by:
|
|
|
|
|
|
|
|
* a base cell, used for any cell on the plane without a glyph,
|
|
|
|
* the egcpool backing its cells,
|
|
|
|
* a current cursor location,
|
|
|
|
* a current style, foreground channel, and background channel,
|
|
|
|
* its geometry,
|
|
|
|
* a configured user pointer,
|
|
|
|
* its position relative to the visible plane, and
|
|
|
|
* its z-index.
|
|
|
|
|
2020-03-27 06:06:58 +00:00
|
|
|
New planes can be created with **ncplane_new**, **ncplane_bound**, and
|
|
|
|
**ncplane_aligned**. If a plane is bound to another, x and y coordinates are
|
|
|
|
relative to the plane to which it is bound, and if that plane moves, all its
|
|
|
|
bound planes move along with it. When a plane is destroyed, all planes bound to
|
|
|
|
it (directly or transitively) are destroyed. **ncplane_reparent** detaches the
|
|
|
|
plane **n** from any plane to which it is bound, and binds it to **newparent**
|
|
|
|
if **newparent** is not **NULL**. All planes bound to **n** move along with it
|
|
|
|
during a reparenting operation.
|
|
|
|
|
|
|
|
**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
|
|
|
|
2020-03-22 21:33:08 +00:00
|
|
|
**ncplane_translate** translates coordinates expressed relative to the plane
|
|
|
|
**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
|
|
|
|
to refer to the standard plane. **ncplane_translate_abs** takes coordinates
|
|
|
|
expressed relative to the standard plane, and returns coordinates relative to
|
|
|
|
**dst**, returning **false** if the coordinates are invalid for **dst**.
|
|
|
|
|
2020-03-21 04:11:45 +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**
|
|
|
|
might see changes. It is an error to merge a plane onto itself.
|
|
|
|
|
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
|
|
|
|
2020-01-02 02:23:11 +00:00
|
|
|
# RETURN VALUES
|
|
|
|
|
2020-03-27 06:06:58 +00:00
|
|
|
**ncplane_new**, **ncplane_bound**, **ncplane_aligned**, and **ncplane_dup**
|
|
|
|
all 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-04-18 04:09:14 +00:00
|
|
|
**ncplane_at_yx** and **ncplane_at_cursor** return a heap-allocated copy of the
|
|
|
|
EGC at the relevant cell, or NULL if the cell is invalid. The caller should free
|
|
|
|
this result. **ncplane_at_yx_cell** and **ncplane_at_cursor_cell** instead load
|
|
|
|
these values into a **cell**, which is invalidated if the associated plane is
|
|
|
|
destroyed. The caller should release this cell with **cell_release**.
|
|
|
|
|
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-01-02 02:23:11 +00:00
|
|
|
# SEE ALSO
|
|
|
|
|
|
|
|
**notcurses(3)**, **notcurses_cell(3)**, **notcurses_output(3)**,
|
|
|
|
**notcurses_stdplane(3)**
|