Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Generic / ConsoleInterface / Menu.cpp
diff options
context:
space:
mode:
Commit2d77f9881df1e2e93cd367e9a2be320de0215fcf (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-05-29 08:39:00 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-05-29 08:39:00 +0300
Files9f79c9c86987782975315e5c020d0b8538a3096b /src/Generic/ConsoleInterface/Menu.cpp
FMI-OOP-P2_Tables-2d77f9881df1e2e93cd367e9a2be320de0215fcf.tar
FMI-OOP-P2_Tables-2d77f9881df1e2e93cd367e9a2be320de0215fcf.tar.gz
FMI-OOP-P2_Tables-2d77f9881df1e2e93cd367e9a2be320de0215fcf.zip
Parent51e29b000ab58844060bdaea1a916a6ce637cec6 (diff)
Autocommit at 29.05.2022 @ 08:39
1 files changed, 11 insertions, 13 deletions
-rw-r--r--src/Generic/ConsoleInterface/Menu.cpp24
diff --git a/src/Generic/ConsoleInterface/Menu.cpp b/src/Generic/ConsoleInterface/Menu.cpp
index 90efc60..23b3c31 100644
--- a/src/Generic/ConsoleInterface/Menu.cpp
+++ b/src/Generic/ConsoleInterface/Menu.cpp
@@ -35,27 +35,25 @@ void Menu::navigate() const {
char buffer[MAX_LINE_WIDTH];
- while (strncmp(buffer, "quit", 4) != 0) {
- unsigned startIndex = 0;
- inputLineBox(buffer, MAX_LINE_WIDTH, true);
-
- std::cout << "\"" << buffer << "\"" << std::endl;
+ unsigned startIndex, commandEnd, index;
+ while (1) {
+ startIndex = 0;
+ inputLineBox(buffer, MAX_LINE_WIDTH, false);
while (buffer[startIndex] == ' ') startIndex++;
- unsigned commandEnd = startIndex;
+ if (strncmp(buffer + startIndex, "quit", 4) == 0)
+ break;
+
+ 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 = 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)
index = i;
- break;
- }
}
- std::cout << menuOptions.get_count() << " " << index << std::endl;
if (index == menuOptions.get_count()) {
printLine("Invalid menu option!");