Enhance UART handling and improve TUI input management
This commit is contained in:
@@ -29,64 +29,76 @@ void uartDialog(char *uart_adress, int terminal_x, int terminal_y)
|
||||
wattroff(uartwin, COLOR_PAIR(1));
|
||||
wrefresh(uartwin);
|
||||
|
||||
// menu...
|
||||
int choice;
|
||||
char choice;
|
||||
int highlight = 0;
|
||||
|
||||
keypad(uartwin, TRUE);
|
||||
int text_x = (win_width - 52) / 2;
|
||||
int button_x = (win_width - 7) / 2;
|
||||
|
||||
keypad(uartwin, true);
|
||||
while (1)
|
||||
{
|
||||
int text_x = (win_width - 52) / 2;
|
||||
// Input array
|
||||
if (highlight == 0)
|
||||
{
|
||||
wattron(uartwin, COLOR_PAIR(2));
|
||||
mvwprintw(uartwin, 5, text_x, "[__________________________________________________]");
|
||||
wattroff(uartwin, COLOR_PAIR(2));
|
||||
}
|
||||
else
|
||||
wattron(uartwin, COLOR_PAIR(1));
|
||||
|
||||
mvwprintw(uartwin, 5, text_x, "[%50s]", input);
|
||||
if (!strcmp(input, "\0"))
|
||||
mvwprintw(uartwin, 5, text_x, "[__________________________________________________]");
|
||||
|
||||
int button_x = (win_width - 7) / 2;
|
||||
if (highlight == 1)
|
||||
{
|
||||
wattron(uartwin, COLOR_PAIR(2));
|
||||
mvwprintw(uartwin, 7, button_x, "<Enter>");
|
||||
if (highlight == 0)
|
||||
wattroff(uartwin, COLOR_PAIR(2));
|
||||
}
|
||||
mvwprintw(uartwin, 7, button_x, "<Enter>");
|
||||
else
|
||||
wattroff(uartwin, COLOR_PAIR(1));
|
||||
|
||||
// Enter button
|
||||
if (highlight == 1)
|
||||
wattron(uartwin, COLOR_PAIR(2));
|
||||
else
|
||||
wattron(uartwin, COLOR_PAIR(1));
|
||||
mvwprintw(uartwin, 7, button_x - 2, " %s ", "<Enter>");
|
||||
if (highlight == 1)
|
||||
wattroff(uartwin, COLOR_PAIR(2));
|
||||
else
|
||||
wattroff(uartwin, COLOR_PAIR(1));
|
||||
wrefresh(uartwin);
|
||||
|
||||
flushinp();
|
||||
choice = wgetch(uartwin);
|
||||
|
||||
if (choice == '\t')
|
||||
{
|
||||
highlight=!highlight;
|
||||
highlight = !highlight;
|
||||
}
|
||||
|
||||
if (highlight == 0)
|
||||
else if (choice == '\n')
|
||||
{
|
||||
wattron(uartwin, COLOR_PAIR(2));
|
||||
mvwprintw(uartwin, 5, (win_width - 52) / 2, "[__________________________________________________]");
|
||||
echo();
|
||||
wmove(uartwin, 5, ((win_width - 52) / 2) + 1);
|
||||
curs_set(1);
|
||||
flushinp();
|
||||
wgetnstr(uartwin, input, 50);
|
||||
curs_set(0);
|
||||
wattroff(uartwin, COLOR_PAIR(2));
|
||||
noecho();
|
||||
}
|
||||
else if (highlight == 1)
|
||||
{
|
||||
if (choice == '\n')
|
||||
if (highlight == 0)
|
||||
{
|
||||
wclear(uartwin);
|
||||
wrefresh(uartwin);
|
||||
touchwin(stdscr);
|
||||
refresh();
|
||||
delwin(uartwin);
|
||||
refresh();
|
||||
strcpy(uart_adress, input);
|
||||
break;
|
||||
mvwprintw(uartwin, 5, (win_width - 52) / 2, "[__________________________________________________]");
|
||||
echo();
|
||||
wmove(uartwin, 5, ((win_width - 52) / 2) + 1);
|
||||
curs_set(1);
|
||||
flushinp();
|
||||
wgetnstr(uartwin, input, 50);
|
||||
curs_set(0);
|
||||
noecho();
|
||||
}
|
||||
else if (highlight == 1)
|
||||
{
|
||||
if (choice == '\n')
|
||||
{
|
||||
wclear(uartwin);
|
||||
wrefresh(uartwin);
|
||||
touchwin(stdscr);
|
||||
refresh();
|
||||
delwin(uartwin);
|
||||
refresh();
|
||||
strcpy(uart_adress, input);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user