summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--input.c2
-rw-r--r--screen-write.c20
-rw-r--r--tmux.h1
3 files changed, 22 insertions, 1 deletions
diff --git a/input.c b/input.c
index ba3d9223..d8737888 100644
--- a/input.c
+++ b/input.c
@@ -646,7 +646,7 @@ input_handle_c0_control(u_char ch, struct input_ctx *ictx)
ictx->wp->window->flags |= WINDOW_BELL;
break;
case '\010': /* BS */
- screen_write_cursorleft(&ictx->ctx, 1);
+ screen_write_backspace(&ictx->ctx);
break;
case '\011': /* TAB */
/* Don't tab beyond the end of the line. */
diff --git a/screen-write.c b/screen-write.c
index 6b6aa400..2ce98dee 100644
--- a/screen-write.c
+++ b/screen-write.c
@@ -513,6 +513,25 @@ screen_write_cursorleft(struct screen_write_ctx *ctx, u_int nx)
s->cx -= nx;
}
+/* Backspace; cursor left unless at start of wrapped line when can move up. */
+void
+screen_write_backspace(struct screen_write_ctx *ctx)
+{
+ struct screen *s = ctx->s;
+ struct grid_line *gl;
+
+ if (s->cx == 0) {
+ if (s->cy == 0)
+ return;
+ gl = &s->grid->linedata[s->grid->hsize + s->cy - 1];
+ if (gl->flags & GRID_LINE_WRAPPED) {
+ s->cy--;
+ s->cx = screen_size_x(s) - 1;
+ }
+ } else
+ s->cx--;
+}
+
/* VT100 alignment test. */
void
screen_write_alignmenttest(struct screen_write_ctx *ctx)
@@ -536,6 +555,7 @@ screen_write_alignmenttest(struct screen_write_ctx *ctx)
s->cy = 0;
s->rupper = 0;
+
s->rlower = screen_size_y(s) - 1;
tty_write(tty_cmd_alignmenttest, &ttyctx);
diff --git a/tmux.h b/tmux.h
index 02f9bbd0..2d25c1de 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1646,6 +1646,7 @@ void screen_write_putc(
struct screen_write_ctx *, struct grid_cell *, u_char);
void screen_write_copy(struct screen_write_ctx *,
struct screen *, u_int, u_int, u_int, u_int);
+void screen_write_backspace(struct screen_write_ctx *);
void screen_write_cursorup(struct screen_write_ctx *, u_int);
void screen_write_cursordown(struct screen_write_ctx *, u_int);
void screen_write_cursorright(struct screen_write_ctx *, u_int);