diff --git i/screen-write.c w/screen-write.c index e58d744..eabfa6d 100644 --- i/screen-write.c +++ w/screen-write.c @@ -18,8 +18,11 @@ #include +#include +#include #include #include +#include #include "tmux.h" @@ -494,8 +497,20 @@ screen_write_backspace(struct screen_write_ctx *ctx) s->cy--; s->cx = screen_size_x(s) - 1; } - } else - s->cx--; + } else { + struct termios tio; + int fd = open(ctx->wp->tty, O_RDONLY); + assert(tcgetattr(fd, &tio) == 0); + close(fd); + if (tio.c_lflag & ICANON && tio.c_iflag & IUTF8 && ctx->wp->mode != &window_copy_mode) { + gl = &s->grid->linedata[s->grid->hsize + s->cy]; + if (s->cx > 0 && s->cx-1 < gl->extdsize && gl->extddata[s->cx-1].data.width == 2) + s->cx -= 2; + else + s->cx--; + } else + s->cx--; + } } /* VT100 alignment test. */