[C++] Sync API changes
Added: * class FDPlane (`ncfdplane*`) * class Subproc (`ncsubproc*`) * NotCurses: get_inputready_fd (`notcurses_inputready_fd`) * Plane: qrcode (`ncplane_qrcode`) * class PlotBase: templated base class for Plot variations * class PlotU: `uint64_t` instantiation of PlotBase (aliased to previous `Plot` class for source compatibility), `ncuplot*` * class PlotD: `double` instantiation of PlotBase, `ncdplot*`pull/587/head
parent
f14444cfca
commit
e23d5baea4
@ -0,0 +1,69 @@
|
|||||||
|
#ifndef __NCPP_FDPLANE_HH
|
||||||
|
#define __NCPP_FDPLANE_HH
|
||||||
|
|
||||||
|
#include <notcurses/notcurses.h>
|
||||||
|
|
||||||
|
#include "Root.hh"
|
||||||
|
#include "Plane.hh"
|
||||||
|
|
||||||
|
namespace ncpp
|
||||||
|
{
|
||||||
|
class NCPP_API_EXPORT FDPlane : public Root
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static ncfdplane_options default_options;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit FDPlane (Plane* n, int fd, ncfdplane_callback cbfxn = nullptr, ncfdplane_done_cb donecbfxn = nullptr)
|
||||||
|
: FDPlane (n, fd, nullptr, cbfxn, donecbfxn)
|
||||||
|
{}
|
||||||
|
|
||||||
|
explicit FDPlane (Plane* n, int fd, ncfdplane_options *opts = nullptr, ncfdplane_callback cbfxn = nullptr, ncfdplane_done_cb donecbfxn = nullptr)
|
||||||
|
{
|
||||||
|
if (n == nullptr)
|
||||||
|
throw invalid_argument ("'n' must be a valid pointer");
|
||||||
|
create_fdplane (*n, fd, opts, cbfxn, donecbfxn);
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit FDPlane (Plane& n, int fd, ncfdplane_callback cbfxn = nullptr, ncfdplane_done_cb donecbfxn = nullptr)
|
||||||
|
: FDPlane (n, fd, nullptr, cbfxn, donecbfxn)
|
||||||
|
{}
|
||||||
|
|
||||||
|
explicit FDPlane (Plane& n, int fd, ncfdplane_options *opts = nullptr, ncfdplane_callback cbfxn = nullptr, ncfdplane_done_cb donecbfxn = nullptr)
|
||||||
|
{
|
||||||
|
create_fdplane (n, fd, opts, cbfxn, donecbfxn);
|
||||||
|
}
|
||||||
|
|
||||||
|
~FDPlane ()
|
||||||
|
{
|
||||||
|
if (is_notcurses_stopped ())
|
||||||
|
return;
|
||||||
|
|
||||||
|
ncfdplane_destroy (fdplane);
|
||||||
|
}
|
||||||
|
|
||||||
|
Plane* get_plane () const noexcept
|
||||||
|
{
|
||||||
|
return Plane::map_plane (ncfdplane_plane (fdplane));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void create_fdplane (Plane& n, int fd, ncfdplane_options *opts, ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn)
|
||||||
|
{
|
||||||
|
fdplane = ncfdplane_create (
|
||||||
|
n,
|
||||||
|
opts == nullptr ? &default_options : opts,
|
||||||
|
fd,
|
||||||
|
cbfxn,
|
||||||
|
donecbfxn
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fdplane == nullptr)
|
||||||
|
throw init_error ("NotCurses failed to create an ncfdplane instance");
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ncfdplane *fdplane;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif // __NCPP_FDPLANE_HH
|
@ -0,0 +1,93 @@
|
|||||||
|
#ifndef __NCPP_SUBPROC_HH
|
||||||
|
#define __NCPP_SUBPROC_HH
|
||||||
|
|
||||||
|
#include <notcurses/notcurses.h>
|
||||||
|
|
||||||
|
#include "Root.hh"
|
||||||
|
#include "Plane.hh"
|
||||||
|
|
||||||
|
namespace ncpp
|
||||||
|
{
|
||||||
|
class NCPP_API_EXPORT Subproc : public Root
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static ncsubproc_options default_options;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit Subproc (Plane* n, const char* bin, bool use_path = true,
|
||||||
|
char* const arg[] = nullptr, char* const env[] = nullptr,
|
||||||
|
ncfdplane_callback cbfxn = nullptr, ncfdplane_done_cb donecbfxn = nullptr)
|
||||||
|
: Subproc (n, bin, nullptr, use_path, arg, env, cbfxn, donecbfxn)
|
||||||
|
{}
|
||||||
|
|
||||||
|
explicit Subproc (Plane* n, const char* bin, const ncsubproc_options* opts, bool use_path = true,
|
||||||
|
char* const arg[] = nullptr, char* const env[] = nullptr,
|
||||||
|
ncfdplane_callback cbfxn = nullptr, ncfdplane_done_cb donecbfxn = nullptr)
|
||||||
|
{
|
||||||
|
if (n == nullptr)
|
||||||
|
throw invalid_argument ("'n' must be a valid pointer");
|
||||||
|
create_subproc (*n, bin, opts, use_path, arg, env, cbfxn, donecbfxn);
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit Subproc (Plane& n, const char* bin, bool use_path = true,
|
||||||
|
char* const arg[] = nullptr, char* const env[] = nullptr,
|
||||||
|
ncfdplane_callback cbfxn = nullptr, ncfdplane_done_cb donecbfxn = nullptr)
|
||||||
|
: Subproc (n, bin, nullptr, use_path, arg, env, cbfxn, donecbfxn)
|
||||||
|
{}
|
||||||
|
|
||||||
|
explicit Subproc (Plane& n, const char* bin, const ncsubproc_options* opts, bool use_path = true,
|
||||||
|
char* const arg[] = nullptr, char* const env[] = nullptr,
|
||||||
|
ncfdplane_callback cbfxn = nullptr, ncfdplane_done_cb donecbfxn = nullptr)
|
||||||
|
{
|
||||||
|
create_subproc (n, bin, opts, use_path, arg, env, cbfxn, donecbfxn);
|
||||||
|
}
|
||||||
|
|
||||||
|
~Subproc ()
|
||||||
|
{
|
||||||
|
if (is_notcurses_stopped ())
|
||||||
|
return;
|
||||||
|
|
||||||
|
ncsubproc_destroy (subproc);
|
||||||
|
}
|
||||||
|
|
||||||
|
Plane* get_plane () const noexcept
|
||||||
|
{
|
||||||
|
return Plane::map_plane (ncsubproc_plane (subproc));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void create_subproc (Plane& n, const char* bin, const ncsubproc_options* opts, bool use_path,
|
||||||
|
char* const arg[], char* const env[],
|
||||||
|
ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn)
|
||||||
|
{
|
||||||
|
if (bin == nullptr)
|
||||||
|
throw invalid_argument ("'bin' must be a valid pointer");
|
||||||
|
|
||||||
|
if (opts == nullptr)
|
||||||
|
opts = &default_options;
|
||||||
|
|
||||||
|
if (use_path) {
|
||||||
|
if (env != nullptr) {
|
||||||
|
subproc = ncsubproc_createvpe (
|
||||||
|
n, opts, bin, arg, env, cbfxn, donecbfxn
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
subproc = ncsubproc_createvp (
|
||||||
|
n, opts, bin, arg, cbfxn, donecbfxn
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
subproc = ncsubproc_createv (
|
||||||
|
n, opts, bin, arg, cbfxn, donecbfxn
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subproc == nullptr)
|
||||||
|
throw new init_error ("NotCurses failed to create ncsubproc instance");
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ncsubproc *subproc;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif // __NCPP_SUBPROC_HH
|
@ -0,0 +1,8 @@
|
|||||||
|
#include <ncpp/FDPlane.hh>
|
||||||
|
|
||||||
|
using namespace ncpp;
|
||||||
|
|
||||||
|
ncfdplane_options FDPlane::default_options = {
|
||||||
|
nullptr, // curry
|
||||||
|
false, // follow
|
||||||
|
};
|
@ -0,0 +1,8 @@
|
|||||||
|
#include <ncpp/Subproc.hh>
|
||||||
|
|
||||||
|
using namespace ncpp;
|
||||||
|
|
||||||
|
ncsubproc_options Subproc::default_options = {
|
||||||
|
nullptr, // curry
|
||||||
|
0, // restart_period
|
||||||
|
};
|
Loading…
Reference in New Issue