aboutsummaryrefslogtreecommitdiff
path: root/vis-menu.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-11-25 16:41:53 +0100
committerMarc André Tanner <mat@brain-dump.org>2016-11-25 16:41:53 +0100
commit1c9c52647fe2984472246eb2c12b3412fd5fafa4 (patch)
treeb8324ddd02b777233529995b2020ad97e379031c /vis-menu.c
parente9f28e98dd09a444fe5ce8a149745e08f9d4228e (diff)
downloadvis-1c9c52647fe2984472246eb2c12b3412fd5fafa4.tar.gz
vis-1c9c52647fe2984472246eb2c12b3412fd5fafa4.tar.xz
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 (limited to 'vis-menu.c')
-rw-r--r--vis-menu.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/vis-menu.c b/vis-menu.c
index a37e7df..a5023e2 100644
--- 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);