aboutsummaryrefslogtreecommitdiff
path: root/src/sdtui.c
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-10-15 12:08:44 +0200
committerPřemysl Eric Janouch <p@janouch.name>2021-10-15 12:09:37 +0200
commit573554b9decf74f3b57ab6d26252700132255525 (patch)
tree849a1472bb630e2bbebb880108df463aef905f37 /src/sdtui.c
parent9d7bc2a839b5f5200489a64c348acc02ee6ceb8f (diff)
downloadtdv-573554b9decf74f3b57ab6d26252700132255525.tar.gz
tdv-573554b9decf74f3b57ab6d26252700132255525.tar.xz
tdv-573554b9decf74f3b57ab6d26252700132255525.zip
sdgtk -> sdgui, improve build, mention in README
It's finally not horrible.
Diffstat (limited to 'src/sdtui.c')
-rw-r--r--src/sdtui.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/sdtui.c b/src/sdtui.c
index 3be34f4..1158d05 100644
--- a/src/sdtui.c
+++ b/src/sdtui.c
@@ -36,8 +36,12 @@
#include <signal.h>
#include <pwd.h>
-#include <termo.h> // input
-#include <ncurses.h> // output
+#include <termo.h> // input
+#include <ncurses.h> // output
+#include <termios.h>
+#ifndef TIOCGWINSZ
+#include <sys/ioctl.h>
+#endif // ! TIOCGWINSZ
#include "config.h"
#include "stardict.h"
@@ -62,6 +66,27 @@ unichar_width (gunichar ch)
return 1 + g_unichar_iswide (ch);
}
+void
+update_curses_terminal_size (void)
+{
+#if defined (HAVE_RESIZETERM) && defined (TIOCGWINSZ)
+ struct winsize size;
+ if (!ioctl (STDOUT_FILENO, TIOCGWINSZ, (char *) &size))
+ {
+ char *row = getenv ("LINES");
+ char *col = getenv ("COLUMNS");
+ unsigned long tmp;
+ resizeterm (
+ (row && xstrtoul (&tmp, row, 10)) ? tmp : size.ws_row,
+ (col && xstrtoul (&tmp, col, 10)) ? tmp : size.ws_col);
+ }
+#else // HAVE_RESIZETERM && TIOCGWINSZ
+ // The standard endwin/refresh sequence makes the terminal flicker.
+ endwin ();
+ refresh ();
+#endif // HAVE_RESIZETERM && TIOCGWINSZ
+}
+
static guint
add_read_watch (int fd, GIOFunc func, gpointer user_data)
{