aboutsummaryrefslogtreecommitdiff
path: root/src/sdtui.c
diff options
context:
space:
mode:
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)
{