vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 2b18c8ee30a26d342d539bc85b882d23fbce9900
parent 4d10e732821ddb29beee10edf1db6483d2118fa6
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Wed, 12 Aug 2015 19:14:43 +0200

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:
Mui-curses.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 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;