Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Generic / ConsoleInterface / Menu.cpp
diff options
context:
space:
mode:
1 files changed, 15 insertions, 4 deletions
-rw-r--r--src/Generic/ConsoleInterface/Menu.cpp19
diff --git a/src/Generic/ConsoleInterface/Menu.cpp b/src/Generic/ConsoleInterface/Menu.cpp
index 71bafaf..16032eb 100644
--- a/src/Generic/ConsoleInterface/Menu.cpp
+++ b/src/Generic/ConsoleInterface/Menu.cpp
@@ -28,9 +28,20 @@ void Menu::navigate() const {
clear();
inputLineBox("> ", buffer, MAX_LINE_WIDTH);
- if (buffer > menuOptions.get_count())
- registerError("Invalid menu option!");
- else if (buffer > 0)
- menuOptions[buffer - 1].run();
+ unsigned index = menuOptions.get_count();
+ for (unsigned i = 0; i < menuOptions.get_count(); i++) {
+ if (strncmp(buffer, menuOptions[i].get_nameInMenu(), MAX_LINE_WIDTH) == 0) {
+ index = i;
+ break;
+ }
+ }
+
+ if (index > menuOptions.get_count()) {
+ printline("Invalid menu option!");
+ continue;
+ }
+
+
+ menuOptions[index].run();
}
}