diff options
author | bptato <nincsnevem662@gmail.com> | 2021-02-02 21:14:46 +0000 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2021-02-02 21:14:46 +0000 |
commit | e4570e8b6e17382e1cc4984684f861524d5b02f4 (patch) | |
tree | 37b0dc1979c6f020f0c2095891a2bba796b306b0 /terms.c | |
parent | Avoid having external programs download images (diff) | |
download | w3m-e4570e8b6e17382e1cc4984684f861524d5b02f4.tar.gz w3m-e4570e8b6e17382e1cc4984684f861524d5b02f4.zip |
Support iTerm2 graphics protocol, replace encodeB with base64_encode
Diffstat (limited to '')
-rw-r--r-- | terms.c | 33 |
1 files changed, 32 insertions, 1 deletions
@@ -469,7 +469,7 @@ writestr(char *s) #ifdef USE_IMAGE void -put_image_osc5379(char *url, int x, int y, int w, int h, int sx, int sy, int sw, int sh, int n_terminal_image) +put_image_osc5379(char *url, int x, int y, int w, int h, int sx, int sy, int sw, int sh) { Str buf; char *size ; @@ -485,6 +485,37 @@ put_image_osc5379(char *url, int x, int y, int w, int h, int sx, int sy, int sw, MOVE(Currentbuf->cursorY,Currentbuf->cursorX); } + +void +put_image_iterm2(char *url, int x, int y, int w, int h) +{ + Str buf, filecontent; + const char *base64; + FILE *fp; + + fp = fopen(url, "r"); + if (!fp) + return; + filecontent = Strfgetall(fp); + + base64 = base64_encode(filecontent->ptr, filecontent->length); + if (!base64) + return; + + MOVE(y,x); + buf = Sprintf("\x1b]1337;" + "File=" + "name=%s;" + "size=%d;" + "width=%d;" + "height=%d;" + "preserveAspectRatio=0;" + "inline=1" + ":%s\a", url, filecontent->length, w, h, base64); + writestr(buf->ptr); + MOVE(Currentbuf->cursorY,Currentbuf->cursorX); +} + static void save_gif(const char *path, u_char *header, size_t header_size, u_char *body, size_t body_size) { |