summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/tty.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2017-07-21 14:25:30 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2017-07-21 14:25:30 +0000
commitba43fb114dd859a4e7f8a1d9b5f9a30fc3c9e043 (patch)
tree15939e1edfd832ffc5cb760b0196478b5ecaafca /usr.bin/tmux/tty.c
parentd499df9238039c4f5587f56482973ff14dbab891 (diff)
Trim trailing spaces from full line when it is clearly OK to do so.
Diffstat (limited to 'usr.bin/tmux/tty.c')
-rw-r--r--usr.bin/tmux/tty.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index cfb811cf0fc..db69f056033 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.290 2017/06/06 14:53:28 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.291 2017/07/21 14:25:29 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -885,7 +885,7 @@ tty_draw_line(struct tty *tty, const struct window_pane *wp,
u_int i, j, sx, nx, width;
int flags, cleared = 0;
char buf[512];
- size_t len;
+ size_t len, old_len;
flags = (tty->flags & TTY_NOCURSOR);
tty->flags |= TTY_NOCURSOR;
@@ -973,8 +973,17 @@ tty_draw_line(struct tty *tty, const struct window_pane *wp,
}
}
if (len != 0) {
- tty_attributes(tty, &last, wp);
- tty_putn(tty, buf, len, width);
+ if (grid_cells_equal(&last, &grid_default_cell)) {
+ old_len = len;
+ while (len > 0 && buf[len - 1] == ' ')
+ len--;
+ log_debug("%s: trimmed %zu spaces", __func__,
+ old_len - len);
+ }
+ if (len != 0) {
+ tty_attributes(tty, &last, wp);
+ tty_putn(tty, buf, len, width);
+ }
}
nx = screen_size_x(s) - sx;