diff options
| Commit | 2d77f9881df1e2e93cd367e9a2be320de0215fcf (patch) | |
|---|---|---|
| Author | 2022-05-29 08:39:00 +0300 | |
| Committer | 2022-05-29 08:39:00 +0300 | |
| Files | 9f79c9c86987782975315e5c020d0b8538a3096b /src | |
| FMI-OOP-P2_Tables-2d77f9881df1e2e93cd367e9a2be320de0215fcf.tar FMI-OOP-P2_Tables-2d77f9881df1e2e93cd367e9a2be320de0215fcf.tar.gz FMI-OOP-P2_Tables-2d77f9881df1e2e93cd367e9a2be320de0215fcf.zip | ||
| Parent | 51e29b000ab58844060bdaea1a916a6ce637cec6 (diff) | |
Autocommit at 29.05.2022 @ 08:39
3 files changed, 14 insertions, 13 deletions
| -rw-r--r-- | src/Generic/ConsoleInterface/Menu.cpp | 24 | ||||
| -rw-r--r-- | src/Models/Table.h | 1 | ||||
| -rw-r--r-- | src/UserInterface/UserInterface.cpp | 2 |
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!"); diff --git a/src/Models/Table.h b/src/Models/Table.h index 6fb516a..23b518d 100644 --- a/src/Models/Table.h +++ b/src/Models/Table.h @@ -9,6 +9,7 @@ class Table { public: Table(unsigned rows, unsigned cols); + unsigned get_cols() const; void putCell(unsigned row, unsigned col, const char* rawValue); List<String> getAllCells() const; diff --git a/src/UserInterface/UserInterface.cpp b/src/UserInterface/UserInterface.cpp index 726d683..f216afa 100644 --- a/src/UserInterface/UserInterface.cpp +++ b/src/UserInterface/UserInterface.cpp @@ -1,6 +1,7 @@ #include "UserInterface.h" #include "../Generic/List/List.hpp" #include "../Generic/String/String.h" +#include "../Generic/ConsoleInterface/Toolbox.hpp" #include <stdexcept> /* Private (static) */ @@ -9,6 +10,7 @@ Table* UserInterface::table = nullptr; void UserInterface::com_print(const char* params) { List<String> cells = table->getAllCells(); + table(cells, table.get_cols()); } void UserInterface::com_edit(const char* params) { |
