diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-03-22 10:36:55 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-03-22 10:36:55 +0000 |
commit | 137a4bbc41fe6e0976510998536f8a256c2db738 (patch) | |
tree | 2feb3b6ca7bec7a99bf02764626bb3bfe64cc861 /usr.bin/tmux/screen-write.c | |
parent | 4988d8fd04f07e5d2462fe91e5111b3c0c70a189 (diff) |
Implement DECAWM (SM/RM 7) using existing MODE_WRAP flag.
Diffstat (limited to 'usr.bin/tmux/screen-write.c')
-rw-r--r-- | usr.bin/tmux/screen-write.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c index 030538d5948..e08a9916e01 100644 --- a/usr.bin/tmux/screen-write.c +++ b/usr.bin/tmux/screen-write.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-write.c,v 1.63 2013/03/22 10:33:50 nicm Exp $ */ +/* $OpenBSD: screen-write.c,v 1.64 2013/03/22 10:36:54 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -979,10 +979,10 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc) struct screen *s = ctx->s; struct grid *gd = s->grid; struct tty_ctx ttyctx; - u_int width, xx; + u_int width, xx, last; struct grid_cell tmp_gc, *tmp_gcp; struct utf8_data ud; - int insert = 0; + int insert; /* Ignore padding. */ if (gc->flags & GRID_FLAG_PADDING) @@ -1020,7 +1020,8 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc) xx = screen_size_x(s) - s->cx - width; grid_move_cells(s->grid, s->cx + width, s->cx, s->cy, xx); insert = 1; - } + } else + insert = 0; /* Check this will fit on the current line and wrap if not. */ if ((s->mode & MODE_WRAP) && s->cx > screen_size_x(s) - width) { @@ -1028,9 +1029,8 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc) s->cx = 0; /* carriage return */ } - /* Sanity checks. */ - if (((s->mode & MODE_WRAP) && s->cx > screen_size_x(s) - width) - || s->cy > screen_size_y(s) - 1) + /* Sanity check cursor position. */ + if (s->cx > screen_size_x(s) - width || s->cy > screen_size_y(s) - 1) return; /* Handle overwriting of UTF-8 characters. */ @@ -1049,8 +1049,15 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc) /* Set the cell. */ grid_view_set_cell(gd, s->cx, s->cy, gc); - /* Move the cursor. */ - s->cx += width; + /* + * Move the cursor. If not wrapping, stick at the last character and + * replace it. + */ + last = !!(s->mode & MODE_WRAP); + if (s->cx <= screen_size_x(s) - last - width) + s->cx += width; + else + s->cx = screen_size_x(s) - last; /* Draw to the screen if necessary. */ if (insert) { |