diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2013-02-24 07:52:03 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2013-02-24 07:52:03 +0000 |
commit | b2a61348ddd2dbe91c6b656ef7ddd64a535e0b20 (patch) | |
tree | 26f4424227ccae92ee622ce0fbe865a3c8883571 /cmd-capture-pane.c | |
parent | 234f6d27c17de09e0dcdb3eb224ab0821ab17993 (diff) | |
download | rtmux-b2a61348ddd2dbe91c6b656ef7ddd64a535e0b20.tar.gz rtmux-b2a61348ddd2dbe91c6b656ef7ddd64a535e0b20.tar.bz2 rtmux-b2a61348ddd2dbe91c6b656ef7ddd64a535e0b20.zip |
Add -a to capture-pane to capture alternate screen, from George Nachman.
Diffstat (limited to 'cmd-capture-pane.c')
-rw-r--r-- | cmd-capture-pane.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/cmd-capture-pane.c b/cmd-capture-pane.c index cd899dd4..a6767141 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_q *); const struct cmd_entry cmd_capture_pane_entry = { "capture-pane", "capturep", - "b:CeE:JpS:t:", 0, 0, - "[-CeJp] [-b buffer-index] [-E end-line] [-S start-line]" + "ab:CeE:JpS:t:", 0, 0, + "[-aCeJp] [-b buffer-index] [-E end-line] [-S start-line]" CMD_TARGET_PANE_USAGE, 0, NULL, @@ -50,15 +50,27 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_q *cmdq) struct screen *s; struct grid *gd; int buffer, n, with_codes, escape_c0, join_lines; - u_int i, limit, top, bottom, tmp; + u_int i, limit, top, bottom, tmp, sx; size_t len, linelen; struct grid_cell *gc; const struct grid_line *gl; if (cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp) == NULL) return (CMD_RETURN_ERROR); - s = &wp->base; - gd = s->grid; + + if (args_has(args, 'a')) { + s = NULL; + gd = wp->saved_grid; + sx = screen_size_x(&wp->base); + if (gd == NULL) { + cmdq_error(cmdq, "no alternate screen"); + return (CMD_RETURN_ERROR); + } + } else { + s = &wp->base; + sx = screen_size_x(s); + gd = s->grid; + } buf = NULL; len = 0; @@ -97,15 +109,15 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_q *cmdq) gc = NULL; for (i = top; i <= bottom; i++) { - line = grid_string_cells(s->grid, 0, i, screen_size_x(s), - &gc, with_codes, escape_c0); + line = grid_string_cells(gd, 0, i, sx, &gc, with_codes, + escape_c0); linelen = strlen(line); buf = xrealloc(buf, 1, len + linelen + 1); memcpy(buf + len, line, linelen); len += linelen; - gl = grid_peek_line(s->grid, i); + gl = grid_peek_line(gd, i); if (!join_lines || !(gl->flags & GRID_LINE_WRAPPED)) buf[len++] = '\n'; |