[cli PoC] add a poll on the eventready fd #2216

pull/2388/head
nick black 3 years ago
parent 70bfd825d7
commit 2d6428cb15
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -1,3 +1,4 @@
#include <poll.h>
#include <notcurses/notcurses.h>
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;
}

Loading…
Cancel
Save