ncdirect: don't make infd nonblocking #919

This commit is contained in:
nick black 2020-08-26 23:49:02 -04:00
parent d3e23697af
commit 201994ab0c
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
2 changed files with 13 additions and 6 deletions

View File

@ -844,9 +844,6 @@ int cbreak_mode(int ttyfd, struct termios* tpreserved){
int ncinputlayer_init(ncinputlayer* nilayer, FILE* infp){
nilayer->inputescapes = NULL;
nilayer->ttyinfp = infp;
if(make_nonblocking(nilayer->ttyinfp)){
return -1;
}
if(prep_special_keys(nilayer)){
return -1;
}
@ -960,6 +957,9 @@ notcurses* notcurses_init(const notcurses_options* opts, FILE* outfp){
if(ncinputlayer_init(&ret->input, stdin)){
goto err;
}
if(make_nonblocking(ret->input.ttyinfp)){
return -1;
}
// Neither of these is supported on e.g. the "linux" virtual console.
if(!(opts->flags & NCOPTION_NO_ALTERNATE_SCREEN)){
terminfostr(&ret->tcache.smcup, "smcup");

View File

@ -15,7 +15,9 @@ print_b(struct ncdirect* nc, int r, int g, int total){
if(ret){
return -1;
}
printf("X");
if(printf("X") < 0){
return -1;
}
return 0;
}
@ -32,10 +34,14 @@ print_gb(struct ncdirect* nc, int r, int total){
static int
print_rgb(struct ncdirect* nc, int total){
if(random() % 2){
ncdirect_styles_off(nc, NCSTYLE_ITALIC);
if(ncdirect_styles_off(nc, NCSTYLE_ITALIC)){
return -1;
}
}
if(random() % 16 == 0){
ncdirect_styles_on(nc, NCSTYLE_ITALIC);
if(ncdirect_styles_on(nc, NCSTYLE_ITALIC)){
return -1;
}
}
for(int r = 0 ; r <= total && r < 256 ; r += 4){
if(print_gb(nc, r, total)){
@ -114,6 +120,7 @@ int main(void){
return EXIT_SUCCESS;
err:
fprintf(stderr, "WE HAD A BAD ERROR YO (%s)\n", strerror(errno));
ncdirect_stop(nc);
return EXIT_FAILURE;
}