diff options
Diffstat (limited to '')
-rw-r--r-- | fm.h | 2 | ||||
-rw-r--r-- | image.c | 41 | ||||
-rw-r--r-- | terms.c | 41 |
3 files changed, 53 insertions, 31 deletions
@@ -1177,9 +1177,11 @@ global char *ssl_forbid_method init("2, 3"); global int is_redisplay init(FALSE); global int clear_buffer init(TRUE); global double pixel_per_char init(DEFAULT_PIXEL_PER_CHAR); +global int pixel_per_char_i init(DEFAULT_PIXEL_PER_CHAR); global int set_pixel_per_char init(FALSE); #ifdef USE_IMAGE global double pixel_per_line init(DEFAULT_PIXEL_PER_LINE); +global int pixel_per_line_i init(DEFAULT_PIXEL_PER_LINE); global int set_pixel_per_line init(FALSE); global double image_scale init(100); #endif @@ -57,6 +57,8 @@ getCharSize() int ppc, ppl; if (get_pixel_per_cell(&ppc,&ppl)) { + pixel_per_char_i = ppc ; + pixel_per_line_i = ppl ; pixel_per_char = (double)ppc; pixel_per_line = (double)ppl; } @@ -210,7 +212,7 @@ drawImage() i->cache->width > 0 ? i->cache->width : 0, i->cache->height > 0 ? i->cache->height : 0, i->sx, i->sy, i->width, i->height, - (int)pixel_per_char, (int)pixel_per_line); + pixel_per_char_i, pixel_per_line_i); #endif put_image( #if 1 @@ -220,27 +222,25 @@ drawImage() #else i->cache->url, #endif - (int)(i->x / pixel_per_char), - (int)(i->y / pixel_per_line), + i->x / pixel_per_char_i, + i->y / pixel_per_line_i, #if 1 i->cache->a_width > 0 ? - (int)((i->cache->width + i->x % (int)pixel_per_char + - pixel_per_char - 1) / pixel_per_char) : + (i->cache->width + i->x % pixel_per_char_i + pixel_per_char_i - 1) / + pixel_per_char_i : #endif 0, #if 1 i->cache->a_height > 0 ? - (int)((i->cache->height + i->y % (int)pixel_per_line + - pixel_per_line - 1) / pixel_per_line) : + (i->cache->height + i->y % pixel_per_line_i + pixel_per_line_i - 1) / + pixel_per_line_i : #endif 0, - (int)(i->sx / pixel_per_char), - (int)(i->sy / pixel_per_line), - (int)((i->width + i->sx % (int)pixel_per_char + - pixel_per_char - 1) / pixel_per_char), - (int)((i->height + i->sy % (int)pixel_per_line + - pixel_per_line - 1) / pixel_per_line)); + i->sx / pixel_per_char_i, + i->sy / pixel_per_line_i, + (i->width + i->sx % pixel_per_char_i + pixel_per_char_i - 1) / pixel_per_char_i, + (i->height + i->sy % pixel_per_line_i + pixel_per_line_i - 1) / pixel_per_line_i); continue ; } @@ -593,8 +593,19 @@ getImage(Image * image, ParsedURL *current, int flag) cache->pid = 0; cache->index = 0; cache->loaded = IMG_FLAG_UNLOADED; - cache->width = image->width; - cache->height = image->height; + if (support_remote_image) { + if (image->width > 0 && image->width % pixel_per_char_i > 0) + image->width += (pixel_per_char_i - image->width % pixel_per_char_i); + + if (image->height > 0 && image->height % pixel_per_line_i > 0) + image->height += (pixel_per_line_i - image->height % pixel_per_line_i); + + if (image->height > 0 && image->width > 0) + cache->loaded = IMG_FLAG_LOADED; + } + + cache->width = image->width ; + cache->height = image->height ; cache->a_width = image->width; cache->a_height = image->height; putHash_sv(image_hash, key->ptr, (void *)cache); @@ -489,31 +489,40 @@ get_pixel_per_cell(int *ppc, int *ppl) fd_set rfd; struct timeval tval; char buf[100]; + char *p; ssize_t len; + ssize_t left; int wp,hp,wc,hc; + int i; fputs("\x1b[14t\x1b[18t",ttyf); flush_tty(); - tval.tv_usec = 10000; /* 0.1 sec */ - tval.tv_sec = 0; - FD_SET(tty,&rfd); - if (select(tty+1,&rfd,NULL,NULL,&tval) < 0 || ! FD_ISSET(tty,&rfd)) { - return 0; - } + p = buf; + left = sizeof(buf) - 1; + for (i = 0; i < 5; i++) { + tval.tv_usec = 100000; /* 0.1 sec */ + tval.tv_sec = 0; + FD_SET(tty,&rfd); + if (select(tty+1,&rfd,NULL,NULL,&tval) <= 0 || ! FD_ISSET(tty,&rfd)) { + continue; + } - if ((len = read(tty,buf,sizeof(buf)-1)) <= 0) { - return 0; - } - buf[len] = '\0'; + if ((len = read(tty,p,left)) <= 0) { + return 0; + } + p[len] = '\0'; - if (sscanf(buf,"\x1b[4;%d;%dt\x1b[8;%d;%dt",&hp,&wp,&hc,&wc) != 4) { - return 0; - } + if (sscanf(buf,"\x1b[4;%d;%dt\x1b[8;%d;%dt",&hp,&wp,&hc,&wc) == 4) { + *ppc = wp / wc; + *ppl = hp / hc; - *ppc = wp / wc; - *ppl = hp / hc; + return 1; + } + p = buf + len; + left -= len; + } - return 1; + return 0; } #ifdef USE_MOUSE |