mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-06 03:20:26 +00:00
e6637e81cc
* CMake: add USE_PANDOC, USE_DOXYGEN options #101 * README: mention rust * start integrating rust into build #101 * CMake: add USE_NETWORK option for cargo * Debian: build-dep on doxygen * rust: colloquy checks in Cargo.lock * extract NCKEY defines into their own include * colloquy: use clap to parse CLI args * CMake: unify option namespace * Python: update include path * Rust: fix up --frozen workings for -DUSE_NETWORK=off * CMake: abstract out colloquy a little * Sync direct.hh to the New Way
78 lines
1.3 KiB
C++
78 lines
1.3 KiB
C++
#ifndef __NCPP_MENU_HH
|
|
#define __NCPP_MENU_HH
|
|
|
|
#include <notcurses/notcurses.h>
|
|
|
|
#include "Root.hh"
|
|
|
|
namespace ncpp
|
|
{
|
|
class Plane;
|
|
|
|
class NCPP_API_EXPORT Menu : public Root
|
|
{
|
|
public:
|
|
static ncmenu_options default_options;
|
|
|
|
public:
|
|
explicit Menu (const ncmenu_options *opts = nullptr)
|
|
{
|
|
menu = ncmenu_create (get_notcurses (), opts == nullptr ? &default_options : opts);
|
|
if (menu == nullptr)
|
|
throw init_error ("notcurses failed to create a new menu");
|
|
}
|
|
|
|
~Menu ()
|
|
{
|
|
if (!is_notcurses_stopped ())
|
|
ncmenu_destroy (menu);
|
|
}
|
|
|
|
bool unroll (int sectionidx) const noexcept
|
|
{
|
|
return ncmenu_unroll (menu, sectionidx) >= 0;
|
|
}
|
|
|
|
bool rollup () const noexcept
|
|
{
|
|
return ncmenu_rollup (menu) >= 0;
|
|
}
|
|
|
|
bool nextsection () const noexcept
|
|
{
|
|
return ncmenu_nextsection (menu) >= 0;
|
|
}
|
|
|
|
bool prevsection () const noexcept
|
|
{
|
|
return ncmenu_prevsection (menu) >= 0;
|
|
}
|
|
|
|
bool nextitem () const noexcept
|
|
{
|
|
return ncmenu_nextitem (menu) >= 0;
|
|
}
|
|
|
|
bool previtem () const noexcept
|
|
{
|
|
return ncmenu_previtem (menu) >= 0;
|
|
}
|
|
|
|
const char* get_selected (ncinput *ni = nullptr) const noexcept
|
|
{
|
|
return ncmenu_selected (menu, ni);
|
|
}
|
|
|
|
bool offer_input (const struct ncinput* nc) const noexcept
|
|
{
|
|
return ncmenu_offer_input (menu, nc);
|
|
}
|
|
|
|
Plane* get_plane () const noexcept;
|
|
|
|
private:
|
|
ncmenu *menu;
|
|
};
|
|
}
|
|
#endif
|