diff options
author | bptato <nincsnevem662@gmail.com> | 2021-02-18 19:27:48 +0000 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2021-02-18 19:27:48 +0000 |
commit | da628ebd885da1ae921ab1b254cd3253a87ea396 (patch) | |
tree | f1b4d0f25f40e15d7707c93c2ec2ebe8ef546620 | |
parent | Support kitty image protocol (diff) | |
download | w3m-da628ebd885da1ae921ab1b254cd3253a87ea396.tar.gz w3m-da628ebd885da1ae921ab1b254cd3253a87ea396.zip |
Fix small images on kitty
-rw-r--r-- | terms.c | 63 |
1 files changed, 35 insertions, 28 deletions
@@ -576,7 +576,6 @@ put_image_kitty(char *url, int x, int y, int w, int h, int sx, int sy, int sw, "w=%d,h=%d,c=%d,r=%d;", w, h, x, y, sx, sy, sw, sh, cols, rows); - writestr(buf->ptr); cbuf = GC_MALLOC_ATOMIC(3072); i = 0; @@ -591,36 +590,44 @@ put_image_kitty(char *url, int x, int y, int w, int h, int sx, int sy, int sw, if (!base64) return; - buf = Sprintf("%s\x1b\\", base64); + if (c == EOF) + buf = Sprintf("\x1b_Gf=100,s=%d,v=%d,a=T,m=0,X=%d,Y=%d,x=%d,y=%d," + "w=%d,h=%d,c=%d,r=%d;", + w, h, x, y, sx, sy, sw, sh, cols, rows); writestr(buf->ptr); - i = 0; - base64 = NULL; - while ((c = fgetc(fp)) != EOF) { - if (!i && base64) { - buf = Sprintf("\x1b_Gm=1;%s\x1b\\", base64); - writestr(buf->ptr); - } - cbuf[i] = c; - ++i; - if (i == 3072) { - base64 = base64_encode(cbuf, i); - if (!base64) - return; - - i = 0; - } - } - - if (i) { - base64 = base64_encode(cbuf, i); - if (!base64) - return; - } + buf = Sprintf("%s\x1b\\", base64); + writestr(buf->ptr); - if (base64) { - buf = Sprintf("\x1b_Gm=0;%s\x1b\\", base64); - writestr(buf->ptr); + if (c != EOF) { + i = 0; + base64 = NULL; + while ((c = fgetc(fp)) != EOF) { + if (!i && base64) { + buf = Sprintf("\x1b_Gm=1;%s\x1b\\", base64); + writestr(buf->ptr); + } + cbuf[i] = c; + ++i; + if (i == 3072) { + base64 = base64_encode(cbuf, i); + if (!base64) + return; + + i = 0; + } + } + + if (i) { + base64 = base64_encode(cbuf, i); + if (!base64) + return; + } + + if (base64) { + buf = Sprintf("\x1b_Gm=0;%s\x1b\\", base64); + writestr(buf->ptr); + } } MOVE(Currentbuf->cursorY, Currentbuf->cursorX); } |