[terminfo] only interrogate for sixel when pixel geometry is defined #1511 #1506

pull/1516/head
nick black 4 years ago
parent 217453780e
commit 694a0c133f
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -20,7 +20,7 @@ tinfo_debug_caps(const tinfo* ti, FILE* debugfp, int rows, int cols,
indent, capyn(ti->sgr), capyn(ti->sgr0));
fprintf(debugfp, "%sop: %c fgop: %c bgop: %c\n",
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);
if(!ti->pixel_query_done){
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.
// 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){
if(fd < 0){
return -1;
@ -383,16 +386,22 @@ int query_term(tinfo* ti, int fd){
int ret = 0;
pthread_mutex_lock(&ti->pixel_query);
if(!ti->pixel_query_done){
if(flags & O_NONBLOCK){
fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
}
ret = query_sixel(ti, fd);
ti->pixel_query_done = true;
if(ti->sixel_supported){
ti->pixel_init(fd);
}
if(flags & O_NONBLOCK){
fcntl(fd, F_SETFL, flags);
// if the terminal reported 0 pixels for cell dimensions, bypass any
// interrogation, and assume no bitmap support.
if(!ti->cellpixx || !ti->cellpixy){
ti->pixel_query_done = true;
}else{
if(flags & O_NONBLOCK){
fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
}
ret = query_sixel(ti, fd);
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);

Loading…
Cancel
Save