summaryrefslogtreecommitdiffstats
path: root/screen-write.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-10-12 16:59:55 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-10-12 16:59:55 +0000
commit8608c6970d67d5dec37400bcb4fb6a0c46efc165 (patch)
treee15779553b82c47035ef95e338eff92cee5b3ad1 /screen-write.c
parent693b3d03e66e5ab2f4c4e31b7d5d2c1629afbd8c (diff)
When backspace is received at the beginning of a line and the previous line was
wrapped, move the cursor back up to the end of the previous line. Another one of the forgotten persons requested this quite a while ago (I need to start noting names on todo items...) when it was quite hard to implement. Now it is easy and I don't see it can do any harm, so hey presto...
Diffstat (limited to 'screen-write.c')
-rw-r--r--screen-write.c20
1 files changed, 20 insertions, 0 deletions
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);