aboutsummaryrefslogtreecommitdiff
path: root/ui-curses.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-08-12 19:14:43 +0200
committerMarc André Tanner <mat@brain-dump.org>2015-08-12 19:14:43 +0200
commitc034f9ded7a2b827f7f09fed8a0c531fd96a11b0 (patch)
tree043cdf047a17761c99899c46e288fd77bea53421 /ui-curses.c
parent9eb33f5146709c75baebba3ea6d019ab98f7ae35 (diff)
downloadvis-c034f9ded7a2b827f7f09fed8a0c531fd96a11b0.tar.gz
vis-c034f9ded7a2b827f7f09fed8a0c531fd96a11b0.tar.xz
ui: query terminal size on stderr
We always draw the editor user interface to stderr in order to allow usage as a filter e.g. $ echo Hello | vis - | grep World > out hence stdin might be redirected and we should always read the terminal size from stderr. Closes #66
Diffstat (limited to 'ui-curses.c')
-rw-r--r--ui-curses.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/ui-curses.c b/ui-curses.c
index 569b2ca..30e8c94 100644
--- a/ui-curses.c
+++ b/ui-curses.c
@@ -1,3 +1,4 @@
+#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
@@ -300,7 +301,7 @@ static void ui_resize(Ui *ui) {
struct winsize ws;
int width, height;
- if (ioctl(0, TIOCGWINSZ, &ws) == -1) {
+ if (ioctl(STDERR_FILENO, TIOCGWINSZ, &ws) == -1) {
getmaxyx(stdscr, height, width);
} else {
width = ws.ws_col;