Adds a '-h' option to capture the entire pane without providing the appropriate co-ordinates.
Signed-off-by: Raghavendra D Prabhu <rpra...@wnohang.net> diff --git a/cmd-capture-pane.c b/cmd-capture-pane.c index a94c717..11c4367 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:S:t:", 0, 0, - "[-b buffer-index] [-E end-line] [-S start-line] [-t target-pane]", + "b:E:S:t:h", 0, 0, + "[-b buffer-index] [-E end-line] [-S start-line] [-t target-pane] [-h ]", 0, NULL, NULL, @@ -59,44 +59,49 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx) buf = NULL; len = 0; - n = args_strtonum(args, 'S', INT_MIN, SHRT_MAX, &cause); - if (cause != NULL) { - top = gd->hsize; - free(cause); - } else if (n < 0 && (u_int) -n > gd->hsize) + if (args_has(args, 'h')) { 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', INT_MIN, SHRT_MAX, &cause); - if (cause != NULL) { - bottom = gd->hsize + gd->sy - 1; - free(cause); - } 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); - memcpy(buf + len, line, linelen); - len += linelen; - buf[len++] = '\n'; - - free(line); + } else { + n = args_strtonum(args, 'S', INT_MIN, SHRT_MAX, &cause); + if (cause != NULL) { + top = gd->hsize; + free(cause); + } 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', INT_MIN, SHRT_MAX, &cause); + if (cause != NULL) { + bottom = gd->hsize + gd->sy - 1; + free(cause); + } 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); + memcpy(buf + len, line, linelen); + len += linelen; + buf[len++] = '\n'; + + free(line); + } } limit = options_get_number(&global_options, "buffer-limit"); -- 1.8.0.2 ------------------------------------------------------------------------------ LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users