aboutsummaryrefslogtreecommitdiff
path: root/tty.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-10-17 08:24:46 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-10-17 08:24:46 +0000
commit43d62c1ae3846ba1b33d79349be367ed3b6763cf (patch)
tree2669769866294fed8087b5dea4bf81d36daa7207 /tty.c
parent70355021d8e8b83eaa3d947dc7a49b4eacff17fa (diff)
downloadrtmux-43d62c1ae3846ba1b33d79349be367ed3b6763cf.tar.gz
rtmux-43d62c1ae3846ba1b33d79349be367ed3b6763cf.tar.bz2
rtmux-43d62c1ae3846ba1b33d79349be367ed3b6763cf.zip
Instead of having a complicated check to see if the cursor is in the last
position to avoid an explicit wrap, actually move it there. Some UTF-8 fixes to come.
Diffstat (limited to 'tty.c')
-rw-r--r--tty.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/tty.c b/tty.c
index 53cd3362..37cff1fc 100644
--- a/tty.c
+++ b/tty.c
@@ -456,7 +456,7 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int py, u_int ox, u_int oy)
/*
* Don't move the cursor to the start permission if it will wrap there
- * itself; much the same as the conditions in tty_cmd_cell.
+ * itself.
*/
gl = NULL;
if (py != 0)
@@ -842,33 +842,21 @@ tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx)
{
struct window_pane *wp = ctx->wp;
struct screen *s = wp->screen;
- struct grid_line *gl;
- u_int wx, wy;
+ u_int cx;
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
- wx = ctx->ocx + wp->xoff;
- wy = ctx->ocy + wp->yoff;
-
/*
- * If:
- *
- * - the line was wrapped:
- * - the cursor is beyond the edge of the screen,
- * - the desired position is at the left,
- * - and either a) the desired next line is the one below the current
- * or b) the current line is the bottom of the scroll region,
- *
- * Then just printing the next character will be enough to scroll into
- * place, so don't do an explicit cursor move.
+ * Should the cursor be in the last cursor position ready for a natural
+ * wrap? If so - and it isn't - move to and rewrite the last cell.
*/
- gl = NULL;
- if (ctx->ocy != 0)
- gl = &s->grid->linedata[s->grid->hsize + ctx->ocy - 1];
- if (wy == 0 || (gl != NULL && !(gl->flags & GRID_LINE_WRAPPED)) ||
- tty->cx < tty->sx || /* not at edge of screen */
- wx != 0 || /* don't want 0 next */
- (wy != tty->cy + 1 && tty->cy != ctx->orlower + wp->yoff))
+ if (ctx->ocx + wp->xoff > tty->sx - ctx->last_width) {
+ if (tty->cx < tty->sx) {
+ cx = screen_size_x(s) - ctx->last_width;
+ tty_cursor_pane(tty, ctx, cx, ctx->ocy);
+ tty_cell(tty, &ctx->last_cell, &ctx->last_utf8);
+ }
+ } else
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
tty_cell(tty, ctx->cell, ctx->utf8);