aboutsummaryrefslogtreecommitdiff
path: root/cmd-capture-pane.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2011-04-06 22:19:42 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2011-04-06 22:19:42 +0000
commit0a2b3492c3842ad8ce83314a7c72455008c39485 (patch)
treecf2c286f4dd1c4a12b0b2b73a74f84b6cbd858bf /cmd-capture-pane.c
parent8ab7fcf7eba8121837a4edf0c214ec0acd31e6bf (diff)
downloadrtmux-0a2b3492c3842ad8ce83314a7c72455008c39485.tar.gz
rtmux-0a2b3492c3842ad8ce83314a7c72455008c39485.tar.bz2
rtmux-0a2b3492c3842ad8ce83314a7c72455008c39485.zip
|PatchSet 874
|Date: 2011/03/28 21:17:39 |Author: nicm |Branch: HEAD |Tag: (none) |Log: |Allow a start and end line to be specified for capture-pane which may be |negative to capture part of the history. Prompted by request from Victor |J Orlikowski.
Diffstat (limited to 'cmd-capture-pane.c')
-rw-r--r--cmd-capture-pane.c42
1 files changed, 35 insertions, 7 deletions
diff --git a/cmd-capture-pane.c b/cmd-capture-pane.c
index 6a14a434..1880ba77 100644
--- a/cmd-capture-pane.c
+++ b/cmd-capture-pane.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-capture-pane.c,v 1.6 2011-01-07 14:45:33 tcunha Exp $ */
+/* $Id: cmd-capture-pane.c,v 1.7 2011-04-06 22:19:42 nicm Exp $ */
/*
* Copyright (c) 2009 Jonathan Alvarado <radobobo@users.sourceforge.net>
@@ -31,8 +31,8 @@ int cmd_capture_pane_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_capture_pane_entry = {
"capture-pane", "capturep",
- "b:t:", 0, 0,
- "[-b buffer-index] [-t target-pane]",
+ "b:E:S:t:", 0, 0,
+ "[-b buffer-index] [-E end-line] [-S start-line] [-t target-pane]",
0,
NULL,
NULL,
@@ -46,19 +46,47 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
struct window_pane *wp;
char *buf, *line, *cause;
struct screen *s;
- int buffer;
- u_int i, limit;
+ struct grid *gd;
+ int buffer, n;
+ u_int i, limit, top, bottom, tmp;
size_t len, linelen;
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
return (-1);
s = &wp->base;
+ gd = s->grid;
buf = NULL;
len = 0;
- for (i = 0; i < screen_size_y(s); i++) {
- line = grid_view_string_cells(s->grid, 0, i, screen_size_x(s));
+ n = args_strtonum(args, 'S', SHRT_MIN, SHRT_MAX, &cause);
+ if (cause != NULL)
+ top = gd->hsize;
+ else if (n < 0 && (u_int) -n > gd->hsize)
+ top = 0;
+ else
+ top = gd->hsize + n;
+ if (top > gd->hsize + gd->sy - 1)
+ top = gd->hsize + gd->sy - 1;
+
+ n = args_strtonum(args, 'E', SHRT_MIN, SHRT_MAX, &cause);
+ if (cause != NULL)
+ bottom = gd->hsize + gd->sy - 1;
+ else if (n < 0 && (u_int) -n > gd->hsize)
+ bottom = 0;
+ else
+ bottom = gd->hsize + n;
+ if (bottom > gd->hsize + gd->sy - 1)
+ bottom = gd->hsize + gd->sy - 1;
+
+ if (bottom < top) {
+ tmp = bottom;
+ bottom = top;
+ top = tmp;
+ }
+
+ for (i = top; i <= bottom; i++) {
+ line = grid_string_cells(s->grid, 0, i, screen_size_x(s));
linelen = strlen(line);
buf = xrealloc(buf, 1, len + linelen + 1);