mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-18 03:25:55 +00:00
d32bef358d
After a long delay, apologies :) Added: * NotCurses: `can_sextant` (`notcurses_cansextant`) * Notcurses: `linesigs_enable` (`notcurses_linesigs_enable`) * Notcurses: `linesigs_disable` (`notcurses_linesigs_disable`) * Pile: `top_with` (`ncpile_top`) * Pile: `bottom_with` (`ncpile_bottom`) * Plane: `resize_maximize` (`ncplane_resize_maximize`) * Plane: `get_abs_x` (`ncplane_abs_x`) * Plane: `get_abs_y` (`ncplane_abs_y`) * Plane: `get_abs_yx` (`ncplane_abs_yx`) * Plane: `load_egc32` (`cell_load_egc32`) * Plane: `is_descendant_of` (`ncplane_descendant_p`) * Progbar: new class, wraps `ncprogbar_*` Changed: * Plane (ABI break): `at_cursor` overloads now return `int` where before they returned `bool` because the underlying Notcurses API only signalled the operation status with the return value while now it returns actual information.
61 lines
1.1 KiB
C++
61 lines
1.1 KiB
C++
#ifndef __NCPP_PROGBAR_HH
|
|
#define __NCPP_PROGBAR_HH
|
|
|
|
#include <exception>
|
|
#include <notcurses/notcurses.h>
|
|
|
|
#include "NotCurses.hh"
|
|
#include "Plane.hh"
|
|
|
|
namespace ncpp
|
|
{
|
|
class NCPP_API_EXPORT Progbar : public Root
|
|
{
|
|
public:
|
|
Progbar (Plane& n, const ncprogbar_options* opts)
|
|
: Root (nullptr)
|
|
{
|
|
if (opts == nullptr) {
|
|
throw invalid_argument ("Argument 'opts' must be a valid pointer");
|
|
}
|
|
|
|
progbar = ncprogbar_create (n, opts);
|
|
if (progbar == nullptr) {
|
|
throw init_error ("Notcurses failed to create ncprogbar");
|
|
}
|
|
}
|
|
|
|
~Progbar ()
|
|
{
|
|
if (!is_notcurses_stopped ()) {
|
|
ncprogbar_destroy (progbar);
|
|
}
|
|
}
|
|
|
|
Plane* get_plane () const noexcept
|
|
{
|
|
ncplane *ret = ncprogbar_plane (progbar);
|
|
if (ret == nullptr) {
|
|
return nullptr;
|
|
}
|
|
|
|
return Plane::map_plane (ret);
|
|
}
|
|
|
|
void set_progress (double p) const noexcept
|
|
{
|
|
ncprogbar_set_progress (progbar, p);
|
|
}
|
|
|
|
double get_progress () const noexcept
|
|
{
|
|
return ncprogbar_progress (progbar);
|
|
}
|
|
|
|
private:
|
|
ncprogbar *progbar = nullptr;
|
|
};
|
|
}
|
|
|
|
#endif // __NCPP_PROGBAR_HH
|