From e0d49ad7589e5a2c18a81009e797b5b5b198a420 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 21 Jul 2017 12:58:02 +0000 Subject: [PATCH 1/3] Allow ispunct() as well as isalnum() when parsing initial window names. --- names.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/names.c b/names.c index 1997899e..661ba06e 100644 --- a/names.c +++ b/names.c @@ -151,7 +151,9 @@ parse_window_name(const char *in) if (*name != '\0') { ptr = name + strlen(name) - 1; - while (ptr > name && !isalnum((u_char)*ptr)) + while (ptr > name && + !isalnum((u_char)*ptr) && + !ispunct((u_char)*ptr)) *ptr-- = '\0'; } From 8c6ad5532076254ec138f9b598b41d035bdf68e7 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 21 Jul 2017 14:25:29 +0000 Subject: [PATCH 2/3] Trim trailing spaces from full line when it is clearly OK to do so. --- tty.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tty.c b/tty.c index 77291daa..2d3f2b86 100644 --- a/tty.c +++ b/tty.c @@ -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; From 3bb426d92c482396fb7b1a8f8bc1c5ab525da1c6 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 21 Jul 2017 22:55:45 +0000 Subject: [PATCH 3/3] Use the actual width written rather than the possible width to clear. --- tty.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tty.c b/tty.c index 2d3f2b86..d83d4ced 100644 --- a/tty.c +++ b/tty.c @@ -882,7 +882,7 @@ tty_draw_line(struct tty *tty, const struct window_pane *wp, struct screen *s, u_int py, u_int ox, u_int oy) { struct grid_cell gc, last; - u_int i, j, sx, nx, width; + u_int i, j, ux, sx, nx, width; int flags, cleared = 0; char buf[512]; size_t len, old_len; @@ -903,6 +903,7 @@ tty_draw_line(struct tty *tty, const struct window_pane *wp, sx = s->grid->linedata[s->grid->hsize + py].cellsize; if (sx > tty->sx) sx = tty->sx; + ux = 0; if (wp == NULL || py == 0 || @@ -944,6 +945,7 @@ tty_draw_line(struct tty *tty, const struct window_pane *wp, (sizeof buf) - len < gc.data.size)) { tty_attributes(tty, &last, wp); tty_putn(tty, buf, len, width); + ux += width; len = 0; width = 0; @@ -966,6 +968,7 @@ tty_draw_line(struct tty *tty, const struct window_pane *wp, for (j = 0; j < gc.data.size; j++) tty_putc(tty, gc.data.data[j]); } + ux += gc.data.width; } else { memcpy(buf + len, gc.data.data, gc.data.size); len += gc.data.size; @@ -975,21 +978,24 @@ tty_draw_line(struct tty *tty, const struct window_pane *wp, if (len != 0) { if (grid_cells_equal(&last, &grid_default_cell)) { old_len = len; - while (len > 0 && buf[len - 1] == ' ') + while (len > 0 && buf[len - 1] == ' ') { len--; + width--; + } log_debug("%s: trimmed %zu spaces", __func__, old_len - len); } if (len != 0) { tty_attributes(tty, &last, wp); tty_putn(tty, buf, len, width); + ux += width; } } - nx = screen_size_x(s) - sx; - if (!cleared && sx < tty->sx && nx != 0) { + nx = screen_size_x(s) - ux; + if (!cleared && ux < tty->sx && nx != 0) { tty_default_attributes(tty, wp, 8); - tty_clear_line(tty, wp, oy + py, ox + sx, nx, 8); + tty_clear_line(tty, wp, oy + py, ox + ux, nx, 8); } tty->flags = (tty->flags & ~TTY_NOCURSOR) | flags;