mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-20 03:25:47 +00:00
demo: handle_input() deadline check #377
This commit is contained in:
parent
58b67a56af
commit
339185dd6f
@ -352,8 +352,8 @@ summary_table(struct ncdirect* nc, const char* spec){
|
|||||||
qprefix(nsdelta, GIG, timebuf, 0);
|
qprefix(nsdelta, GIG, timebuf, 0);
|
||||||
bprefix(totalbytes, 1, totalbuf, 0);
|
bprefix(totalbytes, 1, totalbuf, 0);
|
||||||
qprefix(totalrenderns, GIG, rtimebuf, 0);
|
qprefix(totalrenderns, GIG, rtimebuf, 0);
|
||||||
table_segment(nc, "", "══╧═════════╧════════╪═══════╪═════════╪═════════╪═══╪═══════╪═══════╝\n");
|
table_segment(nc, "", "══╧═════════╪════════╪═══════╪═════════╪═════════╪═══╪═══════╪═══════╝\n");
|
||||||
table_printf(nc, "│", " %*ss", PREFIXSTRLEN, timebuf);
|
table_printf(nc, "│", " │%*ss", PREFIXSTRLEN, timebuf);
|
||||||
table_printf(nc, "│", "%7lu", totalframes);
|
table_printf(nc, "│", "%7lu", totalframes);
|
||||||
table_printf(nc, "│", "%*s", BPREFIXSTRLEN, totalbuf);
|
table_printf(nc, "│", "%*s", BPREFIXSTRLEN, totalbuf);
|
||||||
table_printf(nc, "│", " %*ss", PREFIXSTRLEN, rtimebuf);
|
table_printf(nc, "│", " %*ss", PREFIXSTRLEN, rtimebuf);
|
||||||
|
@ -223,10 +223,15 @@ handle_input(struct notcurses* nc, struct ncreel* pr, int efd,
|
|||||||
wchar_t key = -1;
|
wchar_t key = -1;
|
||||||
int pret;
|
int pret;
|
||||||
DEMO_RENDER(nc);
|
DEMO_RENDER(nc);
|
||||||
|
int64_t deadlinens = timespec_to_ns(deadline);
|
||||||
do{
|
do{
|
||||||
struct timespec pollspec, cur;
|
struct timespec pollspec, cur;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &cur);
|
clock_gettime(CLOCK_MONOTONIC, &cur);
|
||||||
timespec_subtract(&pollspec, deadline, &cur);
|
int64_t curns = timespec_to_ns(&cur);
|
||||||
|
if(curns > deadlinens){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ns_to_timespec(curns - deadlinens, &pollspec);
|
||||||
pret = ppoll(fds, sizeof(fds) / sizeof(*fds), &pollspec, &sset);
|
pret = ppoll(fds, sizeof(fds) / sizeof(*fds), &pollspec, &sset);
|
||||||
if(pret == 0){
|
if(pret == 0){
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user