mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-08 01:10:23 +00:00
[cli PoC] add a poll on the eventready fd #2216
This commit is contained in:
parent
70bfd825d7
commit
2d6428cb15
@ -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…
Reference in New Issue
Block a user