* Add n_terminal_image argument to put_image_{sixel|osc5379}(). * Use struct winsize to calculate ppc and ppl.

This commit is contained in:
Araki Ken
2014-12-06 20:47:05 +09:00
committed by Tatsuya Kinoshita
parent f64d6bb899
commit 982a8feab0
2 changed files with 16 additions and 15 deletions
+4 -3
View File
@@ -195,8 +195,8 @@ syncImage(void)
n_terminal_image = 0; n_terminal_image = 0;
} }
void put_image_osc5379(char *url, int x, int y, int w, int h, int sx, int sy, int sw, int sh); 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);
void put_image_sixel(char *url, int x, int y, int w, int h, int sx, int sy, int sw, int sh); void put_image_sixel(char *url, int x, int y, int w, int h, int sx, int sy, int sw, int sh, int n_terminal_image);
void void
drawImage() drawImage()
@@ -247,7 +247,8 @@ drawImage()
i->sx / pixel_per_char_i, i->sx / pixel_per_char_i,
i->sy / pixel_per_line_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->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); (i->height + i->sy % pixel_per_line_i + pixel_per_line_i - 1) / pixel_per_line_i,
n_terminal_image);
continue ; continue ;
} }
+8 -8
View File
@@ -468,7 +468,7 @@ writestr(char *s)
#define MOVE(line,column) writestr(tgoto(T_cm,column,line)); #define MOVE(line,column) writestr(tgoto(T_cm,column,line));
void void
put_image_osc5379(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, int n_terminal_image)
{ {
Str buf; Str buf;
char *size ; char *size ;
@@ -578,7 +578,7 @@ void ttymode_set(int mode, int imode);
void ttymode_reset(int mode, int imode); void ttymode_reset(int mode, int imode);
void void
put_image_sixel(char *url, int x, int y, int w, int h, int sx, int sy, int sw, int sh) put_image_sixel(char *url, int x, int y, int w, int h, int sx, int sy, int sw, int sh, int n_terminal_image)
{ {
pid_t pid; pid_t pid;
int do_anim; int do_anim;
@@ -589,7 +589,7 @@ put_image_sixel(char *url, int x, int y, int w, int h, int sx, int sy, int sw, i
MOVE(y,x); MOVE(y,x);
flush_tty(); flush_tty();
do_anim = (x == 0 && y == 0 && sx == 0 && sy == 0) ; do_anim = (n_terminal_image == 1 && x == 0 && y == 0 && sx == 0 && sy == 0);
previntr = mySignal(SIGINT, SIG_IGN); previntr = mySignal(SIGINT, SIG_IGN);
prevquit = mySignal(SIGQUIT, SIG_IGN); prevquit = mySignal(SIGQUIT, SIG_IGN);
@@ -663,18 +663,14 @@ get_pixel_per_cell(int *ppc, int *ppl)
int wp,hp,wc,hc; int wp,hp,wc,hc;
int i; int i;
/* screen replaces ws.ws_col and ws.ws_row alone. */
#if 0
#ifdef TIOCGWINSZ #ifdef TIOCGWINSZ
struct winsize ws; struct winsize ws;
if (ioctl(tty, TIOCGWINSZ, &ws) == 0 && ws.ws_ypixel > 0 && ws.ws_row > 0 && if (ioctl(tty, TIOCGWINSZ, &ws) == 0 && ws.ws_ypixel > 0 && ws.ws_row > 0 &&
ws.ws_xpixel > 0 && ws.ws_col > 0) { ws.ws_xpixel > 0 && ws.ws_col > 0) {
*ppc = ws.ws_xpixel / ws.ws_col; *ppc = ws.ws_xpixel / ws.ws_col;
*ppl = ws.ws_ypixel / ws.ws_row; *ppl = ws.ws_ypixel / ws.ws_row;
return 1; return 1;
} }
#endif
#endif #endif
fputs("\x1b[14t\x1b[18t",ttyf); flush_tty(); fputs("\x1b[14t\x1b[18t",ttyf); flush_tty();
@@ -694,11 +690,15 @@ get_pixel_per_cell(int *ppc, int *ppl)
p[len] = '\0'; p[len] = '\0';
if (sscanf(buf,"\x1b[4;%d;%dt\x1b[8;%d;%dt",&hp,&wp,&hc,&wc) == 4) { if (sscanf(buf,"\x1b[4;%d;%dt\x1b[8;%d;%dt",&hp,&wp,&hc,&wc) == 4) {
if (wp > 0 && wc > 0 && hp > 0 && hc > 0) {
*ppc = wp / wc; *ppc = wp / wc;
*ppl = hp / hc; *ppl = hp / hc;
return 1; return 1;
} }
else {
return 0;
}
}
p += len; p += len;
left -= len; left -= len;
} }