Notcurses 3.0.13
a blingful library for TUIs and character graphics
Loading...
Searching...
No Matches
FDPlane.hh
Go to the documentation of this file.
1#ifndef __NCPP_FDPLANE_HH
2#define __NCPP_FDPLANE_HH
3
5
6#include "Utilities.hh"
7#include "Plane.hh"
8#include "Widget.hh"
9
10namespace ncpp
11{
13 {
14 public:
16
17 public:
18 explicit FDPlane (Plane *plane, int fd, ncfdplane_callback cbfxn = nullptr, ncfdplane_done_cb donecbfxn = nullptr)
19 : FDPlane (plane, fd, nullptr, cbfxn, donecbfxn)
20 {}
21
22 explicit FDPlane (Plane *plane, int fd, ncfdplane_options *opts = nullptr, ncfdplane_callback cbfxn = nullptr, ncfdplane_done_cb donecbfxn = nullptr)
23 : Widget (Utilities::get_notcurses_cpp (plane))
24 {
25 ensure_valid_plane (plane);
26 create_fdplane (*plane, fd, opts, cbfxn, donecbfxn);
27 take_plane_ownership (plane);
28 }
29
30 explicit FDPlane (Plane &plane, int fd, ncfdplane_callback cbfxn = nullptr, ncfdplane_done_cb donecbfxn = nullptr)
31 : FDPlane (plane, fd, nullptr, cbfxn, donecbfxn)
32 {}
33
34 explicit FDPlane (Plane &plane, int fd, ncfdplane_options *opts = nullptr, ncfdplane_callback cbfxn = nullptr, ncfdplane_done_cb donecbfxn = nullptr)
35 : Widget (Utilities::get_notcurses_cpp (plane))
36 {
37 ensure_valid_plane (plane);
38 create_fdplane (plane, fd, opts, cbfxn, donecbfxn);
39 take_plane_ownership (plane);
40 }
41
43 {
44 if (is_notcurses_stopped ())
45 return;
46
47 ncfdplane_destroy (fdplane);
48 }
49
50 Plane* get_plane () const noexcept
51 {
52 return Plane::map_plane (ncfdplane_plane (fdplane));
53 }
54
55 private:
56 void create_fdplane (Plane& n, int fd, ncfdplane_options *opts, ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn)
57 {
58 fdplane = ncfdplane_create (
59 n,
60 opts == nullptr ? &default_options : opts,
61 fd,
62 cbfxn,
63 donecbfxn
64 );
65
66 if (fdplane == nullptr)
67 throw init_error ("NotCurses failed to create an ncfdplane instance");
68 }
69
70 private:
71 ncfdplane *fdplane;
72 };
73}
74#endif // __NCPP_FDPLANE_HH
#define NCPP_API_EXPORT
Definition _helpers.hh:9
FDPlane(Plane *plane, int fd, ncfdplane_options *opts=nullptr, ncfdplane_callback cbfxn=nullptr, ncfdplane_done_cb donecbfxn=nullptr)
Definition FDPlane.hh:22
FDPlane(Plane *plane, int fd, ncfdplane_callback cbfxn=nullptr, ncfdplane_done_cb donecbfxn=nullptr)
Definition FDPlane.hh:18
static ncfdplane_options default_options
Definition FDPlane.hh:15
FDPlane(Plane &plane, int fd, ncfdplane_options *opts=nullptr, ncfdplane_callback cbfxn=nullptr, ncfdplane_done_cb donecbfxn=nullptr)
Definition FDPlane.hh:34
FDPlane(Plane &plane, int fd, ncfdplane_callback cbfxn=nullptr, ncfdplane_done_cb donecbfxn=nullptr)
Definition FDPlane.hh:30
Plane * get_plane() const noexcept
Definition FDPlane.hh:50
int ncfdplane_destroy(ncfdplane *n)
Definition fd.c:136
ncplane * ncfdplane_plane(ncfdplane *n)
Definition fd.c:132
ncfdplane * ncfdplane_create(ncplane *n, const ncfdplane_options *opts, int fd, ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn)
Definition fd.c:120
const struct ncplane_options * opts
Definition notcurses.h:3483
vopts n
Definition notcurses.h:3502
int(* ncfdplane_done_cb)(struct ncfdplane *n, int fderrno, void *curry)
Definition notcurses.h:4547
int(* ncfdplane_callback)(struct ncfdplane *n, const void *buf, size_t s, void *curry)
Definition notcurses.h:4546