Enhance main menu functionality: increase window height, add menu options, and implement keyboard input handling for navigation.

This commit is contained in:
2025-05-15 15:37:45 +02:00
parent 7800666839
commit 24d9cc8b17
2 changed files with 46 additions and 2 deletions
+1 -1
View File
@@ -60,7 +60,6 @@ int main(int argc, char const **argv)
pthread_mutex_init(&person_list.lock, NULL); pthread_mutex_init(&person_list.lock, NULL);
loadListFromCSV(argv[1], &person_list); loadListFromCSV(argv[1], &person_list);
saveListToCSV("khohotjorjijer.csv", &person_list);
noecho(); noecho();
noraw(); noraw();
@@ -70,6 +69,7 @@ int main(int argc, char const **argv)
assume_default_colors(COLOR_WHITE, COLOR_BLUE); assume_default_colors(COLOR_WHITE, COLOR_BLUE);
erase(); erase();
printw("LightTAM Server");
refresh(); refresh();
uartDialog(uart_address, x_max, y_max); uartDialog(uart_address, x_max, y_max);
+45 -1
View File
@@ -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) 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 win_width = 80;
int start_y = (terminal_y - win_height) / 2; int start_y = (terminal_y - win_height) / 2;
int start_x = (terminal_x - win_width) / 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(); start_color();
init_pair(1, COLOR_BLACK, COLOR_WHITE); init_pair(1, COLOR_BLACK, COLOR_WHITE);
init_pair(2, COLOR_WHITE, COLOR_RED); 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)); wattron(uartwin, COLOR_PAIR(1));
wattroff(uartwin, COLOR_PAIR(1)); wattroff(uartwin, COLOR_PAIR(1));
keypad(uartwin, true);
int text_x = (win_width - 52) / 2;
wrefresh(uartwin); 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;
}
}
}
}
} }