From 24d9cc8b17cb6c03f50fe6b139ff71aed465d3ba Mon Sep 17 00:00:00 2001 From: "DLABAL, Eduard" Date: Thu, 15 May 2025 15:37:45 +0200 Subject: [PATCH] Enhance main menu functionality: increase window height, add menu options, and implement keyboard input handling for navigation. --- src/main.c | 2 +- src/tui.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index cb75e19..502fe9e 100644 --- a/src/main.c +++ b/src/main.c @@ -60,7 +60,6 @@ int main(int argc, char const **argv) pthread_mutex_init(&person_list.lock, NULL); loadListFromCSV(argv[1], &person_list); - saveListToCSV("khohotjorjijer.csv", &person_list); noecho(); noraw(); @@ -70,6 +69,7 @@ int main(int argc, char const **argv) assume_default_colors(COLOR_WHITE, COLOR_BLUE); erase(); + printw("LightTAM Server"); refresh(); uartDialog(uart_address, x_max, y_max); diff --git a/src/tui.c b/src/tui.c index e18bd00..123a119 100644 --- a/src/tui.c +++ b/src/tui.c @@ -108,11 +108,16 @@ void uartDialog(char *uart_adress, int terminal_x, int terminal_y) void mainMenu(list_t *person_list, int terminal_x, int terminal_y) { - int win_height = 15; + int win_height = 30; int win_width = 80; int start_y = (terminal_y - win_height) / 2; int start_x = (terminal_x - win_width) / 2; + char choices[6][30] = {"List all employees","Find employee","Edit database","Save","Save as...","Exit"}; + + char keboard_input; + int highlight = 0; + start_color(); init_pair(1, COLOR_BLACK, COLOR_WHITE); init_pair(2, COLOR_WHITE, COLOR_RED); @@ -125,5 +130,44 @@ void mainMenu(list_t *person_list, int terminal_x, int terminal_y) wattron(uartwin, COLOR_PAIR(1)); wattroff(uartwin, COLOR_PAIR(1)); + keypad(uartwin, true); + + int text_x = (win_width - 52) / 2; + wrefresh(uartwin); + + while (1) + { + + flushinp(); + keboard_input = wgetch(uartwin); + + if (keboard_input == '\t') + { + highlight = !highlight; + } + + else if (keboard_input == '\n') + { + if (highlight == 0) + { + + } + else if (highlight == 1) + { + if (keboard_input == '\n') + { + wclear(uartwin); + wrefresh(uartwin); + touchwin(stdscr); + refresh(); + delwin(uartwin); + refresh(); + break; + } + } + } + } } + +