version 1.6, 2011/01/04 00:42:46 |
version 1.7, 2011/03/28 20:17:39 |
|
|
|
|
const struct cmd_entry cmd_capture_pane_entry = { |
const struct cmd_entry cmd_capture_pane_entry = { |
"capture-pane", "capturep", |
"capture-pane", "capturep", |
"b:t:", 0, 0, |
"b:E:S:t:", 0, 0, |
"[-b buffer-index] [-t target-pane]", |
"[-b buffer-index] [-E end-line] [-S start-line] [-t target-pane]", |
0, |
0, |
NULL, |
NULL, |
NULL, |
NULL, |
|
|
struct window_pane *wp; |
struct window_pane *wp; |
char *buf, *line, *cause; |
char *buf, *line, *cause; |
struct screen *s; |
struct screen *s; |
int buffer; |
struct grid *gd; |
u_int i, limit; |
int buffer, n; |
|
u_int i, limit, top, bottom, tmp; |
size_t len, linelen; |
size_t len, linelen; |
|
|
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL) |
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL) |
return (-1); |
return (-1); |
s = &wp->base; |
s = &wp->base; |
|
gd = s->grid; |
|
|
buf = NULL; |
buf = NULL; |
len = 0; |
len = 0; |
|
|
for (i = 0; i < screen_size_y(s); i++) { |
n = args_strtonum(args, 'S', SHRT_MIN, SHRT_MAX, &cause); |
line = grid_view_string_cells(s->grid, 0, i, screen_size_x(s)); |
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); |
linelen = strlen(line); |
|
|
buf = xrealloc(buf, 1, len + linelen + 1); |
buf = xrealloc(buf, 1, len + linelen + 1); |