Add -sixel option which supports image processing by img2sixel.

This commit is contained in:
Araki Ken
2014-09-22 20:16:39 +09:00
committed by Tatsuya Kinoshita
parent 98b4d10ce4
commit 2fe66f3a6f
6 changed files with 43 additions and 60 deletions

18
terms.c
View File

@@ -467,7 +467,7 @@ writestr(char *s)
#define MOVE(line,column) writestr(tgoto(T_cm,column,line));
void
put_image(char *url, int x, int y, int w, int h, int sx, int sy, int sw, int sh)
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 ;
@@ -483,6 +483,22 @@ put_image(char *url, int x, int y, int w, int h, int sx, int sy, int sw, int sh)
MOVE(Currentbuf->cursorY,Currentbuf->cursorX);
}
void
put_image_sixel(char *url, int x, int y, int w, int h, int sx, int sy, int sw, int sh)
{
Str buf;
MOVE(y,x);
flush_tty();
buf = Sprintf("img2sixel -l disable -c %dx%d+%d+%d -w %d -h %d %s 2>/dev/null",
sw*pixel_per_char_i, sh*pixel_per_line_i,
sx*pixel_per_char_i, sy*pixel_per_line_i,
w*pixel_per_char_i, h*pixel_per_line_i,
url);
system(buf->ptr);
MOVE(Currentbuf->cursorY,Currentbuf->cursorX);
}
int
get_pixel_per_cell(int *ppc, int *ppl)
{