From 18133cb66101c8e8c30dc5c9ffbde7aa756b2935 Mon Sep 17 00:00:00 2001 From: nick black Date: Sun, 7 Feb 2021 21:07:23 -0500 Subject: [PATCH] handle_input: add comment regarding getc vs read --- src/lib/input.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/input.c b/src/lib/input.c index e1a414f8b..aa9d9c342 100644 --- a/src/lib/input.c +++ b/src/lib/input.c @@ -380,6 +380,12 @@ handle_queued_input(ncinputlayer* nc, ncinput* ni, int leftmargin, int topmargin static char32_t handle_input(ncinputlayer* nc, ncinput* ni, int leftmargin, int topmargin, sigset_t* sigmask){ + // we once used getc() here (and kept ttyinfp, a FILE*, instead of the file + // descriptor ttyinfd), but under tmux, the first time running getc() would + // (bewilderingly) see a series of terminal reset codes emitted. this has + // never been explained to my satisfaction, but we can work around it by + // using a lower-level read() anyway. + // see https://github.com/dankamongmen/notcurses/issues/1314 for more info. unsigned char c; while(!input_queue_full(nc) && read(nc->ttyinfd, &c, 1) > 0){ nc->inputbuf[nc->inputbuf_write_at] = c;