[hamradio-commits] [dump1090] 271/389: WIZARDISHUNGRY
Matthew Ernisse
mernisse-guest at moszumanska.debian.org
Wed Nov 5 00:20:04 UTC 2014
This is an automated email from the git hooks/post-receive script.
mernisse-guest pushed a commit to branch master
in repository dump1090.
commit 86093ea95e0ca586397757d422d72c5d5ffdb870
Author: Malcolm Robb <Support at ATTAvionics.com>
Date: Sat Feb 22 22:11:11 2014 +0000
WIZARDISHUNGRY
Dynamically size terminal using SIGWINCH
https://github.com/antirez/dump1090/commit/f18180fef4ea6e0195d55439d93c4d717c35da8f
---
dump1090.c | 28 +++++++++++++++++++++++++++-
dump1090.h | 3 ++-
view1090.c | 28 +++++++++++++++++++++++++++-
3 files changed, 56 insertions(+), 3 deletions(-)
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 <fcntl.h>
#include <ctype.h>
#include <sys/stat.h>
+ #include <sys/ioctl.h>
#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();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/dump1090.git
More information about the pkg-hamradio-commits
mailing list