ncmenu: move to flag field #590

pull/592/head
nick black 4 years ago
parent fec423264f
commit 9446840b97
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -19,6 +19,9 @@ rearrangements of Notcurses.
Define `NCOPTION_INHIBIT_SETLOCALE` bit. If it's not set, and the "C" or
"POSIX" locale is in use, `notcurses_init()` will invoke
`setlocale(LC_ALL, "")`.
* All widgets now take an `ncplane*` as their first argument (some took
`notcurses*` before). All widgets' `options` structs now have an `unsigned
flags` bitfield. This future-proofs the widget API, to a degree.
* 1.3.4 (2020-05-07)
* `notcurses_lex_margins()` has been added to lex margins expressed in either

@ -25,13 +25,15 @@ struct ncmenu_section {
int itemcount;
};
#define NCMENU_OPTIONS_BOTTOM 0x0001 // bottom row (as opposed to top row)
#define NCMENU_OPTIONS_HIDING 0x0002 // hide the menu when not being used
typedef struct ncmenu_options {
bool bottom; // on the bottom row, as opposed to top row
bool hiding; // hide the menu when not being used
struct ncmenu_section* sections; // 'sectioncount' menu_sections
int sectioncount; // must be positive
uint64_t headerchannels; // styling for header
uint64_t sectionchannels; // styling for sections
unsigned flags; // bitfield on NCMENU_OPTIONS_*
} ncmenu_options;
```

@ -17,7 +17,8 @@ namespace ncpp
public:
explicit Menu (const ncmenu_options *opts = nullptr)
{
menu = ncmenu_create (get_notcurses (), opts == nullptr ? &default_options : opts);
menu = ncmenu_create (notcurses_stdplane(get_notcurses ()),
opts == nullptr ? &default_options : opts);
if (menu == nullptr)
throw init_error ("notcurses failed to create a new menu");
}

@ -2594,19 +2594,21 @@ struct ncmenu_section {
ncinput shortcut; // shortcut, will be underlined if present in name
};
#define NCMENU_OPTIONS_BOTTOM 0x0001 // bottom row (as opposed to top row)
#define NCMENU_OPTIONS_HIDING 0x0002 // hide the menu when not being used
typedef struct ncmenu_options {
bool bottom; // on the bottom row, as opposed to top row
bool hiding; // hide the menu when not being used
struct ncmenu_section* sections; // array of 'sectioncount' menu_sections
int sectioncount; // must be positive
uint64_t headerchannels; // styling for header
uint64_t sectionchannels; // styling for sections
int sectioncount; // must be positive
uint64_t headerchannels; // styling for header
uint64_t sectionchannels; // styling for sections
unsigned flags; // flag word of NCMENU_OPTIONS_*
} ncmenu_options;
// Create a menu with the specified options. Menus are currently bound to an
// overall notcurses object (as opposed to a particular plane), and are
// implemented as ncplanes kept atop other ncplanes.
API struct ncmenu* ncmenu_create(struct notcurses* nc, const ncmenu_options* opts);
API struct ncmenu* ncmenu_create(struct ncplane* nc, const ncmenu_options* opts);
// Unroll the specified menu section, making the menu visible if it was
// invisible, and rolling up any menu section that is already unrolled.
@ -2796,6 +2798,9 @@ API int ncplane_qrcode(struct ncplane* n, int maxversion, const void* data, size
// to create the ncvisual from memory using ncvisual_from_rgba().
API struct ncvisual* ncvisual_from_plane(struct ncplane* n);
#define NCREADER_OPTION_HORSCROLL 0x0001
#define NCREADER_OPTION_VERSCROLL 0x0002
typedef struct ncreader_options {
uint64_t tchannels; // channels used for input
uint64_t echannels; // channels used for empty space
@ -2804,13 +2809,13 @@ typedef struct ncreader_options {
char* egc; // egc used for empty space
int physrows;
int physcols;
bool scroll; // allow more than the physical area's worth of input
unsigned flags; // bitfield of NCREADER_OPTION_*
} ncreader_options;
// ncreaders provide freeform input in a (possibly multiline) region,
// supporting readline keybindings. 'rows' and 'cols' both must be negative.
// there are no restrictions on 'y' or 'x'. creates its own plane.
API struct ncreader* ncreader_create(struct notcurses* nc, int y, int x,
API struct ncreader* ncreader_create(struct ncplane* nc, int y, int x,
const ncreader_options* opts);
// empty the ncreader of any user input, and home the cursor.

@ -4,12 +4,11 @@
using namespace ncpp;
ncmenu_options Menu::default_options = {
/* bottom */ false,
/* hiding */ true,
/* sections */ nullptr,
/* sectioncount */ 0,
/* headerchannels */ 0,
/* sectionchannels */ 0,
/* flags */ 0,
};
Plane* Menu::get_plane () const noexcept

Loading…
Cancel
Save