commit 04f0cf1dc33caf82a133b2e55af1a98f503f2566
parent d54bc47feed3bdbdce72554ef8ecb0979bf4af63
Author: Martin Kloeckner <mjkloeckner@gmail.com>
Date: Fri, 15 Mar 2024 01:30:23 -0300
Make cursor indicator a `string`
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/solutions/ej11.cpp b/solutions/ej11.cpp
@@ -12,7 +12,7 @@ using namespace std;
const unsigned int menu_items = 4;
static struct termios default_attributes;
-char cursor[menu_items] = {0};
+string *cursor = new string[menu_items];
unsigned int cursor_pos;
bool run_program;
@@ -61,7 +61,7 @@ void reset_input_mode (void) {
void print_menu(void) {
for(size_t i = 0; i < menu_items; ++i) {
- cursor[cursor_pos] = ((i == cursor_pos) ? '>' : ' ');
+ cursor[cursor_pos].assign(((i == cursor_pos) ? " >" : " "));
cout << cursor[cursor_pos] << menu[i] << (i == menu_items ? "" : "\n")
<< flush;
}