Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Generic / ConsoleInterface / Menu.cpp
diff options
context:
space:
mode:
Commitddf7af235fecfc858c380d2c5b8779a1894ad63f (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-05-29 08:23:55 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-05-29 08:23:55 +0300
Filesb290e8894e98c8b2d845c8fcf3bdc010189602ce /src/Generic/ConsoleInterface/Menu.cpp
FMI-OOP-P2_Tables-ddf7af235fecfc858c380d2c5b8779a1894ad63f.tar
FMI-OOP-P2_Tables-ddf7af235fecfc858c380d2c5b8779a1894ad63f.tar.gz
FMI-OOP-P2_Tables-ddf7af235fecfc858c380d2c5b8779a1894ad63f.zip
Parent32ba99f3203b1392f8a850f0ac4b142f83a74953 (diff)
Autocommit at 29.05.2022 @ 08:23
1 files changed, 4 insertions, 3 deletions
-rw-r--r--src/Generic/ConsoleInterface/Menu.cpp7
diff --git a/src/Generic/ConsoleInterface/Menu.cpp b/src/Generic/ConsoleInterface/Menu.cpp
index cde9aae..18287f2 100644
--- a/src/Generic/ConsoleInterface/Menu.cpp
+++ b/src/Generic/ConsoleInterface/Menu.cpp
@@ -6,7 +6,7 @@ Menu::Menu() : menuOptions() {}
unsigned indexOfCommandEnd(char* str) {
unsigned ind = 0;
- while (str[ind] != ' ') ind++;
+ while (str[ind] != ' ' && str[ind] != '\n' && str[ind] != '\0') ind++;
return ind;
}
@@ -43,14 +43,15 @@ void Menu::navigate() const {
unsigned commandEnd = indexOfCommandEnd(buffer),
index = menuOptions.get_count();
+ std::cout << commandEnd;
for (unsigned i = 0; i < menuOptions.get_count(); i++) {
- if (strncmp(buffer + startIndex, menuOptions[i].get_name(), commandEnd) == 0) {
+ if (strncmp(buffer, menuOptions[i].get_name(), commandEnd) == 0) {
index = i;
break;
}
}
- if (index > menuOptions.get_count()) {
+ if (index == menuOptions.get_count()) {
printLine("Invalid menu option!");
continue;
}