Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Generic / ConsoleInterface / Menu.cpp
diff options
context:
space:
mode:
Commitdd8ff49d2bd29f08c5a6afa39d89dba3d715ee4a (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-05-30 20:33:26 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-05-30 20:33:26 +0300
Filesb012e52c5b2bd32ee55e3f59d341bfe4c493a873 /src/Generic/ConsoleInterface/Menu.cpp
FMI-OOP-P2_Tables-dd8ff49d2bd29f08c5a6afa39d89dba3d715ee4a.tar
FMI-OOP-P2_Tables-dd8ff49d2bd29f08c5a6afa39d89dba3d715ee4a.tar.gz
FMI-OOP-P2_Tables-dd8ff49d2bd29f08c5a6afa39d89dba3d715ee4a.zip
Parent2929a4a6e811ddc2c2073158f50d2e20170c6c6a (diff)
Autocommit at 30.05.2022 @ 20:33
1 files changed, 9 insertions, 5 deletions
-rw-r--r--src/Generic/ConsoleInterface/Menu.cpp14
diff --git a/src/Generic/ConsoleInterface/Menu.cpp b/src/Generic/ConsoleInterface/Menu.cpp
index d547990..9c2fca5 100644
--- a/src/Generic/ConsoleInterface/Menu.cpp
+++ b/src/Generic/ConsoleInterface/Menu.cpp
@@ -36,15 +36,13 @@ void Menu::navigate() const {
char buffer[MAX_LINE_WIDTH];
unsigned startIndex, commandEnd, paramsStart, index;
- while (1) {
+ bool hasThrown = false;
+ while (!hasThrown) {
startIndex = 0;
inputLineBox(buffer, MAX_LINE_WIDTH, false);
while (buffer[startIndex] == ' ') startIndex++;
- if (strncmp(buffer + startIndex, "quit", 4) == 0)
- break;
-
commandEnd = startIndex;
while (buffer[commandEnd] != ' ' && buffer[commandEnd] != '\n' && buffer[commandEnd] != '\0')
commandEnd++;
@@ -63,6 +61,12 @@ void Menu::navigate() const {
continue;
}
- menuOptions[index].run(buffer + paramsStart);
+ try {
+ menuOptions[index].run(buffer + paramsStart);
+ }
+ catch (std::logic_error err) {
+ hasThrown = true;
+ printLine(err.what());
+ }
}
}