Use ncurses for interactive mode (reduces flicker on slow connections a lot!)

This commit is contained in:
Oliver Jowett 2016-10-11 20:37:28 +01:00
parent 25ea6d398b
commit f6b1b94c7d
6 changed files with 82 additions and 141 deletions

View file

@ -36,27 +36,7 @@ void sigintHandler(int dummy) {
signal(SIGINT, SIG_DFL); // reset signal handler - bit extra safety
Modes.exit = 1; // Signal to threads that we are done
}
//
// =============================== Terminal handling ========================
//
#ifndef _WIN32
// Get the number of rows after the terminal changes size.
int getTermRows() {
struct winsize w;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
return (w.ws_row);
}
// Handle resizing terminal
void sigWinchCallback() {
signal(SIGWINCH, SIG_IGN);
Modes.interactive_rows = getTermRows();
interactiveShowData();
signal(SIGWINCH, sigWinchCallback);
}
#else
int getTermRows() { return MODES_INTERACTIVE_ROWS;}
#endif
//
// =============================== Initialization ===========================
//
@ -66,7 +46,6 @@ void view1090InitConfig(void) {
// Now initialise things that should not be 0/NULL to their defaults
Modes.check_crc = 1;
Modes.interactive_rows = getTermRows();
Modes.interactive_display_ttl = MODES_INTERACTIVE_DISPLAY_TTL;
Modes.interactive = 1;
Modes.maxRange = 1852 * 300; // 300NM default max range
@ -113,6 +92,7 @@ void view1090Init(void) {
modesChecksumInit(Modes.nfix_crc);
icaoFilterInit();
modeACInit();
interactiveInit();
}
//
@ -124,9 +104,7 @@ void showHelp(void) {
"| view1090 ModeS Viewer %45s |\n"
"-----------------------------------------------------------------------------\n"
"--no-interactive Disable interactive mode, print messages to stdout\n"
"--interactive-rows <num> Max number of rows in interactive mode (default: 15)\n"
"--interactive-ttl <sec> Remove from list if idle for <sec> (default: 60)\n"
"--interactive-rtl1090 Display flight table in RTL1090 format\n"
"--modeac Enable decoding of SSR modes 3/A & 3/C\n"
"--net-bo-ipaddr <IPv4> TCP Beast output listen IPv4 (default: 127.0.0.1)\n"
"--net-bo-port <port> TCP Beast output listen port (default: 30005)\n"
@ -169,8 +147,6 @@ int main(int argc, char **argv) {
bo_connect_ipaddr = argv[++j];
} else if (!strcmp(argv[j],"--modeac")) {
Modes.mode_ac = 1;
} else if (!strcmp(argv[j],"--interactive-rows") && more) {
Modes.interactive_rows = atoi(argv[++j]);
} else if (!strcmp(argv[j],"--no-interactive")) {
Modes.interactive = 0;
} else if (!strcmp(argv[j],"--show-only") && more) {
@ -178,9 +154,6 @@ int main(int argc, char **argv) {
Modes.interactive = 0;
} else if (!strcmp(argv[j],"--interactive-ttl") && more) {
Modes.interactive_display_ttl = (uint64_t)(1000 * atof(argv[++j]));
} else if (!strcmp(argv[j],"--interactive-rtl1090")) {
Modes.interactive = 1;
Modes.interactive_rtl1090 = 1;
} else if (!strcmp(argv[j],"--lat") && more) {
Modes.fUserLat = atof(argv[++j]);
} else if (!strcmp(argv[j],"--lon") && more) {
@ -213,11 +186,6 @@ int main(int argc, char **argv) {
#define MSG_DONTWAIT 0
#endif
#ifndef _WIN32
// Setup for SIGWINCH for handling lines
if (Modes.interactive) {signal(SIGWINCH, sigWinchCallback);}
#endif
// Initialization
view1090Init();
modesInitNet();
@ -249,6 +217,7 @@ int main(int argc, char **argv) {
usleep(100000);
}
interactiveCleanup();
return (0);
}
//