stamen

Static Menu Generator
git clone git://git.dimitrijedobrota.com/stamen.git
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING |

commit29d55f56073916781c2ce84858b27a45194ef4da
parenta88c5a020580b045ff3a0f1a9c8c2f45d0b8f17b
authorDimitrije Dobrota <mail@dimitrijedobrota.com>
dateSat, 15 Feb 2025 15:57:08 +0100

Add callback to self in menu_t class

Diffstat:
MCMakeLists.txt|+-
Msource/generate.cpp|+++-

2 files changed, 4 insertions(+), 2 deletions(-)


diff --git a/CMakeLists.txt b/CMakeLists.txt

@@ -4,7 +4,7 @@ include(cmake/prelude.cmake)

project(
stamen
VERSION 1.2.1
VERSION 1.2.2
DESCRIPTION "Static menu generator"
HOMEPAGE_URL "https://git.dimitrijedobrota.com/stamen"
LANGUAGES C CXX

diff --git a/source/generate.cpp b/source/generate.cpp

@@ -87,6 +87,7 @@ void generate_include_cpp(std::ostream& ost, const arguments_t& args)

ost << R"(
struct menu_t {
std::string title;
stamen::callback_f callback;
std::vector<stamen::item_t> items;
static int visit(const menu_t& menu);

@@ -128,7 +129,8 @@ void generate_source_cpp(std::ostream& ost,

ost << "\tstatic const menu_t menu = {\n";
ost << std::format("\t\t.title = \"{}\",\n", menu.get_title());
ost << "\t\t.items = {\n";
ost << std::format("\t\t.callback = {},\n", menu.get_code());
ost << std::format("\t\t.items = {{\n");
for (auto i = 0UL; i < menu.get_size(); i++)
{
ost << std::format("\t\t\t{{.callback = {}, .prompt = \"{}\"}},\n",