Website Summary Files Commits Branches @commit @diff @stats
path: root / src / ConsoleInterface
diff options
context:
space:
mode:
Commit8796882268879807962441c1667ad32cf08938c2 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-05 15:03:56 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-05 15:03:56 +0300
Files61c4037fc074a109619008dcc7f29dd7d8ed59ad /src/ConsoleInterface
FMI-OOP-P1_TicketSystem-8796882268879807962441c1667ad32cf08938c2.tar
FMI-OOP-P1_TicketSystem-8796882268879807962441c1667ad32cf08938c2.tar.gz
FMI-OOP-P1_TicketSystem-8796882268879807962441c1667ad32cf08938c2.zip
Parent110fdbde950490a1911c6033a602519f609b3192 (diff)
Autocommit at 05.05.2022 @ 15:03
3 files changed, 14 insertions, 9 deletions
-rw-r--r--src/ConsoleInterface/Menu.cpp10
-rw-r--r--src/ConsoleInterface/Menu.h3
-rw-r--r--src/ConsoleInterface/Toolbox.cpp10
diff --git a/src/ConsoleInterface/Menu.cpp b/src/ConsoleInterface/Menu.cpp
index 9c24d41..bc1c5f1 100644
--- a/src/ConsoleInterface/Menu.cpp
+++ b/src/ConsoleInterface/Menu.cpp
@@ -1,10 +1,14 @@
#include "Menu.h"
#include "Toolbox.hpp"
+#include <cstring>
-Menu::Menu() : menuOptions() {}
+Menu::Menu() : menuOptions() {
+ strcpy(title, "Menu");
+}
-Menu::Menu(const Command* commands, unsigned commandCount) {
+Menu::Menu(const Command* commands, unsigned commandCount, const char* title) {
menuOptions = List<Command>(commands, commandCount);
+ strcpy(this->title, title);
}
void Menu::addCommand(const Command& command) {
@@ -20,6 +24,8 @@ void Menu::navigate() const {
unsigned buffer = 1; // We immedeately read the value of buffer, so this is fine
while (buffer != 0) {
+ printTitle(title);
+
resetOrderedList(0);
printOrderedListElem("Go Back");
for (unsigned i = 0; i < menuOptions.get_count(); i++)
diff --git a/src/ConsoleInterface/Menu.h b/src/ConsoleInterface/Menu.h
index 5298b4b..37bdf48 100644
--- a/src/ConsoleInterface/Menu.h
+++ b/src/ConsoleInterface/Menu.h
@@ -8,10 +8,9 @@ class Menu {
char title[256];
List<Command> menuOptions;
-
public:
Menu();
- Menu(const Command* commands, unsigned commandCount);
+ Menu(const Command* commands, unsigned commandCount, const char* title);
void addCommand(const Command& command);
void navigate() const;
diff --git a/src/ConsoleInterface/Toolbox.cpp b/src/ConsoleInterface/Toolbox.cpp
index 20f07db..d31aa91 100644
--- a/src/ConsoleInterface/Toolbox.cpp
+++ b/src/ConsoleInterface/Toolbox.cpp
@@ -7,11 +7,11 @@ void resetOrderedList(int starter) {
}
void _printOrderedListBeginning() {
- std::cout << orderedListIndex++ << ". ";
+ std::cout << "[" << orderedListIndex++ << "] ";
}
void _printInputBoxLabel(const char* label) {
- std::cout << "+ " << label;
+ std::cout << "<+> " << label;
}
void inputLineBox(const char* label, char* output, unsigned maxWidth) {
@@ -20,14 +20,14 @@ void inputLineBox(const char* label, char* output, unsigned maxWidth) {
}
void printTitle(const char* title) {
- std::cout << "## " << title << " ##" << std::endl;
+ std::cout << std::endl << "### " << title << " ###" << std::endl<< std::endl;
}
void printSuccess(const char* message) {
- std::cout << ") " << message << std::endl;
+ std::cout << "... " << message << std::endl;
}
void printError(const char* message) {
- std::cout << "! Err: " << message << std::endl;
+ std::cout << "!!! Err: " << message << std::endl;
}