From 09b94a7471f2ac5b2958f0fee735c692a444b9ba Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 30 May 2022 20:13:18 +0300 Subject: Autocommit at 30.05.2022 @ 20:13 --- src/ test.table | 2 +- src/Generic/ConsoleInterface/Menu.cpp | 9 ++++++--- src/test.table | 5 +++++ 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 src/test.table (limited to 'src') diff --git a/src/ test.table b/src/ test.table index e4ca704..147e7e9 100644 --- a/src/ test.table +++ b/src/ test.table @@ -1,4 +1,4 @@ -8.6,0,"String","= 3 * R0C1 + R0C0 ^ R0C1 * 27 / R0C1 - 2 * 2.5 * 2 * 2 + R0C2 ^ R0C2",, +8.6,3,"String","= 3 * R0C1 + R0C0 ^ R0C1 * 27 / R0C1 - 2 * 2.5 * 2 * 2 + R0C2 ^ R0C2",, ,,,,, ,,,,, ,,,,, diff --git a/src/Generic/ConsoleInterface/Menu.cpp b/src/Generic/ConsoleInterface/Menu.cpp index 23b3c31..910e946 100644 --- a/src/Generic/ConsoleInterface/Menu.cpp +++ b/src/Generic/ConsoleInterface/Menu.cpp @@ -35,7 +35,7 @@ void Menu::navigate() const { char buffer[MAX_LINE_WIDTH]; - unsigned startIndex, commandEnd, index; + unsigned startIndex, commandEnd, paramsStart, index; while (1) { startIndex = 0; inputLineBox(buffer, MAX_LINE_WIDTH, false); @@ -51,15 +51,18 @@ void Menu::navigate() const { 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) + if (strncmp(buffer + startIndex, menuOptions[i].get_name(), commandEnd) == 0) index = i; } + paramsStart = startIndex + commandEnd; + while (buffer[paramsStart] == ' ') paramsStart++; + if (index == menuOptions.get_count()) { printLine("Invalid menu option!"); continue; } - menuOptions[index].run(buffer + startIndex + commandEnd); + menuOptions[index].run(buffer + paramsStart); } } diff --git a/src/test.table b/src/test.table new file mode 100644 index 0000000..e4ca704 --- /dev/null +++ b/src/test.table @@ -0,0 +1,5 @@ +8.6,0,"String","= 3 * R0C1 + R0C0 ^ R0C1 * 27 / R0C1 - 2 * 2.5 * 2 * 2 + R0C2 ^ R0C2",, +,,,,, +,,,,, +,,,,, +,,,,, -- cgit v1.3.1-26-gb76a