mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-02 09:40:15 +00:00
clearall: take a FILE, not an fd
This commit is contained in:
parent
a99d096666
commit
de8bb9d498
@ -780,11 +780,11 @@ int sprixel_load(sprixel* spx, char* s, int bytes, int pixy, int pixx, int parse
|
||||
int sixel_destroy(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s);
|
||||
int kitty_destroy(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s);
|
||||
int kitty_remove(int id, FILE* out);
|
||||
int kitty_clear_all(int fd);
|
||||
int kitty_clear_all(FILE* fp);
|
||||
int sixel_init(const tinfo* t, int fd);
|
||||
int sixel_init_inverted(const tinfo* t, int fd);
|
||||
int sprite_init(const tinfo* t, int fd);
|
||||
int sprite_clear_all(const tinfo* t, int fd);
|
||||
int sprite_clear_all(const tinfo* t, FILE* fp);
|
||||
int kitty_shutdown(int fd);
|
||||
int sixel_shutdown(int fd);
|
||||
uint8_t* sixel_trans_auxvec(const struct tinfo* ti);
|
||||
@ -1198,24 +1198,28 @@ tty_emit(const char* seq, int fd){
|
||||
return 0;
|
||||
}
|
||||
|
||||
// reliably flush a FILE*
|
||||
static inline int
|
||||
ncflush(FILE* out){
|
||||
while(fflush(out) == EOF){
|
||||
if(errno != EAGAIN && errno != EINTR && errno != EBUSY){
|
||||
logerror("Unrecoverable error flushing io (%s)\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
term_emit(const char* seq, FILE* out, bool flush){
|
||||
if(!seq){
|
||||
return -1;
|
||||
}
|
||||
if(ncfputs(seq, out) == EOF){
|
||||
//fprintf(stderr, "Error emitting %zub escape (%s)\n", strlen(seq), strerror(errno));
|
||||
logerror("Error emitting %zub escape (%s)\n", strlen(seq), strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if(flush){
|
||||
while(fflush(out) == EOF){
|
||||
if(errno != EAGAIN && errno != EINTR && errno != EBUSY){
|
||||
fprintf(stderr, "Error flushing after %zub sequence (%s)\n", strlen(seq), strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return flush ? ncflush(out) : 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
|
@ -635,9 +635,9 @@ int kitty_move(const ncpile* p, sprixel* s, FILE* out){
|
||||
}
|
||||
|
||||
// clears all kitty bitmaps
|
||||
int kitty_clear_all(int fd){
|
||||
int kitty_clear_all(FILE* fp){
|
||||
//fprintf(stderr, "KITTY UNIVERSAL ERASE\n");
|
||||
return tty_emit("\e_Ga=d\e\\", fd);
|
||||
return term_emit("\e_Ga=d\e\\", fp, false);
|
||||
}
|
||||
|
||||
int kitty_shutdown(int fd){
|
||||
|
@ -199,11 +199,11 @@ int sprite_wipe(const notcurses* nc, sprixel* s, int ycell, int xcell){
|
||||
return r;
|
||||
}
|
||||
|
||||
int sprite_clear_all(const tinfo* t, int fd){
|
||||
int sprite_clear_all(const tinfo* t, FILE* fp){
|
||||
if(t->pixel_clear_all == NULL){
|
||||
return 0;
|
||||
}
|
||||
return t->pixel_clear_all(fd);
|
||||
return t->pixel_clear_all(fp);
|
||||
}
|
||||
|
||||
int sprite_init(const tinfo* t, int fd){
|
||||
|
@ -134,8 +134,8 @@ typedef struct tinfo {
|
||||
// execute move (erase old graphic, place at new location) if non-NULL
|
||||
int (*pixel_move)(const struct ncpile* p, struct sprixel* s, FILE* out);
|
||||
int (*pixel_destroy)(const struct notcurses* nc, const struct ncpile* p, FILE* out, struct sprixel* s);
|
||||
int (*pixel_shutdown)(int fd); // called during context shutdown
|
||||
int (*pixel_clear_all)(int fd); // called during startup, kitty only
|
||||
int (*pixel_shutdown)(int fd); // called during context shutdown
|
||||
int (*pixel_clear_all)(FILE* fp); // called during context startup
|
||||
uint8_t* (*pixel_trans_auxvec)(const struct tinfo* ti); // create tranparent auxvec
|
||||
// sprixel parameters. there are several different sprixel protocols, of
|
||||
// which we support sixel and kitty. the kitty protocol is used based
|
||||
|
Loading…
Reference in New Issue
Block a user