Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Generic / ConsoleInterface
diff options
context:
space:
mode:
Commitf3671d418a098f1fd7aa530b2ef6c975193fce1f (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-05-28 20:20:03 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-05-28 20:20:03 +0300
Filesdc2a266d711b535410b05bfeda005ec66f6ca689 /src/Generic/ConsoleInterface
FMI-OOP-P2_Tables-f3671d418a098f1fd7aa530b2ef6c975193fce1f.tar
FMI-OOP-P2_Tables-f3671d418a098f1fd7aa530b2ef6c975193fce1f.tar.gz
FMI-OOP-P2_Tables-f3671d418a098f1fd7aa530b2ef6c975193fce1f.zip
Parent1aaef6ff5bf41bfccba8944f734dea3434ac2bfc (diff)
Autocommit at 28.05.2022 @ 20:20
2 files changed, 15 insertions, 26 deletions
-rw-r--r--src/Generic/ConsoleInterface/Menu.cpp19
-rw-r--r--src/Generic/ConsoleInterface/Toolbox.hpp22
diff --git a/src/Generic/ConsoleInterface/Menu.cpp b/src/Generic/ConsoleInterface/Menu.cpp
index 71bafaf..16032eb 100644
--- a/src/Generic/ConsoleInterface/Menu.cpp
+++ b/src/Generic/ConsoleInterface/Menu.cpp
@@ -28,9 +28,20 @@ void Menu::navigate() const {
clear();
inputLineBox("> ", buffer, MAX_LINE_WIDTH);
- if (buffer > menuOptions.get_count())
- registerError("Invalid menu option!");
- else if (buffer > 0)
- menuOptions[buffer - 1].run();
+ unsigned index = menuOptions.get_count();
+ for (unsigned i = 0; i < menuOptions.get_count(); i++) {
+ if (strncmp(buffer, menuOptions[i].get_nameInMenu(), MAX_LINE_WIDTH) == 0) {
+ index = i;
+ break;
+ }
+ }
+
+ if (index > menuOptions.get_count()) {
+ printline("Invalid menu option!");
+ continue;
+ }
+
+
+ menuOptions[index].run();
}
}
diff --git a/src/Generic/ConsoleInterface/Toolbox.hpp b/src/Generic/ConsoleInterface/Toolbox.hpp
index 4c9544e..4fb8214 100644
--- a/src/Generic/ConsoleInterface/Toolbox.hpp
+++ b/src/Generic/ConsoleInterface/Toolbox.hpp
@@ -15,28 +15,15 @@
//! Clears the console screen
void clear();
-//! Prints a title box
-void titleBox(const char* title);
-//! Prints a title sub box
-void subTitleBox(const char* title);
//! Prints label, gets a whole line of input and stores it to output
void inputLineBox(const char* label, char* output, unsigned maxWidth, bool ignore = true);
-//! Waits for user to press enter
-void pressEnterToContinue(bool ignore = true);
-
-//! Resets the ordered list starting number
-void resetOrderedList(int starter = 1);
//! Prints a string as a table
void table(unsigned startNumber, unsigned columns, const char* items);
-//! Semi-internal function that prints the spacing for sub boxes
-void _printSubBoxSpacing();
//! Semi-internal function that prints the label of an input box
void _printInputBoxLabel(const char* label);
-//! Semi-internal function that prints the latest ordered list index
-void _printOrderedListBeginning();
//! Reads user input and stores it
template <typename T>
@@ -81,13 +68,4 @@ void inputBox(const char* label, T* output) {
std::cin >> *output;
}
-//! Prints a label with sub box spacing and then reads user input and stores it
-//! \sa _printSubBoxSpacing()
-template <typename T>
-void inputSubBox(const char* label, T* output) {
- _printSubBoxSpacing();
- _printInputBoxLabel(label);
- std::cin >> *output;
-}
-
#endif