diff --git a/dump1090.c b/dump1090.c index a6e3c59..3cef7be 100644 --- a/dump1090.c +++ b/dump1090.c @@ -38,6 +38,27 @@ void sigintHandler(int dummy) { 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 =========================== // void modesInitConfig(void) { @@ -54,7 +75,7 @@ void modesInitConfig(void) { Modes.net_output_beast_port = MODES_NET_OUTPUT_BEAST_PORT; Modes.net_input_beast_port = MODES_NET_INPUT_BEAST_PORT; Modes.net_http_port = MODES_NET_HTTP_PORT; - Modes.interactive_rows = MODES_INTERACTIVE_ROWS; + Modes.interactive_rows = getTermRows(); Modes.interactive_delete_ttl = MODES_INTERACTIVE_DELETE_TTL; Modes.interactive_display_ttl = MODES_INTERACTIVE_DISPLAY_TTL; Modes.fUserLat = MODES_USER_LATITUDE_DFLT; @@ -532,6 +553,11 @@ int main(int argc, char **argv) { } } +#ifndef _WIN32 + // Setup for SIGWINCH for handling lines + if (Modes.interactive) {signal(SIGWINCH, sigWinchCallback);} +#endif + // Initialization modesInit(); diff --git a/dump1090.h b/dump1090.h index 094141b..6099c91 100644 --- a/dump1090.h +++ b/dump1090.h @@ -37,7 +37,7 @@ // MinorVer changes when additional features are added, but not for bug fixes (range 00-99) // DayDate & Year changes for all changes, including for bug fixes. It represent the release date of the update // -#define MODES_DUMP1090_VERSION "1.07.0710.13" +#define MODES_DUMP1090_VERSION "1.07.2202.14" // ============================= Include files ========================== @@ -56,6 +56,7 @@ #include #include #include + #include #include "rtl-sdr.h" #include "anet.h" #else diff --git a/view1090.c b/view1090.c index 32289fc..ae9ee89 100644 --- a/view1090.c +++ b/view1090.c @@ -38,6 +38,27 @@ void sigintHandler(int dummy) { 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 =========================== // void view1090InitConfig(void) { @@ -49,7 +70,7 @@ void view1090InitConfig(void) { Modes.check_crc = 1; strcpy(View1090.net_input_beast_ipaddr,VIEW1090_NET_OUTPUT_IP_ADDRESS); Modes.net_input_beast_port = MODES_NET_OUTPUT_BEAST_PORT; - Modes.interactive_rows = MODES_INTERACTIVE_ROWS; + Modes.interactive_rows = getTermRows(); Modes.interactive_delete_ttl = MODES_INTERACTIVE_DELETE_TTL; Modes.interactive_display_ttl = MODES_INTERACTIVE_DISPLAY_TTL; Modes.fUserLat = MODES_USER_LATITUDE_DFLT; @@ -174,6 +195,11 @@ int main(int argc, char **argv) { } } +#ifndef _WIN32 + // Setup for SIGWINCH for handling lines + if (Modes.interactive) {signal(SIGWINCH, sigWinchCallback);} +#endif + // Initialization view1090Init();