From f2ca647734572a2ab85228126c7b4c560536da52 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 29 May 2022 08:28:57 +0300 Subject: Autocommit at 29.05.2022 @ 08:28 --- src/Generic/ConsoleInterface/Menu.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/Generic/ConsoleInterface/Menu.cpp') 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!"); -- cgit v1.3.1-23-gd82d