vis

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

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

commit 274bc3ae21ebba6e19c8834e97df0913fe4b8d31
parent bb8ec4fdee6d169f1079f3ff7956b3ec83bc24e1
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Fri, 25 Nov 2016 16:41:53 +0100

vis-menu: also re-open /dev/tty as stderr

This means vis-menu will also work when stderr is used for other purposes.

This will be used by the vis editor:

 - stdin is used for the initial completion candidates
 - stdout is used to return the selected entry
 - stderr is used for error reporting

Diffstat:
Mvis-menu.c | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/vis-menu.c b/vis-menu.c @@ -201,6 +201,7 @@ drawmenu(void) { } fprintf(stderr, "\033[%iG", (int)(promptw+textwn(text, cursor)-1)); + fflush(stderr); } static char* @@ -317,7 +318,8 @@ setup(void) { struct winsize ws; /* re-open stdin to read keyboard */ - if (!freopen("/dev/tty", "r", stdin)) die("Can't reopen tty."); + if (!freopen("/dev/tty", "r", stdin)) die("Can't reopen tty as stdin."); + if (!freopen("/dev/tty", "w", stderr)) die("Can't reopen tty as stderr."); /* ioctl() the tty to get size */ fd = open("/dev/tty", O_RDWR);