2020-01-07 22:51:34 +00:00
|
|
|
#ifndef __NCPP_PLANE_HH
|
|
|
|
#define __NCPP_PLANE_HH
|
|
|
|
|
|
|
|
#include <exception>
|
|
|
|
#include <cstdarg>
|
|
|
|
#include <ctime>
|
|
|
|
#include <map>
|
|
|
|
#include <mutex>
|
2020-02-18 17:36:16 +00:00
|
|
|
#include <notcurses/notcurses.h>
|
2020-01-07 22:51:34 +00:00
|
|
|
|
|
|
|
#include "Root.hh"
|
|
|
|
#include "Cell.hh"
|
2020-02-05 22:29:42 +00:00
|
|
|
#include "Reel.hh"
|
2020-01-07 22:51:34 +00:00
|
|
|
#include "CellStyle.hh"
|
|
|
|
#include "NCAlign.hh"
|
|
|
|
#include "NCBox.hh"
|
|
|
|
|
|
|
|
namespace ncpp
|
|
|
|
{
|
|
|
|
class NCPP_API_EXPORT Plane : public Root
|
|
|
|
{
|
|
|
|
public:
|
2020-02-15 22:04:39 +00:00
|
|
|
Plane (Plane const& other)
|
2020-05-24 12:41:18 +00:00
|
|
|
: Root (nullptr)
|
2020-02-15 22:04:39 +00:00
|
|
|
{
|
|
|
|
plane = duplicate_plane (other, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit Plane (Plane const& other, void *opaque)
|
2020-05-24 12:41:18 +00:00
|
|
|
: Root (nullptr)
|
2020-02-15 22:04:39 +00:00
|
|
|
{
|
|
|
|
plane = duplicate_plane (other, opaque);
|
|
|
|
}
|
|
|
|
|
2020-04-11 22:20:11 +00:00
|
|
|
explicit Plane (Plane *n, int rows, int cols, int yoff, int xoff, void *opaque = nullptr)
|
|
|
|
: Plane (static_cast<const Plane*>(n), rows, cols, yoff, xoff, opaque)
|
|
|
|
{}
|
|
|
|
|
|
|
|
explicit Plane (const Plane *n, int rows, int cols, int yoff, int xoff, void *opaque = nullptr)
|
2020-05-24 12:41:18 +00:00
|
|
|
: Root (nullptr)
|
2020-04-11 22:20:11 +00:00
|
|
|
{
|
|
|
|
if (n == nullptr)
|
|
|
|
throw invalid_argument ("'n' must be a valid pointer");
|
|
|
|
|
|
|
|
plane = create_plane (*n, rows, cols, yoff, xoff, opaque);
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit Plane (const Plane &n, int rows, int cols, int yoff, int xoff, void *opaque = nullptr)
|
2020-05-24 12:41:18 +00:00
|
|
|
: Root (nullptr)
|
2020-04-11 22:20:11 +00:00
|
|
|
{
|
|
|
|
plane = create_plane (n, rows, cols, yoff, xoff, opaque);
|
|
|
|
}
|
|
|
|
|
2020-05-24 12:41:18 +00:00
|
|
|
explicit Plane (int rows, int cols, int yoff, int xoff, void *opaque = nullptr, NotCurses *ncinst = nullptr)
|
|
|
|
: Root (ncinst)
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
plane = ncplane_new (
|
|
|
|
get_notcurses (),
|
|
|
|
rows,
|
|
|
|
cols,
|
|
|
|
yoff,
|
|
|
|
xoff,
|
|
|
|
opaque
|
|
|
|
);
|
|
|
|
|
|
|
|
if (plane == nullptr)
|
2020-05-20 04:15:38 +00:00
|
|
|
throw init_error ("Notcurses failed to create a new plane");
|
2020-01-07 22:51:34 +00:00
|
|
|
|
|
|
|
map_plane (plane, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit Plane (Plane &n, int rows, int cols, int yoff, NCAlign align, void *opaque = nullptr)
|
2020-05-24 12:41:18 +00:00
|
|
|
: Root (nullptr)
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
plane = create_plane (n, rows, cols, yoff, align, opaque);
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit Plane (Plane const& n, int rows, int cols, int yoff, NCAlign align, void *opaque = nullptr)
|
2020-05-24 12:41:18 +00:00
|
|
|
: Root (nullptr)
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
plane = create_plane (const_cast<Plane&>(n), rows, cols, yoff, align, opaque);
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit Plane (Plane *n, int rows, int cols, int yoff, NCAlign align, void *opaque = nullptr)
|
2020-05-24 12:41:18 +00:00
|
|
|
: Root (nullptr)
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
if (n == nullptr)
|
2020-02-16 19:25:26 +00:00
|
|
|
throw invalid_argument ("'n' must be a valid pointer");
|
2020-01-07 22:51:34 +00:00
|
|
|
|
|
|
|
plane = create_plane (*n, rows, cols, yoff, align, opaque);
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit Plane (Plane const* n, int rows, int cols, int yoff, NCAlign align, void *opaque = nullptr)
|
2020-05-24 12:41:18 +00:00
|
|
|
: Root (nullptr)
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
if (n == nullptr)
|
2020-02-16 19:25:26 +00:00
|
|
|
throw invalid_argument ("'n' must be a valid pointer");
|
2020-01-07 22:51:34 +00:00
|
|
|
|
|
|
|
plane = create_plane (const_cast<Plane&>(*n), rows, cols, yoff, align, opaque);
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit Plane (ncplane *_plane) noexcept
|
2020-05-24 12:41:18 +00:00
|
|
|
: Root (nullptr),
|
|
|
|
plane (_plane)
|
2020-01-07 22:51:34 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
~Plane () noexcept
|
|
|
|
{
|
|
|
|
if (is_stdplane)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!is_notcurses_stopped ())
|
|
|
|
ncplane_destroy (plane);
|
|
|
|
unmap_plane (this);
|
|
|
|
}
|
|
|
|
|
|
|
|
operator ncplane* () noexcept
|
|
|
|
{
|
|
|
|
return plane;
|
|
|
|
}
|
|
|
|
|
|
|
|
operator ncplane const* () const noexcept
|
|
|
|
{
|
|
|
|
return plane;
|
|
|
|
}
|
|
|
|
|
2020-05-24 08:07:12 +00:00
|
|
|
void center_abs (int *y, int *x) const noexcept
|
|
|
|
{
|
|
|
|
ncplane_center_abs (plane, y, x);
|
2020-05-24 12:41:18 +00:00
|
|
|
}
|
2020-05-24 08:07:12 +00:00
|
|
|
|
2020-05-22 20:11:59 +00:00
|
|
|
ncplane* to_ncplane () noexcept
|
|
|
|
{
|
|
|
|
return plane;
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool resize (int keepy, int keepx, int keepleny, int keeplenx, int yoff, int xoff, int ylen, int xlen) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
int ret = ncplane_resize (
|
2020-01-07 22:51:34 +00:00
|
|
|
plane,
|
|
|
|
keepy,
|
|
|
|
keepx,
|
|
|
|
keepleny,
|
|
|
|
keeplenx,
|
|
|
|
yoff,
|
|
|
|
xoff,
|
|
|
|
ylen,
|
|
|
|
xlen
|
2020-04-12 21:09:03 +00:00
|
|
|
);
|
2020-01-07 22:51:34 +00:00
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ret, -1);
|
2020-04-06 00:29:30 +00:00
|
|
|
}
|
2020-03-22 21:33:08 +00:00
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool pulse (const timespec* ts, fadecb fader, void* curry) const NOEXCEPT_MAYBE
|
|
|
|
{
|
|
|
|
return error_guard (ncplane_pulse (plane, ts, fader, curry), -1);
|
2020-04-06 00:29:30 +00:00
|
|
|
}
|
2020-03-22 21:33:08 +00:00
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int gradient (const char* egc, uint32_t attrword, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr, int ystop, int xstop) const NOEXCEPT_MAYBE
|
2020-02-16 19:25:26 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_gradient (plane, egc, attrword, ul, ur, ll, lr, ystop, xstop), -1);
|
2020-02-16 19:25:26 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int gradient_sized (const char* egc, uint32_t attrword, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr, int ylen, int xlen) const NOEXCEPT_MAYBE
|
2020-02-16 19:25:26 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_gradient_sized (plane, egc, attrword, ul, ur, ll, lr, ylen, xlen), -1);
|
2020-02-16 19:25:26 +00:00
|
|
|
}
|
|
|
|
|
2020-06-05 04:36:42 +00:00
|
|
|
int high_gradient (uint32_t ul, uint32_t ur, uint32_t ll, uint32_t lr, int ylen, int xlen) const NOEXCEPT_MAYBE
|
2020-03-14 23:35:54 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_highgradient (plane, ul, ur, ll, lr, ylen, xlen), -1);
|
2020-03-14 23:35:54 +00:00
|
|
|
}
|
|
|
|
|
2020-06-05 04:36:42 +00:00
|
|
|
int high_gradient_sized (uint32_t ul, uint32_t ur, uint32_t ll, uint32_t lr, int ylen, int xlen) const NOEXCEPT_MAYBE
|
2020-03-14 23:35:54 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_highgradient_sized (plane, ul, ur, ll, lr, ylen, xlen), -1);
|
2020-03-14 23:35:54 +00:00
|
|
|
}
|
|
|
|
|
2020-01-07 22:51:34 +00:00
|
|
|
void greyscale () const noexcept
|
|
|
|
{
|
|
|
|
ncplane_greyscale (plane);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool resize (int ylen, int xlen) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ncplane_resize_simple (plane, ylen, xlen), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool fadeout (timespec *ts, fadecb fader = nullptr, void *curry = nullptr) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
return fadeout (static_cast<const timespec*>(ts), fader, curry);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool fadeout (timespec &ts, fadecb fader = nullptr, void *curry = nullptr) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
return fadeout (&ts, fader, curry);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool fadeout (timespec const& ts, fadecb fader = nullptr, void *curry = nullptr) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
return fadeout (&ts, fader, curry);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool fadeout (const timespec *ts, fadecb fader = nullptr, void *curry = nullptr) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ncplane_fadeout (plane, ts, fader, curry), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool fadein (timespec *ts, fadecb fader = nullptr) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
return fadein (static_cast<const timespec*>(ts), fader);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool fadein (timespec &ts, fadecb fader = nullptr) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
return fadein (&ts, fader);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool fadein (timespec const& ts, fadecb fader = nullptr) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
return fadein (&ts, fader);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool fadein (const timespec *ts, fadecb fader = nullptr, void *curry = nullptr) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ncplane_fadein (plane, ts, fader, curry), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void erase () const noexcept
|
|
|
|
{
|
|
|
|
ncplane_erase (plane);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int get_align (NCAlign align, int c) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_align (plane, static_cast<ncalign_e>(align), c), INT_MAX);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void get_dim (int *rows, int *cols) const noexcept
|
|
|
|
{
|
|
|
|
ncplane_dim_yx (plane, rows, cols);
|
|
|
|
}
|
|
|
|
|
|
|
|
void get_dim (int &rows, int &cols) const noexcept
|
|
|
|
{
|
|
|
|
get_dim (&rows, &cols);
|
|
|
|
}
|
|
|
|
|
|
|
|
int get_dim_x () const noexcept
|
|
|
|
{
|
|
|
|
return ncplane_dim_x (plane);
|
|
|
|
}
|
|
|
|
|
|
|
|
int get_dim_y () const noexcept
|
|
|
|
{
|
|
|
|
return ncplane_dim_y (plane);
|
|
|
|
}
|
|
|
|
|
|
|
|
void get_yx (int *y, int *x) const noexcept
|
|
|
|
{
|
|
|
|
ncplane_yx (plane, y, x);
|
|
|
|
}
|
|
|
|
|
|
|
|
void get_yx (int &y, int &x) const noexcept
|
|
|
|
{
|
|
|
|
get_yx (&y, &x);
|
|
|
|
}
|
|
|
|
|
2020-04-11 22:20:11 +00:00
|
|
|
Plane* reparent (Plane *newparent = nullptr) const noexcept
|
|
|
|
{
|
|
|
|
ncplane *ret = ncplane_reparent (plane, newparent == nullptr ? nullptr : newparent->plane);
|
|
|
|
if (ret == nullptr)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
return map_plane (ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
Plane* reparent (const Plane *newparent) const noexcept
|
|
|
|
{
|
|
|
|
return reparent (const_cast<Plane*>(newparent));
|
|
|
|
}
|
|
|
|
|
|
|
|
Plane* reparent (const Plane &newparent) const noexcept
|
|
|
|
{
|
|
|
|
return reparent (const_cast<Plane*>(&newparent));
|
|
|
|
}
|
|
|
|
|
2020-06-22 19:49:13 +00:00
|
|
|
void home () const noexcept
|
|
|
|
{
|
|
|
|
ncplane_home (plane);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool move (int y, int x) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ncplane_move_yx (plane, y, x), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-05-20 19:32:27 +00:00
|
|
|
void move_top () noexcept
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-05-20 19:32:27 +00:00
|
|
|
ncplane_move_top (plane);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-05-20 19:32:27 +00:00
|
|
|
void move_bottom () noexcept
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-05-20 19:32:27 +00:00
|
|
|
ncplane_move_bottom (plane);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool move_below (Plane &below) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ncplane_move_below (plane, below.plane), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool move_below (Plane *below) const
|
|
|
|
{
|
|
|
|
if (below == nullptr)
|
2020-02-16 19:25:26 +00:00
|
|
|
throw invalid_argument ("'below' must be a valid pointer");
|
2020-01-07 22:51:34 +00:00
|
|
|
|
|
|
|
return move_below (*below);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool move_above (Plane &above) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ncplane_move_above (plane, above.plane), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool move_above (Plane *above) const
|
|
|
|
{
|
|
|
|
if (above == nullptr)
|
2020-02-16 19:25:26 +00:00
|
|
|
throw invalid_argument ("'above' must be a valid pointer");
|
2020-01-07 22:51:34 +00:00
|
|
|
|
|
|
|
return move_above (*above);
|
|
|
|
}
|
|
|
|
|
2020-03-21 21:35:41 +00:00
|
|
|
bool mergedown (Plane &dst) const
|
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return mergedown (&dst);
|
2020-03-21 21:35:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool mergedown (Plane *dst) const
|
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
if (dst != nullptr && plane == dst->plane)
|
|
|
|
throw invalid_argument ("'dst' must refer to a differnt plane than the one this method is called on");
|
|
|
|
|
|
|
|
return error_guard (ncplane_mergedown (plane, dst != nullptr ? dst->plane : nullptr), -1);
|
2020-03-21 21:35:41 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool cursor_move (int y, int x) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ncplane_cursor_move_yx (plane, y, x), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void get_cursor_yx (int *y, int *x) const noexcept
|
|
|
|
{
|
|
|
|
ncplane_cursor_yx (plane, y, x);
|
|
|
|
}
|
|
|
|
|
|
|
|
void get_cursor_yx (int &y, int &x) const noexcept
|
|
|
|
{
|
|
|
|
get_cursor_yx (&y, &x);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int putc (const Cell &c) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_putc (plane, c), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int putc (const Cell *c) const
|
|
|
|
{
|
|
|
|
if (c == nullptr)
|
2020-02-16 19:25:26 +00:00
|
|
|
throw invalid_argument ("'c' must be a valid pointer");
|
2020-01-07 22:51:34 +00:00
|
|
|
|
|
|
|
return putc (*c);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int putc (int y, int x, Cell const& c) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_putc_yx (plane, y, x, c), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int putc (int y, int x, Cell const* c) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
if (c == nullptr)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return putc (y, x, *c);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int putc (char c, bool retain_styling = false) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
int ret;
|
|
|
|
if (retain_styling) {
|
|
|
|
ret = ncplane_putsimple_stainable (plane, c);
|
|
|
|
} else {
|
|
|
|
ret = ncplane_putsimple (plane, c);
|
|
|
|
}
|
|
|
|
|
|
|
|
return error_guard<int> (ret, -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int putc (int y, int x, char c) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_putsimple_yx (plane, y, x, c), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int putc (const char *gclust, int *sbytes = nullptr, bool retain_styling = false) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
int ret;
|
|
|
|
if (retain_styling) {
|
|
|
|
ret = ncplane_putegc_stainable (plane, gclust, sbytes);
|
|
|
|
} else {
|
|
|
|
ret = ncplane_putegc (plane, gclust, sbytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
return error_guard<int> (ret, -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int putc (int y, int x, const char *gclust, int *sbytes = nullptr) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_putegc_yx (plane, y, x, gclust, sbytes), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int putc (const wchar_t *gclust, int *sbytes = nullptr, bool retain_styling = false) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
int ret;
|
|
|
|
if (retain_styling) {
|
|
|
|
ret = ncplane_putwegc_stainable (plane, gclust, sbytes);
|
|
|
|
} else {
|
|
|
|
ret = ncplane_putwegc (plane, gclust, sbytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
return error_guard<int> (ret, -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int putc (int y, int x, const wchar_t *gclust, int *sbytes = nullptr) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_putwegc_yx (plane, y, x, gclust, sbytes), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// OK, this is ugly, but we need to rename this overload or calls similar to n->putc (0, 0, '0') will be
|
|
|
|
// considered ambiguous with the above `putc (int, int, char)` overload.
|
2020-04-12 21:09:03 +00:00
|
|
|
int putcw (int y, int x, wchar_t w) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_putwc_yx (plane, y, x, w), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Ditto
|
2020-04-12 21:09:03 +00:00
|
|
|
int putcw (wchar_t w) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_putwc (plane, w), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int putstr (const char *gclustarr) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
int ret = ncplane_putstr (plane, gclustarr);
|
|
|
|
return error_guard_cond<int> (ret, ret < 0);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int putstr (int y, int x, const char *gclustarr) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
int ret = ncplane_putstr_yx (plane, y, x, gclustarr);
|
|
|
|
return error_guard_cond<int> (ret, ret < 0);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int putstr (int y, NCAlign atype, const char *s) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_putstr_aligned (plane, y, static_cast<ncalign_e>(atype), s), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int putstr (const wchar_t *gclustarr) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_putwstr (plane, gclustarr), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int putstr (int y, int x, const wchar_t *gclustarr) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_putwstr_yx (plane, y, x, gclustarr), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int putstr (int y, NCAlign atype, const wchar_t *gclustattr) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_putwstr_aligned (plane, y, static_cast<ncalign_e>(atype), gclustattr), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-07-31 20:59:59 +00:00
|
|
|
int putstr_stainable (const char* s) const NOEXCEPT_MAYBE
|
|
|
|
{
|
|
|
|
int ret = ncplane_putstr_stainable (plane, s);
|
|
|
|
return error_guard_cond<int> (ret, ret < 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int printf_stainable (const char* format, ...) const NOEXCEPT_MAYBE
|
|
|
|
__attribute__ ((format (printf, 2, 3)))
|
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
|
|
|
|
va_start (va, format);
|
|
|
|
int ret = ncplane_vprintf_stainable (plane, format, va);
|
|
|
|
va_end (va);
|
|
|
|
|
|
|
|
return error_guard<int> (ret, -1);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int printf (const char* format, ...) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
__attribute__ ((format (printf, 2, 3)))
|
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
|
|
|
|
va_start (va, format);
|
|
|
|
int ret = ncplane_vprintf (plane, format, va);
|
|
|
|
va_end (va);
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ret, -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int printf (int y, int x, const char *format, ...) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
__attribute__ ((format (printf, 4, 5)))
|
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
|
|
|
|
va_start (va, format);
|
|
|
|
int ret = ncplane_vprintf_yx (plane, y, x, format, va);
|
|
|
|
va_end (va);
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ret, -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int printf (int y, NCAlign align, const char *format, ...) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
__attribute__ ((format (printf, 4, 5)))
|
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
|
|
|
|
va_start (va, format);
|
|
|
|
int ret = vprintf (y, align, format, va);
|
|
|
|
va_end (va);
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ret, -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-07-31 20:59:59 +00:00
|
|
|
int vprintf_stainable (const char* format, va_list ap) const NOEXCEPT_MAYBE
|
|
|
|
{
|
|
|
|
return error_guard<int> (ncplane_vprintf_stainable (plane, format, ap), -1);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int vprintf (const char* format, va_list ap) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_vprintf (plane, format, ap), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int vprintf (int y, int x, const char* format, va_list ap) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_vprintf_yx (plane, y, x, format, ap), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int vprintf (int y, NCAlign align, const char *format, va_list ap) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_vprintf_aligned (plane, y, static_cast<ncalign_e>(align), format, ap), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int hline (const Cell &c, int len) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_hline (plane, c, len), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int hline (const Cell &c, int len, uint64_t c1, uint64_t c2) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_hline_interp (plane, c, len, c1, c2), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int vline (const Cell &c, int len) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_vline (plane, c, len), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int vline (const Cell &c, int len, uint64_t c1, uint64_t c2) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_vline_interp (plane, c, len, c1, c2), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool load_box (uint32_t attrs, uint64_t channels, Cell &ul, Cell &ur, Cell &ll, Cell &lr, Cell &hl, Cell &vl, const char *gclusters) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (cells_load_box (plane, attrs, channels, ul, ur, ll, lr, hl, vl, gclusters), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool load_box (CellStyle style, uint64_t channels, Cell &ul, Cell &ur, Cell &ll, Cell &lr, Cell &hl, Cell &vl, const char *gclusters) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
return load_box (static_cast<uint32_t>(style), channels, ul, ur, ll, lr, hl, vl, gclusters);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool load_rounded_box (uint32_t attr, uint64_t channels, Cell &ul, Cell &ur, Cell &ll, Cell &lr, Cell &hl, Cell &vl) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (cells_rounded_box (plane, attr, channels, ul, ur, ll, lr, hl, vl), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool load_rounded_box (CellStyle style, uint64_t channels, Cell &ul, Cell &ur, Cell &ll, Cell &lr, Cell &hl, Cell &vl) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
return load_rounded_box (static_cast<uint32_t>(style), channels, ul, ur, ll, lr, hl, vl);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool load_double_box (uint32_t attr, uint64_t channels, Cell &ul, Cell &ur, Cell &ll, Cell &lr, Cell &hl, Cell &vl) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (cells_double_box (plane, attr, channels, ul, ur, ll, lr, hl, vl), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool load_double_box (CellStyle style, uint64_t channels, Cell &ul, Cell &ur, Cell &ll, Cell &lr, Cell &hl, Cell &vl) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
return load_double_box (static_cast<uint32_t>(style), channels, ul, ur, ll, lr, hl, vl);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool box (const Cell &ul, const Cell &ur, const Cell &ll, const Cell &lr,
|
2020-04-18 04:09:14 +00:00
|
|
|
const Cell &hline, const Cell &vline, int ystop, int xstop,
|
|
|
|
unsigned ctlword) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ncplane_box (plane, ul, ur, ll, lr, hline, vline, ystop, xstop, ctlword), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool box_sized (const Cell &ul, const Cell &ur, const Cell &ll, const Cell &lr,
|
|
|
|
const Cell &hline, const Cell &vline, int ylen, int xlen,
|
2020-04-12 21:09:03 +00:00
|
|
|
unsigned ctlword) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ncplane_box_sized (plane, ul, ur, ll, lr, hline, vline, ylen, xlen, ctlword), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool rounded_box (uint32_t attr, uint64_t channels, int ystop, int xstop, unsigned ctlword) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ncplane_rounded_box (plane, attr, channels, ystop, xstop, ctlword), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool rounded_box_sized (uint32_t attr, uint64_t channels, int ylen, int xlen, unsigned ctlword) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ncplane_rounded_box_sized (plane, attr, channels, ylen, xlen, ctlword), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool double_box (uint32_t attr, uint64_t channels, int ystop, int xstop, unsigned ctlword) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ncplane_double_box (plane, attr, channels, ystop, xstop, ctlword), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool double_box_sized (uint32_t attr, uint64_t channels, int ylen, int xlen, unsigned ctlword) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ncplane_double_box_sized (plane, attr, channels, ylen, xlen, ctlword), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool perimeter (const Cell &ul, const Cell &ur, const Cell &ll, const Cell &lr, const Cell &hline, const Cell &vline, unsigned ctlword) const NOEXCEPT_MAYBE
|
2020-02-15 22:04:39 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ncplane_perimeter (plane, ul, ur, ll, lr, hline, vline, ctlword), -1);
|
2020-02-15 22:04:39 +00:00
|
|
|
}
|
|
|
|
|
2020-06-22 19:49:13 +00:00
|
|
|
bool perimeter_rounded (uint32_t attrword, uint64_t channels, unsigned ctlword) const NOEXCEPT_MAYBE
|
|
|
|
{
|
|
|
|
return error_guard (ncplane_perimeter_rounded (plane, attrword, channels, ctlword), -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool perimeter_double (uint32_t attrword, uint64_t channels, unsigned ctlword) const NOEXCEPT_MAYBE
|
|
|
|
{
|
|
|
|
return error_guard (ncplane_perimeter_double (plane, attrword, channels, ctlword), -1);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int polyfill (int y, int x, const Cell& c) const NOEXCEPT_MAYBE
|
2020-02-15 22:04:39 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_polyfill_yx (plane, y, x, c), -1);
|
2020-02-15 22:04:39 +00:00
|
|
|
}
|
|
|
|
|
2020-06-06 09:11:45 +00:00
|
|
|
uint32_t* rgba(ncblitter_e blit, int begy, int begx, int leny, int lenx) const noexcept
|
2020-05-08 23:45:47 +00:00
|
|
|
{
|
2020-06-06 09:11:45 +00:00
|
|
|
return ncplane_rgba (plane, blit, begy, begx, leny, lenx);
|
2020-05-08 23:45:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
char* content(int begy, int begx, int leny, int lenx) const noexcept
|
|
|
|
{
|
|
|
|
return ncplane_contents (plane, begy, begx, leny, lenx);
|
|
|
|
}
|
|
|
|
|
2020-01-07 22:51:34 +00:00
|
|
|
uint64_t get_channels () const noexcept
|
|
|
|
{
|
|
|
|
return ncplane_channels (plane);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t get_attr () const noexcept
|
|
|
|
{
|
|
|
|
return ncplane_attr (plane);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned get_bchannel () const noexcept
|
|
|
|
{
|
|
|
|
return ncplane_bchannel (plane);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned get_fchannel () const noexcept
|
|
|
|
{
|
|
|
|
return ncplane_fchannel (plane);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned get_fg () const noexcept
|
|
|
|
{
|
|
|
|
return ncplane_fg (plane);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned get_bg () const noexcept
|
|
|
|
{
|
|
|
|
return ncplane_bg (plane);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned get_fg_alpha () const noexcept
|
|
|
|
{
|
|
|
|
return ncplane_fg_alpha (plane);
|
|
|
|
}
|
|
|
|
|
2020-05-24 08:07:12 +00:00
|
|
|
void set_channels (uint64_t channels) const noexcept
|
|
|
|
{
|
|
|
|
ncplane_set_channels (plane, channels);
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_attr (uint32_t attrword) const noexcept
|
|
|
|
{
|
|
|
|
ncplane_set_attr (plane, attrword);
|
|
|
|
}
|
|
|
|
|
2020-07-31 20:59:59 +00:00
|
|
|
bool set_fg_alpha (unsigned alpha) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ncplane_set_fg_alpha (plane, alpha), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned get_bg_alpha () const noexcept
|
|
|
|
{
|
|
|
|
return ncplane_bg_alpha (plane);
|
|
|
|
}
|
|
|
|
|
2020-07-31 20:59:59 +00:00
|
|
|
bool set_bg_alpha (unsigned alpha) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ncplane_set_bg_alpha (plane, alpha), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned get_fg_rgb (unsigned *r, unsigned *g, unsigned *b) const noexcept
|
|
|
|
{
|
|
|
|
return ncplane_fg_rgb (plane, r, g, b);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool set_fg_rgb (int r, int g, int b, bool clipped = false) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
if (clipped) {
|
|
|
|
ncplane_set_fg_rgb_clipped (plane, r, g, b);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ncplane_set_fg_rgb (plane, r, g, b), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool set_fg_palindex (int idx) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ncplane_set_fg_palindex (plane, idx), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool set_fg (uint32_t channel) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ncplane_set_fg (plane, channel), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void set_fg_default () const noexcept
|
|
|
|
{
|
|
|
|
ncplane_set_fg_default (plane);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned get_bg_rgb (unsigned *r, unsigned *g, unsigned *b) const noexcept
|
|
|
|
{
|
|
|
|
return ncplane_bg_rgb (plane, r, g, b);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool set_bg_rgb (int r, int g, int b, bool clipped = false) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
if (clipped) {
|
|
|
|
ncplane_set_fg_rgb_clipped (plane, r, g, b);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ncplane_set_bg_rgb (plane, r, g, b), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool set_bg_palindex (int idx) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ncplane_set_bg_alpha (plane, idx), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool set_bg (uint32_t channel) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (ncplane_set_bg (plane, channel), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void set_bg_default () const noexcept
|
|
|
|
{
|
|
|
|
ncplane_set_bg_default (plane);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool set_scrolling (bool scrollp) const noexcept
|
2020-04-06 00:29:30 +00:00
|
|
|
{
|
|
|
|
return ncplane_set_scrolling (plane, scrollp);
|
|
|
|
}
|
|
|
|
|
2020-01-07 22:51:34 +00:00
|
|
|
void styles_set (CellStyle styles) const noexcept
|
|
|
|
{
|
|
|
|
ncplane_styles_set (plane, static_cast<unsigned>(styles));
|
|
|
|
}
|
|
|
|
|
|
|
|
void styles_on (CellStyle styles) const noexcept
|
|
|
|
{
|
|
|
|
ncplane_styles_on (plane, static_cast<unsigned>(styles));
|
|
|
|
}
|
|
|
|
|
|
|
|
void styles_off (CellStyle styles) const noexcept
|
|
|
|
{
|
|
|
|
ncplane_styles_off (plane, static_cast<unsigned>(styles));
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int format (int ystop, int xstop, uint32_t attrword) const NOEXCEPT_MAYBE
|
2020-02-22 19:01:52 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_format (plane, ystop, xstop, attrword), -1);
|
2020-02-22 19:01:52 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int stain (int ystop, int xstop, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr) const NOEXCEPT_MAYBE
|
2020-02-22 19:01:52 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (ncplane_stain (plane, ystop, xstop, ul, ur, ll, lr), -1);
|
2020-02-22 19:01:52 +00:00
|
|
|
}
|
|
|
|
|
2020-01-07 22:51:34 +00:00
|
|
|
Plane* get_below () const noexcept
|
|
|
|
{
|
|
|
|
return map_plane (ncplane_below (plane));
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool set_base_cell (Cell &c) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
bool ret = ncplane_set_base_cell (plane, c) < 0;
|
|
|
|
return error_guard_cond<bool, bool> (ret, ret);
|
2020-01-30 13:55:01 +00:00
|
|
|
}
|
|
|
|
|
2020-04-18 04:09:14 +00:00
|
|
|
bool set_base (const char* egc, uint32_t attrword, uint64_t channels) const NOEXCEPT_MAYBE
|
2020-01-30 13:55:01 +00:00
|
|
|
{
|
2020-04-18 04:09:14 +00:00
|
|
|
bool ret = ncplane_set_base (plane, egc, attrword, channels) < 0;
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard_cond<bool, bool> (ret, ret);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool get_base (Cell &c) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
bool ret = ncplane_base (plane, c) < 0;
|
|
|
|
return error_guard_cond<bool, bool> (ret, ret);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool at_cursor (Cell &c) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-18 04:09:14 +00:00
|
|
|
bool ret = ncplane_at_cursor_cell (plane, c) < 0;
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard_cond<bool, bool> (ret, ret);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool at_cursor (Cell *c) const noexcept
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
if (c == nullptr)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return at_cursor (*c);
|
|
|
|
}
|
|
|
|
|
2020-04-18 04:09:14 +00:00
|
|
|
char* at_cursor (uint32_t* attrword, uint64_t* channels) const
|
|
|
|
{
|
|
|
|
if (attrword == nullptr || channels == nullptr)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
return ncplane_at_cursor (plane, attrword, channels);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int get_at (int y, int x, Cell &c) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-18 04:09:14 +00:00
|
|
|
return error_guard<int> (ncplane_at_yx_cell (plane, y, x, c), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int get_at (int y, int x, Cell *c) const
|
|
|
|
{
|
|
|
|
if (c == nullptr)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return get_at (y, x, *c);
|
|
|
|
}
|
|
|
|
|
2020-04-18 04:09:14 +00:00
|
|
|
char* get_at (int y, int x, uint32_t* attrword, uint64_t* channels) const
|
|
|
|
{
|
|
|
|
if (attrword == nullptr || channels == nullptr)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
return ncplane_at_yx (plane, y, x, attrword, channels);
|
|
|
|
}
|
|
|
|
|
2020-01-07 22:51:34 +00:00
|
|
|
void* set_userptr (void *opaque) const noexcept
|
|
|
|
{
|
|
|
|
return ncplane_set_userptr (plane, opaque);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
T* set_userptr (T *opaque) const noexcept
|
|
|
|
{
|
|
|
|
return static_cast<T*>(set_userptr (static_cast<void*>(opaque)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void* get_userptr () const noexcept
|
|
|
|
{
|
|
|
|
return ncplane_userptr (plane);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
T* get_userptr () const noexcept
|
|
|
|
{
|
|
|
|
return static_cast<T*>(get_userptr ());
|
|
|
|
}
|
|
|
|
|
Tons of work on ncreel (#776)
Tons of work on ncreel (#627, #749, #694)
Improve reel demo: get input wired up once more, avoid the FPS demo at bottom, print pointer and line count in each tablet, use new ncreel API. Improve notcurses-ncreel explorer: kill memory leaks (#694), draw tablets better, use new ncreel API. Fix bug in ncreel core where cruft could be left on the screen, via a very gross brute force algorithm. I'll likely come back and make this a bit less ghastly in the future #749. Remove weird one-off input system from ncreel, residue from outcurses. Make some of the normalizing changes speced out in #627
* ncreel: give each tablet an index, and print it #749
* reel: eliminate FIXME + param to insert_tabler() #749
* ncreel: label tablets with their adress to correlate against debugging logs #749
* more terminal environment variable notes
* TERMS.md: add Sakura, st
* ncreel: move legend out of reel proper
* ncreel_options: dump min/max_supported_rows/cols #627
* ncreel: remove weird one-off input layer #627
* ncreel: add ncreel_offer_input()
* reel demo: call demo_getc()
* reel demo: rig up input to demo main
* ncreel: drop ncreel_del_focused(), properly bind tablets
* reel demo: don't free up necessary plane
* ncreel: don't pull absolute locations of tablets
* ncreel: place tablets correctly in boundrel
* reel demo: add back support for left/right
* reel demo: restore thread movement
* ncreel: remove a great deal of complexity
* reel demo: stay out of FPS graph's way
* ncreel: give each tablet an index, and print it #749
* reel: eliminate FIXME + param to insert_tabler() #749
* ncreel: label tablets with their adress to correlate against debugging logs #749
* ncreel: move legend out of reel proper
* ncreel_options: dump min/max_supported_rows/cols #627
* ncreel: remove weird one-off input layer #627
* ncreel: add ncreel_offer_input()
* reel demo: call demo_getc()
* reel demo: rig up input to demo main
* ncreel: drop ncreel_del_focused(), properly bind tablets
* reel demo: don't free up necessary plane
* ncreel: don't pull absolute locations of tablets
* ncreel: place tablets correctly in boundrel
* reel demo: add back support for left/right
* reel demo: restore thread movement
* ncreel: remove a great deal of complexity
* reel demo: stay out of FPS graph's way
* reel: tighten up reel following redraw
* reel: fix upper-left corner of topless perimeter
* ncreel: print linecount, return clipped value
* reel: draw focused tablet relative to reel
* reel: brute force decruftification, how embarrassing #749
2020-07-09 06:02:23 +00:00
|
|
|
NcReel* ncreel_create (const ncreel_options *popts = nullptr) const
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
Tons of work on ncreel (#776)
Tons of work on ncreel (#627, #749, #694)
Improve reel demo: get input wired up once more, avoid the FPS demo at bottom, print pointer and line count in each tablet, use new ncreel API. Improve notcurses-ncreel explorer: kill memory leaks (#694), draw tablets better, use new ncreel API. Fix bug in ncreel core where cruft could be left on the screen, via a very gross brute force algorithm. I'll likely come back and make this a bit less ghastly in the future #749. Remove weird one-off input system from ncreel, residue from outcurses. Make some of the normalizing changes speced out in #627
* ncreel: give each tablet an index, and print it #749
* reel: eliminate FIXME + param to insert_tabler() #749
* ncreel: label tablets with their adress to correlate against debugging logs #749
* more terminal environment variable notes
* TERMS.md: add Sakura, st
* ncreel: move legend out of reel proper
* ncreel_options: dump min/max_supported_rows/cols #627
* ncreel: remove weird one-off input layer #627
* ncreel: add ncreel_offer_input()
* reel demo: call demo_getc()
* reel demo: rig up input to demo main
* ncreel: drop ncreel_del_focused(), properly bind tablets
* reel demo: don't free up necessary plane
* ncreel: don't pull absolute locations of tablets
* ncreel: place tablets correctly in boundrel
* reel demo: add back support for left/right
* reel demo: restore thread movement
* ncreel: remove a great deal of complexity
* reel demo: stay out of FPS graph's way
* ncreel: give each tablet an index, and print it #749
* reel: eliminate FIXME + param to insert_tabler() #749
* ncreel: label tablets with their adress to correlate against debugging logs #749
* ncreel: move legend out of reel proper
* ncreel_options: dump min/max_supported_rows/cols #627
* ncreel: remove weird one-off input layer #627
* ncreel: add ncreel_offer_input()
* reel demo: call demo_getc()
* reel demo: rig up input to demo main
* ncreel: drop ncreel_del_focused(), properly bind tablets
* reel demo: don't free up necessary plane
* ncreel: don't pull absolute locations of tablets
* ncreel: place tablets correctly in boundrel
* reel demo: add back support for left/right
* reel demo: restore thread movement
* ncreel: remove a great deal of complexity
* reel demo: stay out of FPS graph's way
* reel: tighten up reel following redraw
* reel: fix upper-left corner of topless perimeter
* ncreel: print linecount, return clipped value
* reel: draw focused tablet relative to reel
* reel: brute force decruftification, how embarrassing #749
2020-07-09 06:02:23 +00:00
|
|
|
return new NcReel (this, popts);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Some Cell APIs go here since they act on individual panels even though it may seem weird at points (e.g.
|
|
|
|
// release)
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int load (Cell &cell, const char *gcluster) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (cell_load (plane, cell, gcluster), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool load (Cell &cell, char ch) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard (cell_load_simple (plane, cell, ch), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int prime (Cell &cell, const char *gcluster, uint32_t attr, uint64_t channels) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (cell_prime (plane, cell, gcluster, attr, channels), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void release (Cell &cell) const noexcept
|
|
|
|
{
|
|
|
|
cell_release (plane, cell);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int duplicate (Cell &target, Cell &source) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (cell_duplicate (plane, target, source), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
int duplicate (Cell &target, Cell const& source) const NOEXCEPT_MAYBE
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<int> (cell_duplicate (plane, target, source), -1);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int duplicate (Cell &target, Cell *source) const
|
|
|
|
{
|
|
|
|
if (source == nullptr)
|
2020-02-16 19:25:26 +00:00
|
|
|
throw invalid_argument ("'source' must be a valid pointer");
|
2020-01-07 22:51:34 +00:00
|
|
|
|
|
|
|
return duplicate (target, *source);
|
|
|
|
}
|
|
|
|
|
|
|
|
int duplicate (Cell &target, Cell const* source) const
|
|
|
|
{
|
|
|
|
if (source == nullptr)
|
2020-02-16 19:25:26 +00:00
|
|
|
throw invalid_argument ("'source' must be a valid pointer");
|
2020-01-07 22:51:34 +00:00
|
|
|
|
|
|
|
return duplicate (target, *source);
|
|
|
|
}
|
|
|
|
|
|
|
|
int duplicate (Cell *target, Cell *source) const
|
|
|
|
{
|
|
|
|
if (target == nullptr)
|
2020-02-16 19:25:26 +00:00
|
|
|
throw invalid_argument ("'target' must be a valid pointer");
|
2020-01-07 22:51:34 +00:00
|
|
|
if (source == nullptr)
|
2020-02-16 19:25:26 +00:00
|
|
|
throw invalid_argument ("'source' must be a valid pointer");
|
2020-01-07 22:51:34 +00:00
|
|
|
|
|
|
|
return duplicate (*target, *source);
|
|
|
|
}
|
|
|
|
|
|
|
|
int duplicate (Cell *target, Cell const* source) const
|
|
|
|
{
|
|
|
|
if (target == nullptr)
|
2020-02-16 19:25:26 +00:00
|
|
|
throw invalid_argument ("'target' must be a valid pointer");
|
2020-01-07 22:51:34 +00:00
|
|
|
if (source == nullptr)
|
2020-02-16 19:25:26 +00:00
|
|
|
throw invalid_argument ("'source' must be a valid pointer");
|
2020-01-07 22:51:34 +00:00
|
|
|
|
|
|
|
return duplicate (*target, *source);
|
|
|
|
}
|
|
|
|
|
|
|
|
int duplicate (Cell *target, Cell &source) const
|
|
|
|
{
|
|
|
|
if (target == nullptr)
|
2020-02-16 19:25:26 +00:00
|
|
|
throw invalid_argument ("'target' must be a valid pointer");
|
2020-01-07 22:51:34 +00:00
|
|
|
|
|
|
|
return duplicate (*target, source);
|
|
|
|
}
|
|
|
|
|
|
|
|
int duplicate (Cell *target, Cell const& source) const
|
|
|
|
{
|
|
|
|
if (target == nullptr)
|
2020-02-16 19:25:26 +00:00
|
|
|
throw invalid_argument ("'target' must be a valid pointer");
|
2020-01-07 22:51:34 +00:00
|
|
|
|
|
|
|
return duplicate (*target, source);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
void translate (const Plane *dst, int *y = nullptr, int *x = nullptr) const noexcept
|
2020-02-22 19:01:52 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
ncplane_translate (*this, dst ? dst->plane: nullptr, y, x);
|
2020-02-22 19:01:52 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
void translate (const Plane &dst, int *y = nullptr, int *x = nullptr) const noexcept
|
2020-02-22 19:01:52 +00:00
|
|
|
{
|
|
|
|
translate (*this, dst, y, x);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void translate (const Plane *src, const Plane *dst, int *y = nullptr, int *x = nullptr)
|
|
|
|
{
|
|
|
|
if (src == nullptr)
|
|
|
|
throw invalid_argument ("'src' must be a valid pointer");
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
ncplane_translate (*src, dst ? dst->plane : nullptr, y, x);
|
2020-02-22 19:01:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void translate (const Plane &src, const Plane &dst, int *y = nullptr, int *x = nullptr) noexcept
|
|
|
|
{
|
|
|
|
ncplane_translate (src.plane, dst.plane, y, x);
|
|
|
|
}
|
|
|
|
|
2020-04-12 21:09:03 +00:00
|
|
|
bool translate_abs (int *y = nullptr, int *x = nullptr) const noexcept
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard<bool, bool> (ncplane_translate_abs (plane, y, x), false);
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2020-05-04 15:05:52 +00:00
|
|
|
bool rotate_cw () const NOEXCEPT_MAYBE
|
|
|
|
{
|
|
|
|
return error_guard (ncplane_rotate_cw (plane), -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool rotate_ccw () const noexcept
|
|
|
|
{
|
|
|
|
return error_guard (ncplane_rotate_ccw (plane), -1);
|
|
|
|
}
|
|
|
|
|
2020-01-07 22:51:34 +00:00
|
|
|
const char* get_extended_gcluster (Cell &cell) const noexcept
|
|
|
|
{
|
|
|
|
return cell_extended_gcluster (plane, cell);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* get_extended_gcluster (Cell const& cell) const noexcept
|
|
|
|
{
|
|
|
|
return cell_extended_gcluster (plane, cell);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Plane* map_plane (ncplane *ncp, Plane *associated_plane = nullptr) noexcept;
|
|
|
|
|
2020-06-05 07:47:13 +00:00
|
|
|
bool blit_bgrx (const void* data, int linesize, const struct ncvisual_options *vopts) const NOEXCEPT_MAYBE
|
2020-02-15 22:04:39 +00:00
|
|
|
{
|
2020-06-05 07:47:13 +00:00
|
|
|
bool ret = ncblit_bgrx (data, linesize, vopts) < 0;
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard_cond<bool, bool> (ret, ret);
|
2020-02-15 22:04:39 +00:00
|
|
|
}
|
|
|
|
|
2020-06-05 07:47:13 +00:00
|
|
|
bool blit_rgba (const void* data, int linesize, const struct ncvisual_options *vopts) const NOEXCEPT_MAYBE
|
2020-02-15 22:04:39 +00:00
|
|
|
{
|
2020-06-05 07:47:13 +00:00
|
|
|
bool ret = ncblit_rgba (data, linesize, vopts) < 0;
|
2020-04-12 21:09:03 +00:00
|
|
|
return error_guard_cond<bool, bool> (ret, ret);
|
2020-02-15 22:04:39 +00:00
|
|
|
}
|
2020-05-02 21:01:21 +00:00
|
|
|
|
2020-06-14 02:24:50 +00:00
|
|
|
int qrcode (ncblitter_e blitter, int* ymax, int* xmax, const void *data, size_t len) const NOEXCEPT_MAYBE
|
2020-05-02 21:01:21 +00:00
|
|
|
{
|
2020-06-14 02:24:50 +00:00
|
|
|
int ret = ncplane_qrcode (plane, blitter, ymax, xmax, data, len);
|
2020-05-02 21:01:21 +00:00
|
|
|
return error_guard_cond<int> (ret, ret < 0);
|
|
|
|
}
|
|
|
|
|
2020-06-22 19:49:13 +00:00
|
|
|
bool is_fg_default () const noexcept
|
|
|
|
{
|
|
|
|
return ncplane_fg_default_p (plane);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool is_bg_default () const noexcept
|
|
|
|
{
|
|
|
|
return ncplane_bg_default_p (plane);
|
|
|
|
}
|
|
|
|
|
2020-01-07 22:51:34 +00:00
|
|
|
protected:
|
|
|
|
explicit Plane (ncplane *_plane, bool _is_stdplane)
|
2020-05-24 12:41:18 +00:00
|
|
|
: Root (nullptr),
|
|
|
|
plane (_plane),
|
|
|
|
is_stdplane (_is_stdplane)
|
2020-01-07 22:51:34 +00:00
|
|
|
{
|
|
|
|
if (_plane == nullptr)
|
2020-02-16 19:25:26 +00:00
|
|
|
throw invalid_argument ("_plane must be a valid pointer");
|
2020-01-07 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void unmap_plane (Plane *p) noexcept;
|
|
|
|
|
|
|
|
private:
|
2020-04-11 22:20:11 +00:00
|
|
|
ncplane* create_plane (const Plane &n, int rows, int cols, int yoff, int xoff, void *opaque)
|
|
|
|
{
|
|
|
|
ncplane *ret = ncplane_bound (
|
|
|
|
n.plane,
|
|
|
|
rows,
|
|
|
|
cols,
|
|
|
|
yoff,
|
|
|
|
xoff,
|
|
|
|
opaque
|
|
|
|
);
|
|
|
|
|
|
|
|
if (ret == nullptr)
|
2020-05-20 04:15:38 +00:00
|
|
|
throw init_error ("Notcurses failed to create a new plane");
|
2020-04-11 22:20:11 +00:00
|
|
|
|
|
|
|
map_plane (plane, this);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-01-07 22:51:34 +00:00
|
|
|
ncplane* create_plane (Plane &n, int rows, int cols, int yoff, NCAlign align, void *opaque)
|
|
|
|
{
|
|
|
|
ncplane *ret = ncplane_aligned (
|
|
|
|
n.plane,
|
|
|
|
rows,
|
|
|
|
cols,
|
|
|
|
yoff,
|
|
|
|
static_cast<ncalign_e>(align),
|
|
|
|
opaque
|
|
|
|
);
|
|
|
|
|
|
|
|
if (ret == nullptr)
|
2020-05-20 04:15:38 +00:00
|
|
|
throw init_error ("Notcurses failed to create an aligned plane");
|
2020-01-07 22:51:34 +00:00
|
|
|
|
|
|
|
map_plane (plane, this);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-02-15 22:04:39 +00:00
|
|
|
ncplane* duplicate_plane (const Plane &other, void *opaque)
|
|
|
|
{
|
|
|
|
ncplane *ret = ncplane_dup (other.plane, opaque);
|
|
|
|
if (ret == nullptr)
|
2020-05-20 04:15:38 +00:00
|
|
|
throw init_error ("Notcurses failed to duplicate plane");
|
2020-02-15 22:04:39 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-01-07 22:51:34 +00:00
|
|
|
private:
|
|
|
|
ncplane *plane = nullptr;
|
|
|
|
bool is_stdplane = false;
|
|
|
|
static std::map<ncplane*,Plane*> *plane_map;
|
|
|
|
static std::mutex plane_map_mutex;
|
|
|
|
|
|
|
|
friend class NotCurses;
|
2020-02-05 22:29:42 +00:00
|
|
|
friend class NcReel;
|
2020-01-07 22:51:34 +00:00
|
|
|
friend class Tablet;
|
|
|
|
};
|
|
|
|
}
|
2020-05-24 12:41:18 +00:00
|
|
|
#endif
|