aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2013-03-04 11:03:03 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2013-03-04 11:03:03 +0000
commitaaeee34c3250892c8a20e9c95efe66c1d0ec4be2 (patch)
tree71ddef687aed06d4eab527d00c2ec630253ac566
parent70397e4a957eefc2808c600214d8f7689caead71 (diff)
downloadrtmux-aaeee34c3250892c8a20e9c95efe66c1d0ec4be2.tar.gz
rtmux-aaeee34c3250892c8a20e9c95efe66c1d0ec4be2.tar.bz2
rtmux-aaeee34c3250892c8a20e9c95efe66c1d0ec4be2.zip
Preserve trailing spaces with capture-pane -J, from George Nachman.
-rw-r--r--cmd-capture-pane.c2
-rw-r--r--grid-view.c2
-rw-r--r--grid.c8
-rw-r--r--tmux.12
-rw-r--r--tmux.h2
5 files changed, 9 insertions, 7 deletions
diff --git a/cmd-capture-pane.c b/cmd-capture-pane.c
index 118bf946..e9251389 100644
--- a/cmd-capture-pane.c
+++ b/cmd-capture-pane.c
@@ -111,7 +111,7 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_q *cmdq)
gc = NULL;
for (i = top; i <= bottom; i++) {
line = grid_string_cells(gd, 0, i, sx, &gc, with_codes,
- escape_c0);
+ escape_c0, !join_lines);
linelen = strlen(line);
buf = xrealloc(buf, 1, len + linelen + 1);
diff --git a/grid-view.c b/grid-view.c
index 3c5a8728..7ef443a3 100644
--- a/grid-view.c
+++ b/grid-view.c
@@ -234,5 +234,5 @@ grid_view_string_cells(struct grid *gd, u_int px, u_int py, u_int nx)
px = grid_view_x(gd, px);
py = grid_view_y(gd, py);
- return (grid_string_cells(gd, px, py, nx, NULL, 0, 0));
+ return (grid_string_cells(gd, px, py, nx, NULL, 0, 0, 0));
}
diff --git a/grid.c b/grid.c
index 1624b2d0..b30127f3 100644
--- a/grid.c
+++ b/grid.c
@@ -583,7 +583,7 @@ grid_string_cells_code(const struct grid_cell *lastgc,
/* Convert cells into a string. */
char *
grid_string_cells(struct grid *gd, u_int px, u_int py, u_int nx,
- struct grid_cell **lastgc, int with_codes, int escape_c0)
+ struct grid_cell **lastgc, int with_codes, int escape_c0, int trim)
{
const struct grid_cell *gc;
static struct grid_cell lastgc1;
@@ -638,8 +638,10 @@ grid_string_cells(struct grid *gd, u_int px, u_int py, u_int nx,
off += size;
}
- while (off > 0 && buf[off - 1] == ' ')
- off--;
+ if (trim) {
+ while (off > 0 && buf[off - 1] == ' ')
+ off--;
+ }
buf[off] = '\0';
return (buf);
diff --git a/tmux.1 b/tmux.1
index a094d58b..a65ce221 100644
--- a/tmux.1
+++ b/tmux.1
@@ -1092,7 +1092,7 @@ attributes.
.Fl C
also escapes non-printable characters as octal \\xxx.
.Fl J
-joins wrapped lines.
+joins wrapped lines and preserves trailing spaces at each line's end.
.Pp
.Fl S
and
diff --git a/tmux.h b/tmux.h
index 0df1f4d8..c1ad6628 100644
--- a/tmux.h
+++ b/tmux.h
@@ -2002,7 +2002,7 @@ void grid_clear_lines(struct grid *, u_int, u_int);
void grid_move_lines(struct grid *, u_int, u_int, u_int);
void grid_move_cells(struct grid *, u_int, u_int, u_int, u_int);
char *grid_string_cells(struct grid *, u_int, u_int, u_int,
- struct grid_cell **, int, int);
+ struct grid_cell **, int, int, int);
void grid_duplicate_lines(
struct grid *, u_int, struct grid *, u_int, u_int);
u_int grid_reflow(struct grid *, struct grid *, u_int);