From e0462ed53af41e9bda329872457f0757c9bf53d2 Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Sun, 24 May 2020 08:07:12 +0000 Subject: [PATCH] [C++] Sync API changes (#633) Added: * NotCurses: can_utf8 (`notcurses_canutf8`) * NotCurses: debug (`notcurses_debug`) * Plane: center_abs (`ncplane_center_abs`) * Plane: set_channels (`ncplane_set_channels`) * Plane: set_attr (`ncplane_set_attr`) * Reader: clear (`ncreader_clear`) Changed: * USAGE.md: clarfied when C++ throws exceptions --- USAGE.md | 6 +++--- include/ncpp/NotCurses.hh | 10 ++++++++++ include/ncpp/Plane.hh | 17 ++++++++++++++++- include/ncpp/Reader.hh | 6 ++++++ 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/USAGE.md b/USAGE.md index ff2c689d5..ddad35de3 100644 --- a/USAGE.md +++ b/USAGE.md @@ -2557,6 +2557,6 @@ struct ncvisual* ncvisual_from_plane(struct ncplane* n); Marek Habersack has contributed (and maintains) C++ wrappers installed to `include/ncpp/`, `libnotcurses++.so`, and `libnotcurses++.a`. -In their default mode, these wrappers never throw exceptions. If -`NCPP_EXCEPTIONS_PLEASE` is defined prior to including any NCPP headers, -they will throw exceptions. +In their default mode, these wrappers throw exceptions only from the type +constructors (RAII). If `NCPP_EXCEPTIONS_PLEASE` is defined prior to including +any NCPP headers, they will throw exceptions. diff --git a/include/ncpp/NotCurses.hh b/include/ncpp/NotCurses.hh index d256cd137..35a2e0b1e 100644 --- a/include/ncpp/NotCurses.hh +++ b/include/ncpp/NotCurses.hh @@ -83,6 +83,11 @@ namespace ncpp bool stop (); + bool can_utf8 () const noexcept + { + return notcurses_canutf8 (nc); + } + bool can_fade () const noexcept { return notcurses_canfade (nc); @@ -205,6 +210,11 @@ namespace ncpp notcurses_drop_planes (nc); } + void debug (FILE *debugfp) const noexcept + { + notcurses_debug (nc, debugfp); + } + Plane* get_stdplane () noexcept { return new Plane (notcurses_stdplane (nc), true); diff --git a/include/ncpp/Plane.hh b/include/ncpp/Plane.hh index cfe11352f..41b21c08b 100644 --- a/include/ncpp/Plane.hh +++ b/include/ncpp/Plane.hh @@ -115,6 +115,11 @@ namespace ncpp return plane; } + void center_abs (int *y, int *x) const noexcept + { + ncplane_center_abs (plane, y, x); + } + ncplane* to_ncplane () noexcept { return plane; @@ -652,6 +657,16 @@ namespace ncpp return ncplane_fg_alpha (plane); } + 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); + } + bool set_fg_alpha (int alpha) const NOEXCEPT_MAYBE { return error_guard (ncplane_set_fg_alpha (plane, alpha), -1); @@ -1085,4 +1100,4 @@ namespace ncpp friend class Tablet; }; } -#endif +#endif \ No newline at end of file diff --git a/include/ncpp/Reader.hh b/include/ncpp/Reader.hh index 462dd805d..079b4ba42 100644 --- a/include/ncpp/Reader.hh +++ b/include/ncpp/Reader.hh @@ -44,6 +44,12 @@ namespace ncpp ncreader_destroy (reader, nullptr); } + bool clear () const NOEXCEPT_MAYBE + { + bool ret = ncreader_clear (reader) != 0; + return error_guard_cond (ret, ret); + } + char* get_contents () const noexcept { return ncreader_contents(reader);