aboutsummaryrefslogtreecommitdiff
path: root/screen-write.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-10-15 01:41:14 +0000
committerTiago Cunha <tcunha@gmx.com>2009-10-15 01:41:14 +0000
commit610362812942f4b5d60f3a29436ddc716d794908 (patch)
tree2e11c9414b1a0f302cb709a39d2880cfd51dc034 /screen-write.c
parentcbd3b1bc9b51d38c98fd02df8c489b7bc9dab728 (diff)
downloadrtmux-610362812942f4b5d60f3a29436ddc716d794908.tar.gz
rtmux-610362812942f4b5d60f3a29436ddc716d794908.tar.bz2
rtmux-610362812942f4b5d60f3a29436ddc716d794908.zip
Sync OpenBSD patchset 401:
When drawing lines that have wrapped naturally, don't force a newline but permit them to wrap naturally again. This allows terminals that use this to guess where lines start and end for eg mouse selecting (like xterm) to work correctly. This was another long-standing issue raised by several people over the last while. Thanks to martynas@ for much testing. This was not trivial to get right so bringing it in for wider testing and adn to fix any further glitches in-tree.
Diffstat (limited to 'screen-write.c')
-rw-r--r--screen-write.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/screen-write.c b/screen-write.c
index 11b387a6..4739b0c8 100644
--- a/screen-write.c
+++ b/screen-write.c
@@ -1,4 +1,4 @@
-/* $Id: screen-write.c,v 1.76 2009-10-15 01:39:30 tcunha Exp $ */
+/* $Id: screen-write.c,v 1.77 2009-10-15 01:41:14 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -833,15 +833,15 @@ screen_write_mousemode(struct screen_write_ctx *ctx, int state)
s->mode &= ~MODE_MOUSE;
}
-/* Line feed (down with scroll). */
+/*
+ * Line feed the screen only (don't update the tty). Used for printing single
+ * characters, where might want to let the scroll happen naturally.
+ */
void
-screen_write_linefeed(struct screen_write_ctx *ctx, int wrapped)
+screen_write_linefeedscreen(struct screen_write_ctx *ctx, int wrapped)
{
struct screen *s = ctx->s;
struct grid_line *gl;
- struct tty_ctx ttyctx;
-
- screen_write_initctx(ctx, &ttyctx);
gl = &s->grid->linedata[s->grid->hsize + s->cy];
if (wrapped)
@@ -853,6 +853,17 @@ screen_write_linefeed(struct screen_write_ctx *ctx, int wrapped)
grid_view_scroll_region_up(s->grid, s->rupper, s->rlower);
else if (s->cy < screen_size_y(s) - 1)
s->cy++;
+}
+
+/* Line feed (down with scroll). */
+void
+screen_write_linefeed(struct screen_write_ctx *ctx, int wrapped)
+{
+ struct tty_ctx ttyctx;
+
+ screen_write_initctx(ctx, &ttyctx);
+
+ screen_write_linefeedscreen(ctx, wrapped);
tty_write(tty_cmd_linefeed, &ttyctx);
}
@@ -952,6 +963,7 @@ screen_write_cell(
struct screen_write_ctx *ctx, const struct grid_cell *gc, u_char *udata)
{
struct screen *s = ctx->s;
+ struct window_pane *wp = ctx->wp;
struct grid *gd = s->grid;
struct tty_ctx ttyctx;
struct grid_utf8 gu, *tmp_gu;
@@ -1016,8 +1028,16 @@ screen_write_cell(
/* Check this will fit on the current line and wrap if not. */
if (s->cx > screen_size_x(s) - width) {
- screen_write_carriagereturn(ctx);
- screen_write_linefeed(ctx, 1);
+ /*
+ * Don't update the terminal now, just update the screen and
+ * leave the cursor to scroll naturally, unless this is only
+ * part of the screen width.
+ */
+ if (wp->xoff != 0 || wp->sx != screen_size_x(s))
+ screen_write_linefeed(ctx, 1);
+ else
+ screen_write_linefeedscreen(ctx, 1);
+ s->cx = 0; /* carriage return */
}
/* Sanity checks. */