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