2020-05-08 19:19:37 +00:00
|
|
|
#ifndef __NCPP_READER_HH
|
|
|
|
#define __NCPP_READER_HH
|
|
|
|
|
|
|
|
#include <notcurses/notcurses.h>
|
|
|
|
|
|
|
|
#include "Root.hh"
|
|
|
|
#include "NCAlign.hh"
|
|
|
|
#include "NotCurses.hh"
|
2020-05-22 20:11:59 +00:00
|
|
|
#include "Utilities.hh"
|
2020-05-08 19:19:37 +00:00
|
|
|
|
|
|
|
namespace ncpp
|
|
|
|
{
|
|
|
|
class Plane;
|
|
|
|
|
|
|
|
class NCPP_API_EXPORT Reader : public Root
|
|
|
|
{
|
|
|
|
public:
|
2020-05-09 12:41:19 +00:00
|
|
|
explicit Reader (Plane *p, int y, int x, const ncreader_options *opts)
|
2020-05-22 20:11:59 +00:00
|
|
|
: Reader (Utilities::to_ncplane (p), y, x, opts)
|
2020-05-08 19:19:37 +00:00
|
|
|
{}
|
|
|
|
|
2020-05-09 12:41:19 +00:00
|
|
|
explicit Reader (Plane const* p, int y, int x, const ncreader_options *opts)
|
|
|
|
: Reader (const_cast<Plane*>(p), y, x, opts)
|
2020-05-08 19:19:37 +00:00
|
|
|
{}
|
|
|
|
|
2020-05-09 12:41:19 +00:00
|
|
|
explicit Reader (Plane &p, int y, int x, const ncreader_options *opts)
|
|
|
|
: Reader (reinterpret_cast<Plane*>(&p), y, x, opts)
|
2020-05-08 19:19:37 +00:00
|
|
|
{}
|
|
|
|
|
2020-05-09 12:41:19 +00:00
|
|
|
explicit Reader (Plane const& p, int y, int x, const ncreader_options *opts)
|
|
|
|
: Reader (const_cast<Plane*>(&p), y, x, opts)
|
2020-05-08 19:19:37 +00:00
|
|
|
{}
|
|
|
|
|
2020-05-09 12:41:19 +00:00
|
|
|
explicit Reader (ncplane* n, int y, int x, const ncreader_options *opts)
|
2020-05-08 19:19:37 +00:00
|
|
|
{
|
2020-05-09 12:41:19 +00:00
|
|
|
reader = ncreader_create (n, y, x, opts);
|
2020-05-08 19:19:37 +00:00
|
|
|
if (reader == nullptr)
|
2020-05-20 04:15:38 +00:00
|
|
|
throw init_error ("Notcurses failed to create a new reader");
|
2020-05-08 19:19:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~Reader ()
|
|
|
|
{
|
|
|
|
if (!is_notcurses_stopped ())
|
|
|
|
ncreader_destroy (reader, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
char* get_contents () const noexcept
|
|
|
|
{
|
|
|
|
return ncreader_contents(reader);
|
|
|
|
}
|
|
|
|
|
|
|
|
Plane* get_plane () const noexcept
|
|
|
|
{
|
|
|
|
return Plane::map_plane (ncreader_plane (reader));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
ncreader *reader;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|