mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-20 03:25:47 +00:00
This commit is contained in:
parent
217453780e
commit
694a0c133f
@ -20,7 +20,7 @@ tinfo_debug_caps(const tinfo* ti, FILE* debugfp, int rows, int cols,
|
|||||||
indent, capyn(ti->sgr), capyn(ti->sgr0));
|
indent, capyn(ti->sgr), capyn(ti->sgr0));
|
||||||
fprintf(debugfp, "%sop: %c fgop: %c bgop: %c\n",
|
fprintf(debugfp, "%sop: %c fgop: %c bgop: %c\n",
|
||||||
indent, capyn(ti->op), capyn(ti->fgop), capyn(ti->bgop));
|
indent, capyn(ti->op), capyn(ti->fgop), capyn(ti->bgop));
|
||||||
fprintf(debugfp, "%srows: %u cols: %u rpix: %u cpix: %u (%dx%d)\n",
|
fprintf(debugfp, "%srows: %u cols: %u rpx: %u cpx: %u (%dx%d)\n",
|
||||||
indent, rows, cols, ti->cellpixy, ti->cellpixx, rows * ti->cellpixy, cols * ti->cellpixx);
|
indent, rows, cols, ti->cellpixy, ti->cellpixx, rows * ti->cellpixy, cols * ti->cellpixx);
|
||||||
if(!ti->pixel_query_done){
|
if(!ti->pixel_query_done){
|
||||||
fprintf(debugfp, "%sno bitmap graphics information yet\n", indent);
|
fprintf(debugfp, "%sno bitmap graphics information yet\n", indent);
|
||||||
|
@ -372,6 +372,9 @@ query_sixel(tinfo* ti, int fd){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fd must be a real terminal. uses the query lock of |ti| to only act once.
|
// fd must be a real terminal. uses the query lock of |ti| to only act once.
|
||||||
|
// we ought already have performed a TIOCGWINSZ ioctl() to verify that the
|
||||||
|
// terminal reports cell area in pixels, as that's necessary for our use of
|
||||||
|
// sixel (or any other bitmap protocol).
|
||||||
int query_term(tinfo* ti, int fd){
|
int query_term(tinfo* ti, int fd){
|
||||||
if(fd < 0){
|
if(fd < 0){
|
||||||
return -1;
|
return -1;
|
||||||
@ -383,16 +386,22 @@ int query_term(tinfo* ti, int fd){
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
pthread_mutex_lock(&ti->pixel_query);
|
pthread_mutex_lock(&ti->pixel_query);
|
||||||
if(!ti->pixel_query_done){
|
if(!ti->pixel_query_done){
|
||||||
if(flags & O_NONBLOCK){
|
// if the terminal reported 0 pixels for cell dimensions, bypass any
|
||||||
fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
|
// interrogation, and assume no bitmap support.
|
||||||
}
|
if(!ti->cellpixx || !ti->cellpixy){
|
||||||
ret = query_sixel(ti, fd);
|
ti->pixel_query_done = true;
|
||||||
ti->pixel_query_done = true;
|
}else{
|
||||||
if(ti->sixel_supported){
|
if(flags & O_NONBLOCK){
|
||||||
ti->pixel_init(fd);
|
fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
|
||||||
}
|
}
|
||||||
if(flags & O_NONBLOCK){
|
ret = query_sixel(ti, fd);
|
||||||
fcntl(fd, F_SETFL, flags);
|
ti->pixel_query_done = true;
|
||||||
|
if(ti->sixel_supported){
|
||||||
|
ti->pixel_init(fd);
|
||||||
|
}
|
||||||
|
if(flags & O_NONBLOCK){
|
||||||
|
fcntl(fd, F_SETFL, flags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&ti->pixel_query);
|
pthread_mutex_unlock(&ti->pixel_query);
|
||||||
|
Loading…
Reference in New Issue
Block a user