Skip to content

Commit

Permalink
Add a flag to disable blocking while sending a SIXEL image (turned of…
Browse files Browse the repository at this point in the history
…f when the

buffer hits 0 size).
  • Loading branch information
nicm committed Nov 28, 2019
1 parent e01df67 commit d2e3f3c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions tmux.h
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,7 @@ struct tty {
#define TTY_OPENED 0x20
#define TTY_FOCUS 0x40
#define TTY_BLOCK 0x80
#define TTY_NOBLOCK 0x100
int flags;

struct tty_term *term;
Expand Down
8 changes: 8 additions & 0 deletions tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ tty_block_maybe(struct tty *tty)
size_t size = EVBUFFER_LENGTH(tty->out);
struct timeval tv = { .tv_usec = TTY_BLOCK_INTERVAL };

if (size == 0)
tty->flags &= ~TTY_NOBLOCK;
else if (tty->flags & TTY_NOBLOCK)
return (0);

if (size < TTY_BLOCK_START(tty))
return (0);

Expand Down Expand Up @@ -1889,8 +1894,10 @@ tty_cmd_sixelimage(struct tty *tty, const struct tty_ctx *ctx)
sx = wp->sx - cx;
if (sy > wp->sy - cy)
sy = wp->sy - cy;
log_debug("%s: image is %ux%u", __func__, sx, sy);
if (!tty_clamp_area(tty, ctx, cx, cy, sx, sy, &i, &j, &x, &y, &rx, &ry))
return;
log_debug("%s: clamping to section %u,%u-%u,%u", __func__, i, j, rx, ry);

new = sixel_scale(si, tty->xpixel, tty->ypixel, i, j, rx, ry);
if (new == NULL)
Expand All @@ -1901,6 +1908,7 @@ tty_cmd_sixelimage(struct tty *tty, const struct tty_ctx *ctx)
log_debug("%s: %zu bytes: %s", __func__, size, data);
tty_cursor(tty, x, y);

tty->flags |= TTY_NOBLOCK;
tty_add(tty, data, size);
tty_invalidate(tty);
free(data);
Expand Down

0 comments on commit d2e3f3c

Please sign in to comment.