notcurses-view: always check for ready input #997

pull/1016/head
nick black 4 years ago
parent 25a192c7ba
commit 089bb6e44f
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -101,32 +101,41 @@ auto perframe(struct ncvisual* ncv, struct ncvisual_options* vopts,
int dimx, dimy, oldx, oldy;
nc.get_term_dim(&dimy, &dimx);
ncplane_dim_yx(vopts->n, &oldy, &oldx);
struct timespec interval;
clock_gettime(CLOCK_MONOTONIC, &interval);
uint64_t nsnow = timespec_to_ns(&interval);
uint64_t absnow = timespec_to_ns(abstime);
if(absnow > nsnow){
ns_to_timespec(absnow - nsnow, &interval);
char32_t keyp;
while((keyp = nc.getc(&interval, nullptr, nullptr)) != (char32_t)-1){
if(keyp == ' '){
if((keyp = nc.getc(true)) == (char32_t)-1){
return -1;
}
}
// if we just hit a non-space character to unpause, interpret it
if(keyp == ' '){ // space for unpause
continue;
}
if(keyp == NCKey::Resize){
return 0;
}else if(keyp >= '0' && keyp <= '8'){ // FIXME eliminate ctrl/alt
vopts->blitter = static_cast<ncblitter_e>(keyp - '0');
continue;
char32_t keyp;
bool gotinput;
do{
gotinput = false;
struct timespec interval;
clock_gettime(CLOCK_MONOTONIC, &interval);
uint64_t nsnow = timespec_to_ns(&interval);
if(absnow > nsnow){
ns_to_timespec(absnow - nsnow, &interval);
keyp = nc.getc(&interval, nullptr, nullptr);
}else{
keyp = nc.getc();
}
if(keyp == (char32_t)-1){
break;
}
gotinput = true;
if(keyp == ' '){
if((keyp = nc.getc(true)) == (char32_t)-1){
return -1;
}
return 1;
}
}
// if we just hit a non-space character to unpause, interpret it
if(keyp == ' '){ // space for unpause
continue;
}
if(keyp == NCKey::Resize){
return 0;
}else if(keyp >= '0' && keyp <= '8'){ // FIXME eliminate ctrl/alt
vopts->blitter = static_cast<ncblitter_e>(keyp - '0');
continue;
}
return 1;
}while(gotinput);
return 0;
}

Loading…
Cancel
Save