mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-20 03:25:47 +00:00
notcurses-view: always check for ready input #997
This commit is contained in:
parent
25a192c7ba
commit
089bb6e44f
@ -101,32 +101,41 @@ auto perframe(struct ncvisual* ncv, struct ncvisual_options* vopts,
|
|||||||
int dimx, dimy, oldx, oldy;
|
int dimx, dimy, oldx, oldy;
|
||||||
nc.get_term_dim(&dimy, &dimx);
|
nc.get_term_dim(&dimy, &dimx);
|
||||||
ncplane_dim_yx(vopts->n, &oldy, &oldx);
|
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);
|
uint64_t absnow = timespec_to_ns(abstime);
|
||||||
if(absnow > nsnow){
|
char32_t keyp;
|
||||||
ns_to_timespec(absnow - nsnow, &interval);
|
bool gotinput;
|
||||||
char32_t keyp;
|
do{
|
||||||
while((keyp = nc.getc(&interval, nullptr, nullptr)) != (char32_t)-1){
|
gotinput = false;
|
||||||
if(keyp == ' '){
|
struct timespec interval;
|
||||||
if((keyp = nc.getc(true)) == (char32_t)-1){
|
clock_gettime(CLOCK_MONOTONIC, &interval);
|
||||||
return -1;
|
uint64_t nsnow = timespec_to_ns(&interval);
|
||||||
}
|
if(absnow > nsnow){
|
||||||
}
|
ns_to_timespec(absnow - nsnow, &interval);
|
||||||
// if we just hit a non-space character to unpause, interpret it
|
keyp = nc.getc(&interval, nullptr, nullptr);
|
||||||
if(keyp == ' '){ // space for unpause
|
}else{
|
||||||
continue;
|
keyp = nc.getc();
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
if(keyp == (char32_t)-1){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
gotinput = true;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}while(gotinput);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user