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
+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)
{
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;
}
}
}
}
}