summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2013-03-25 10:02:18 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2013-03-25 10:02:18 +0000
commit4656545e788b6d0cbfb669142c2eb5915b20340f (patch)
tree7f11ae2e5d5e87f3a1e1a39ed1aff343681eff4e
parent74b2a63d6d06f1a932452c3e09b862492cc80d0b (diff)
Add -a to capture-pane to capture alternate screen, from George Nachman.
-rw-r--r--usr.bin/tmux/cmd-capture-pane.c30
-rw-r--r--usr.bin/tmux/tmux.110
2 files changed, 27 insertions, 13 deletions
diff --git a/usr.bin/tmux/cmd-capture-pane.c b/usr.bin/tmux/cmd-capture-pane.c
index c5bfeac4a0d..c172cc604c6 100644
--- a/usr.bin/tmux/cmd-capture-pane.c
+++ b/usr.bin/tmux/cmd-capture-pane.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-capture-pane.c,v 1.19 2013/03/24 09:54:10 nicm Exp $ */
+/* $OpenBSD: cmd-capture-pane.c,v 1.20 2013/03/25 10:02:17 nicm Exp $ */
/*
* Copyright (c) 2009 Jonathan Alvarado <radobobo@users.sourceforge.net>
@@ -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';
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 114b03e5557..b3794831a16 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.338 2013/03/24 09:58:40 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.339 2013/03/25 10:02:17 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: March 24 2013 $
+.Dd $Mdocdate: March 25 2013 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -1062,8 +1062,7 @@ By default, it uses the format
but a different format may be specified with
.Fl F .
.It Xo Ic capture-pane
-.Op Fl e
-.Op Fl p
+.Op Fl aep
.Op Fl b Ar buffer-index
.Op Fl E Ar end-line
.Op Fl S Ar start-line
@@ -1077,6 +1076,9 @@ is given, the output goes to stdout, otherwise to the buffer specified with
.Fl b
or a new buffer if omitted.
If
+.Fl a
+is given, the alternate screen is used, and the history is not accessible.
+If
.Fl e
is given, the output includes escape sequences for text and background
attributes.