From 63b64ff62477b4fa5f01d102a15dd26e87a5e9e9 Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Mon, 22 Jun 2020 21:49:13 +0200 Subject: [PATCH] [C++] API sync Added: * Direct: render_image (`ncdirect_render_image`) * NotCurses: can_truecolor (`notcurses_cantruecolor`) * Plane: home (`ncplane_home`) * Plane: perimeter_rounded (`ncplane_perimeter_rounded`) * Plane: perimeter_double (`ncplane_perimeter_double`) * Plane: is_fg_default (`ncplane_fg_default_p`) * Plane: is_bg_default (`ncplane_bg_default_p`) * Plot: sample (`nc{d,u}plot_sample`) * Visual: geom (`ncvisual_geom`) Fixed: * Plot: {set,add}_sample - `x` coord is always `uint64_t` --- include/ncpp/Direct.hh | 5 +++++ include/ncpp/NotCurses.hh | 5 +++++ include/ncpp/Plane.hh | 25 +++++++++++++++++++++++++ include/ncpp/Plot.hh | 17 +++++++++++++++-- include/ncpp/Visual.hh | 5 +++++ 5 files changed, 55 insertions(+), 2 deletions(-) diff --git a/include/ncpp/Direct.hh b/include/ncpp/Direct.hh index 17c5ea741..b4d59d31a 100644 --- a/include/ncpp/Direct.hh +++ b/include/ncpp/Direct.hh @@ -122,6 +122,11 @@ namespace ncpp return error_guard (ncdirect_cursor_disable (direct), -1); } + nc_err_e render_image (const char* file, ncblitter_e blitter, ncscale_e scale) const noexcept + { + return ncdirect_render_image (direct, file, blitter, scale); + } + private: ncdirect *direct; }; diff --git a/include/ncpp/NotCurses.hh b/include/ncpp/NotCurses.hh index 1731a65f1..be7190aca 100644 --- a/include/ncpp/NotCurses.hh +++ b/include/ncpp/NotCurses.hh @@ -111,6 +111,11 @@ namespace ncpp return notcurses_canchangecolor (nc); } + bool can_truecolor () const noexcept + { + return notcurses_cantruecolor (nc); + } + void get_stats (ncstats *stats) const noexcept { if (stats == nullptr) diff --git a/include/ncpp/Plane.hh b/include/ncpp/Plane.hh index 564caccbc..5805d4863 100644 --- a/include/ncpp/Plane.hh +++ b/include/ncpp/Plane.hh @@ -285,6 +285,11 @@ namespace ncpp return reparent (const_cast(&newparent)); } + void home () const noexcept + { + ncplane_home (plane); + } + bool move (int y, int x) const NOEXCEPT_MAYBE { return error_guard (ncplane_move_yx (plane, y, x), -1); @@ -616,6 +621,16 @@ namespace ncpp return error_guard (ncplane_perimeter (plane, ul, ur, ll, lr, hline, vline, ctlword), -1); } + 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); + } + int polyfill (int y, int x, const Cell& c) const NOEXCEPT_MAYBE { return error_guard (ncplane_polyfill_yx (plane, y, x, c), -1); @@ -1033,6 +1048,16 @@ namespace ncpp return error_guard_cond (ret, ret < 0); } + bool is_fg_default () const noexcept + { + return ncplane_fg_default_p (plane); + } + + bool is_bg_default () const noexcept + { + return ncplane_bg_default_p (plane); + } + protected: explicit Plane (ncplane *_plane, bool _is_stdplane) : Root (nullptr), diff --git a/include/ncpp/Plot.hh b/include/ncpp/Plot.hh index 062c56050..9cfd7ac25 100644 --- a/include/ncpp/Plot.hh +++ b/include/ncpp/Plot.hh @@ -18,7 +18,7 @@ namespace ncpp static constexpr bool is_uint64 = std::is_same_v; public: - bool add_sample(TCoord x, TCoord y) const NOEXCEPT_MAYBE + bool add_sample (uint64_t x, TCoord y) const NOEXCEPT_MAYBE { int ret; @@ -31,7 +31,7 @@ namespace ncpp return error_guard (ret, -1); } - bool set_sample(TCoord x, TCoord y) const NOEXCEPT_MAYBE + bool set_sample (uint64_t x, TCoord y) const NOEXCEPT_MAYBE { int ret; @@ -43,6 +43,19 @@ namespace ncpp return error_guard (ret, -1); } + bool sample (uint64_t x, TCoord* y) const NOEXCEPT_MAYBE + { + int ret; + + if constexpr (is_double) { + ret = ncdplot_sample (plot, x, y); + } else { + ret = ncuplot_sample (plot, x, y); + } + + return error_guard (ret, -1); + } + protected: explicit PlotBase (Plane *plane, const ncplot_options *opts, TCoord miny = 0, TCoord maxy = 0) : Root (Utilities::get_notcurses_cpp (plane)) diff --git a/include/ncpp/Visual.hh b/include/ncpp/Visual.hh index 9f56e5da2..b12820dbf 100644 --- a/include/ncpp/Visual.hh +++ b/include/ncpp/Visual.hh @@ -92,6 +92,11 @@ namespace ncpp return error_guard (ncvisual_polyfill_yx (visual, y, x, rgba), -1); } + bool geom (const struct ncvisual_options *vopts, int *y, int *x, int *toy, int *tox) const NOEXCEPT_MAYBE + { + return error_guard (ncvisual_geom (get_notcurses (), visual, vopts, y, x, toy, tox), -1); + } + bool at (int y, int x, uint32_t* pixel) const { if (pixel == nullptr)