diff options
| Commit | 32ba99f3203b1392f8a850f0ac4b142f83a74953 (patch) | |
|---|---|---|
| Author | 2022-05-29 08:18:53 +0300 | |
| Committer | 2022-05-29 08:18:53 +0300 | |
| Files | 4bb71cbbad8f12f90d9c8a1ec95292b2f0ec4ce4 /src | |
| FMI-OOP-P2_Tables-32ba99f3203b1392f8a850f0ac4b142f83a74953.tar FMI-OOP-P2_Tables-32ba99f3203b1392f8a850f0ac4b142f83a74953.tar.gz FMI-OOP-P2_Tables-32ba99f3203b1392f8a850f0ac4b142f83a74953.zip | ||
| Parent | da44817c4faa2d15c4e08637d51b52e78e99e54c (diff) | |
Autocommit at 29.05.2022 @ 08:18
6 files changed, 14 insertions, 26 deletions
| -rw-r--r-- | src/Generic/ConsoleInterface/Menu.cpp | 1 | ||||
| -rw-r--r-- | src/Generic/ConsoleInterface/Toolbox.cpp | 11 | ||||
| -rw-r--r-- | src/Generic/ConsoleInterface/Toolbox.hpp | 3 | ||||
| -rw-r--r-- | src/UserInterface/UserInterface.cpp | 18 | ||||
| -rw-r--r-- | src/UserInterface/UserInterface.h | 5 | ||||
| -rw-r--r-- | src/main.cpp | 2 |
diff --git a/src/Generic/ConsoleInterface/Menu.cpp b/src/Generic/ConsoleInterface/Menu.cpp index 32f5104..cde9aae 100644 --- a/src/Generic/ConsoleInterface/Menu.cpp +++ b/src/Generic/ConsoleInterface/Menu.cpp @@ -36,7 +36,6 @@ void Menu::navigate() const { unsigned startIndex = 0; while (strncmp(buffer, "quit", 4) != 0) { - clear(); startIndex = 0; inputLineBox("> ", buffer, MAX_LINE_WIDTH); diff --git a/src/Generic/ConsoleInterface/Toolbox.cpp b/src/Generic/ConsoleInterface/Toolbox.cpp index 8a4470d..cb17b47 100644 --- a/src/Generic/ConsoleInterface/Toolbox.cpp +++ b/src/Generic/ConsoleInterface/Toolbox.cpp @@ -1,16 +1,5 @@ #include "Toolbox.hpp" -/*! - * Erases display and moves cursor to top left corner via ANSI escape sequences: \c ESC[2J \c ESC[1;1H - * - * \warning Not all terminals support any or all ANSI escape sequences - * - * \note Source: https://stackoverflow.com/a/52895729/12036073 - */ -void clear() { - std::cout << u8"\033[2J\033[1;1H"; -} - /* Input line boxes */ void __inputLineBoxGetInput(char* output, unsigned maxWidth, bool ignore) { diff --git a/src/Generic/ConsoleInterface/Toolbox.hpp b/src/Generic/ConsoleInterface/Toolbox.hpp index cc6e5c1..99489f5 100644 --- a/src/Generic/ConsoleInterface/Toolbox.hpp +++ b/src/Generic/ConsoleInterface/Toolbox.hpp @@ -15,9 +15,6 @@ #define MAX_LINE_WIDTH 1024 -//! Clears the console screen -void clear(); - //! 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); diff --git a/src/UserInterface/UserInterface.cpp b/src/UserInterface/UserInterface.cpp index a536345..726d683 100644 --- a/src/UserInterface/UserInterface.cpp +++ b/src/UserInterface/UserInterface.cpp @@ -5,20 +5,24 @@ /* Private (static) */ +Table* UserInterface::table = nullptr; + void UserInterface::com_print(const char* params) { - List<String> cells = table.getAllCells(); + List<String> cells = table->getAllCells(); +} + +void UserInterface::com_edit(const char* params) { + //TODO } /* Public */ -UserInterface::UserInterface(Table& inTable) : menu() { - if (!instantiated) { +UserInterface::UserInterface(Table* inTable) : menu() { + if (table == nullptr) table = inTable; - instantiated = true; - } - menu.addCommand(Command("print", &UserInterface::com_print)); - menu.addCommand(Command("edit", &UserInterface::com_edit)); + menu.addCommand(Command("print", com_print)); + menu.addCommand(Command("edit", com_edit)); } void UserInterface::run() { diff --git a/src/UserInterface/UserInterface.h b/src/UserInterface/UserInterface.h index 1455ce4..42d323c 100644 --- a/src/UserInterface/UserInterface.h +++ b/src/UserInterface/UserInterface.h @@ -7,8 +7,7 @@ class UserInterface { Menu menu; - static bool instantiated; - static Table& table; + static Table* table; static void com_open(const char* params); static void com_close(const char* params); @@ -21,7 +20,7 @@ class UserInterface { static void com_edit(const char* params); public: - UserInterface(Table& table); + UserInterface(Table* table); void run(); }; diff --git a/src/main.cpp b/src/main.cpp index 3ce8563..d620889 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,6 +2,6 @@ int main() { Table table(5, 5); - UserInterface ui(table); + UserInterface ui(&table); ui.run(); } |
