From 2d6428cb152f700411c757e7fc7afc981403fd13 Mon Sep 17 00:00:00 2001 From: nick black Date: Fri, 26 Nov 2021 07:34:43 -0500 Subject: [PATCH] [cli PoC] add a poll on the eventready fd #2216 --- src/poc/cli.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/poc/cli.c b/src/poc/cli.c index 851df3eb7..2cf0bc877 100644 --- a/src/poc/cli.c +++ b/src/poc/cli.c @@ -1,3 +1,4 @@ +#include #include int main(void){ @@ -12,16 +13,23 @@ int main(void){ } struct ncplane* stdn = notcurses_stdplane(nc); ncplane_set_scrolling(stdn, true); - if(ncplane_putstr(stdn, "press any key\n") < 0){ - goto err; - } - if(notcurses_render(nc)){ - goto err; - } ncinput ni; + int fd = notcurses_inputready_fd(nc); do{ + if(ncplane_putstr(stdn, "press any key\n") < 0){ + goto err; + } + if(notcurses_render(nc)){ + goto err; + } + struct pollfd pfd = { + .fd = fd, + .events = POLLIN, + }; + while(poll(&pfd, 1, -1) <= 0){ + } notcurses_get_blocking(nc, &ni); - }while(ni.evtype == NCTYPE_RELEASE); + }while(ni.evtype == NCTYPE_RELEASE || ni.id != 'q'); if(notcurses_render(nc)){ goto err; }