diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2013-02-19 09:55:02 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2013-02-19 09:55:02 +0000 |
commit | 4d1d4d6e8eb40f21eea851461ea2166242b3409f (patch) | |
tree | 8b16284be035123e66f1e12513152c0bee5ddf5f /cmd-capture-pane.c | |
parent | a96dd1932ad43457e710d154edccbfb08c1c2520 (diff) |
Add -e flag to capture-pane to include embedded ANSI SGR escape sequences, from
George Nachman.
Diffstat (limited to 'cmd-capture-pane.c')
-rw-r--r-- | cmd-capture-pane.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/cmd-capture-pane.c b/cmd-capture-pane.c index 3c09d1c4..80be0165 100644 --- a/cmd-capture-pane.c +++ b/cmd-capture-pane.c @@ -31,8 +31,8 @@ enum cmd_retval cmd_capture_pane_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_capture_pane_entry = { "capture-pane", "capturep", - "b:E:pS:t:", 0, 0, - "[-p] [-b buffer-index] [-E end-line] [-S start-line]" + "eb:E:pS:t:", 0, 0, + "[-ep] [-b buffer-index] [-E end-line] [-S start-line]" CMD_TARGET_PANE_USAGE, 0, NULL, @@ -46,12 +46,13 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx) struct args *args = self->args; struct client *c = ctx->cmdclient; struct window_pane *wp; - char *buf, *line, *cause; + char *buf, *line, *cause; struct screen *s; struct grid *gd; - int buffer, n; + int buffer, n, with_codes; u_int i, limit, top, bottom, tmp; - size_t len, linelen; + size_t len, linelen; + struct grid_cell *gc; if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL) return (CMD_RETURN_ERROR); @@ -89,16 +90,19 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx) top = tmp; } + gc = NULL; + with_codes = args_has(args, 'e'); for (i = top; i <= bottom; i++) { - line = grid_string_cells(s->grid, 0, i, screen_size_x(s)); - linelen = strlen(line); + line = grid_string_cells(s->grid, 0, i, screen_size_x(s), + &gc, with_codes); + linelen = strlen(line); - buf = xrealloc(buf, 1, len + linelen + 1); - memcpy(buf + len, line, linelen); - len += linelen; - buf[len++] = '\n'; + buf = xrealloc(buf, 1, len + linelen + 1); + memcpy(buf + len, line, linelen); + len += linelen; + buf[len++] = '\n'; - free(line); + free(line); } if (args_has(args, 'p')) { |