diff options
author | Araki Ken <arakiken@users.sf.net> | 2014-11-15 19:07:05 +0000 |
---|---|---|
committer | Tatsuya Kinoshita <tats@debian.org> | 2014-12-06 11:47:05 +0000 |
commit | 2e8def7ab6eb7ca9bb5160071a041cc25c919928 (patch) | |
tree | 111159e37d76413735cec946208c685e7b3de6ad | |
parent | * Add n_terminal_image argument to put_image_{sixel|osc5379}(). * Use struct ... (diff) | |
download | w3m-2e8def7ab6eb7ca9bb5160071a041cc25c919928.tar.gz w3m-2e8def7ab6eb7ca9bb5160071a041cc25c919928.zip |
Add README.sixel. W3M_IMG2SIXEL environmental variable enables to specify options of img2sixel.
-rw-r--r-- | doc/README.sixel | 27 | ||||
-rw-r--r-- | terms.c | 47 |
2 files changed, 58 insertions, 16 deletions
diff --git a/doc/README.sixel b/doc/README.sixel new file mode 100644 index 0000000..588afc4 --- /dev/null +++ b/doc/README.sixel @@ -0,0 +1,27 @@ +Sixel support of w3m + 2014/11/05 + K. Araki + +Introduction + + This is the extension for w3m to show inline images by sixel graphics. + +Requirements + + Install 'img2sixel' command provided by libsixel project. + (https://github.com/saitoha/libsixel) + +Build + + $ ./configure --enable-image ... + $ make + $ make install + +Usage + + $ w3m -sixel http://... + + You can specify options of 'img2sixel' command by "W3M_IMG2SIXEL" + environmental variable. + + $ W3M_IMG2SIXEL="img2sixel -d atkinson" w3m -sixel http://... @@ -596,7 +596,9 @@ put_image_sixel(char *url, int x, int y, int w, int h, int sx, int sy, int sw, i prevstop = mySignal(SIGTSTP, SIG_IGN); if ((pid = fork()) == 0) { - char *argv[12]; + char *env; + int n = 0; + char *argv[20]; char digit[2][11+1]; char clip[44+3+1]; Str str_url; @@ -611,28 +613,41 @@ put_image_sixel(char *url, int x, int y, int w, int h, int sx, int sy, int sw, i } ttymode_set(ISIG, 0); - argv[0] = "img2sixel"; - argv[1] = "-l"; - argv[2] = do_anim ? "auto" : "disable"; - argv[3] = "-w"; + if ((env = getenv("W3M_IMG2SIXEL"))) { + char *p; + env = Strnew_charp(env)->ptr; + while (n < 8 && (p = strchr(env, ' '))) { + *p = '\0'; + if (*env != '\0') { + argv[n++] = env; + } + env = p+1; + } + if (*env != '\0') { + argv[n++] = env; + } + } + else { + argv[n++] = "img2sixel"; + } + argv[n++] = "-l"; + argv[n++] = do_anim ? "auto" : "disable"; + argv[n++] = "-w"; sprintf(digit[0], "%d", w*pixel_per_char_i); - argv[4] = digit[0]; - argv[5] = "-h"; + argv[n++] = digit[0]; + argv[n++] = "-h"; sprintf(digit[1], "%d", h*pixel_per_line_i); - argv[6] = digit[1]; - argv[7] = "-c"; + argv[n++] = digit[1]; + argv[n++] = "-c"; sprintf(clip, "%dx%d+%d+%d", sw*pixel_per_char_i, sh*pixel_per_line_i, sx*pixel_per_char_i, sy*pixel_per_line_i); - argv[8] = clip; - argv[9] = url; + argv[n++] = clip; + argv[n++] = url; if (getenv("TERM") && strcmp(getenv("TERM"), "screen") == 0 && (!getenv("SCREEN_VARIANT") || strcmp(getenv("SCREEN_VARIANT"), "sixel") != 0)) { - argv[10] = "-P"; - argv[11] = NULL; - } - else { - argv[10] = NULL; + argv[n++] = "-P"; } + argv[n++] = NULL; execvp(argv[0],argv); exit(0); } |