From eaec0a48f4f07060f4bdfdd19fe8cd3fe5818fe7 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 25 Oct 2024 15:13:10 +0000 Subject: [PATCH] Do not stop stop at first padding in format_grid_line and handle tabs. --- format.c | 7 +++++-- window-copy.c | 9 +++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/format.c b/format.c index 28a57b24..415640f0 100644 --- a/format.c +++ b/format.c @@ -5273,10 +5273,13 @@ format_grid_line(struct grid *gd, u_int y) for (x = 0; x < grid_line_length(gd, y); x++) { grid_get_cell(gd, x, y, &gc); if (gc.flags & GRID_FLAG_PADDING) - break; + continue; ud = xreallocarray(ud, size + 2, sizeof *ud); - memcpy(&ud[size++], &gc.data, sizeof *ud); + if (gc.flags & GRID_FLAG_TAB) + utf8_set(&ud[size++], '\t'); + else + memcpy(&ud[size++], &gc.data, sizeof *ud); } if (size != 0) { ud[size].size = 0; diff --git a/window-copy.c b/window-copy.c index 5e1a327c..4e8f947b 100644 --- a/window-copy.c +++ b/window-copy.c @@ -4823,12 +4823,9 @@ window_copy_copy_line(struct window_mode_entry *wme, char **buf, size_t *off, grid_get_cell(gd, i, sy, &gc); if (gc.flags & GRID_FLAG_PADDING) continue; - if (gc.flags & GRID_FLAG_TAB) { - memset(ud.data, 0, sizeof ud.data); - *ud.data = '\t'; - ud.have = ud.size = 1; - ud.width = gc.data.width; - } else + if (gc.flags & GRID_FLAG_TAB) + utf8_set(&ud, '\t'); + else utf8_copy(&ud, &gc.data); if (ud.size == 1 && (gc.attr & GRID_ATTR_CHARSET)) { s = tty_acs_get(NULL, ud.data[0]);