stamen

Stamen - static menu generator
git clone git://git.dimitrijedobrota.com/stamen.git
Log | Files | Refs | README | LICENSE

commit 5dd366ebead42ece724fc60097c79e667739dcc6
parent cff8002912e2fbd52d9904edabc930a9aa077fe5
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Mon,  6 Nov 2023 23:57:17 +0000

type -1 to go back

Diffstat:
Msrc/display.cpp | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/display.cpp b/src/display.cpp @@ -2,7 +2,7 @@ #include <iostream> int Menu::Menu_function::display() const { - unsigned long choice; + int choice; while (true) { std::cout << name << std::endl; @@ -11,7 +11,11 @@ int Menu::Menu_function::display() const { while (true) { std::cout << "Choose an option: "; - if (std::cin >> choice && choice < items.size()) { + if (std::cin >> choice && choice >= -1 && choice < (int)items.size()) { + if (choice == -1) { + std::cout << "Back" << items[choice].prompt << "\n"; + return 1; + } std::cout << "Chosen: " << items[choice].prompt << "\n\n"; int res = menu.get_callback(items[choice].callback)(); if (--res) return res;