diff --git a/include/notcurses.h b/include/notcurses.h index c93009883..d7d45cb6a 100644 --- a/include/notcurses.h +++ b/include/notcurses.h @@ -2210,13 +2210,15 @@ API void ncselector_destroy(struct ncselector* n, char** item); // a screen resize, menus will be automatically moved/resized. Elements can be // dynamically enabled or disabled at all levels (menu, section, and item), +struct ncmenu_item { + char* desc; // utf-8 menu item, NULL for horizontal separator + ncinput shortcut; // shortcut, all should be distinct +}; + struct ncmenu_section { char* name; // utf-8 c string - struct ncmenu_item { - char* desc; // utf-8 menu item, NULL for horizontal separator - ncinput shortcut; // shortcut, all should be distinct - }* items; int itemcount; + struct ncmenu_item* items; int xoff; // used only in library copy, ignored in request int bodycols; // used only in library copy, ignored in request int itemselected; // used only in library copy, ignored in request diff --git a/tests/menu.cpp b/tests/menu.cpp index 58f9c5aba..3d53dcd57 100644 --- a/tests/menu.cpp +++ b/tests/menu.cpp @@ -34,6 +34,23 @@ TEST_CASE("MenuTest") { ncmenu_destroy(ncm); } + SUBCASE("MenuOneSection") { + struct ncmenu_item file_items[] = { + { .desc = strdup("I would like a new file"), .shortcut = {}, }, + }; + struct ncmenu_section sections[] = { + { .name = strdup("File"), .itemcount = sizeof(file_items) / sizeof(*file_items), .items = file_items, + .xoff = -1, .bodycols = -1, .itemselected = -1, }, + }; + struct ncmenu_options opts{}; + opts.sections = sections; + opts.sectioncount = sizeof(sections) / sizeof(*sections); + struct ncmenu* ncm = ncmenu_create(nc_, &opts); + REQUIRE(nullptr != ncm); + CHECK(0 == notcurses_render(nc_)); + ncmenu_destroy(ncm); + } + CHECK(0 == notcurses_stop(nc_)); CHECK(0 == fclose(outfp_)); }