Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Generic / ConsoleInterface / Menu.cpp
diff options
context:
space:
mode:
Commit09b94a7471f2ac5b2958f0fee735c692a444b9ba (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-05-30 20:13:18 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-05-30 20:13:18 +0300
Files145e1bbc8b6796b2f47b3ad01444088c10e39c4c /src/Generic/ConsoleInterface/Menu.cpp
FMI-OOP-P2_Tables-09b94a7471f2ac5b2958f0fee735c692a444b9ba.tar
FMI-OOP-P2_Tables-09b94a7471f2ac5b2958f0fee735c692a444b9ba.tar.gz
FMI-OOP-P2_Tables-09b94a7471f2ac5b2958f0fee735c692a444b9ba.zip
Parent499a22cf9e6e6ce0cb396a53a25d22a1e63c734f (diff)
Autocommit at 30.05.2022 @ 20:13
1 files changed, 6 insertions, 3 deletions
-rw-r--r--src/Generic/ConsoleInterface/Menu.cpp9
diff --git a/src/Generic/ConsoleInterface/Menu.cpp b/src/Generic/ConsoleInterface/Menu.cpp
index 23b3c31..910e946 100644
--- a/src/Generic/ConsoleInterface/Menu.cpp
+++ b/src/Generic/ConsoleInterface/Menu.cpp
@@ -35,7 +35,7 @@ void Menu::navigate() const {
char buffer[MAX_LINE_WIDTH];
- unsigned startIndex, commandEnd, index;
+ unsigned startIndex, commandEnd, paramsStart, index;
while (1) {
startIndex = 0;
inputLineBox(buffer, MAX_LINE_WIDTH, false);
@@ -51,15 +51,18 @@ void Menu::navigate() const {
index = menuOptions.get_count();
for (unsigned i = 0; i < menuOptions.get_count() && index == menuOptions.get_count(); i++) {
- if (strncmp(buffer, menuOptions[i].get_name(), commandEnd) == 0)
+ if (strncmp(buffer + startIndex, menuOptions[i].get_name(), commandEnd) == 0)
index = i;
}
+ paramsStart = startIndex + commandEnd;
+ while (buffer[paramsStart] == ' ') paramsStart++;
+
if (index == menuOptions.get_count()) {
printLine("Invalid menu option!");
continue;
}
- menuOptions[index].run(buffer + startIndex + commandEnd);
+ menuOptions[index].run(buffer + paramsStart);
}
}