Make -S- and -E- mean the start and end to capture-pane to avoid having

to faff around with huge numbers to get everything.
This commit is contained in:
nicm 2014-06-20 10:46:59 +00:00
parent 00ac1af43f
commit c8efffb4db
2 changed files with 35 additions and 18 deletions

View File

@ -94,6 +94,7 @@ cmd_capture_pane_history(struct args *args, struct cmd_q *cmdq,
int n, with_codes, escape_c0, join_lines; int n, with_codes, escape_c0, join_lines;
u_int i, sx, top, bottom, tmp; u_int i, sx, top, bottom, tmp;
char *cause, *buf, *line; char *cause, *buf, *line;
const char *Sflag, *Eflag;
size_t linelen; size_t linelen;
sx = screen_size_x(&wp->base); sx = screen_size_x(&wp->base);
@ -109,27 +110,37 @@ cmd_capture_pane_history(struct args *args, struct cmd_q *cmdq,
} else } else
gd = wp->base.grid; gd = wp->base.grid;
n = args_strtonum(args, 'S', INT_MIN, SHRT_MAX, &cause); Sflag = args_get(args, 'S');
if (cause != NULL) { if (Sflag != NULL && strcmp(Sflag, "-") == 0)
top = gd->hsize;
free(cause);
} else if (n < 0 && (u_int) -n > gd->hsize)
top = 0; top = 0;
else else {
top = gd->hsize + n; n = args_strtonum(args, 'S', INT_MIN, SHRT_MAX, &cause);
if (top > gd->hsize + gd->sy - 1) if (cause != NULL) {
top = gd->hsize + gd->sy - 1; 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); Eflag = args_get(args, 'E');
if (cause != NULL) { if (Eflag != NULL && strcmp(Eflag, "-") == 0)
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; bottom = gd->hsize + gd->sy - 1;
else {
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) { if (bottom < top) {
tmp = bottom; tmp = bottom;

6
tmux.1
View File

@ -1148,6 +1148,12 @@ and
.Fl E .Fl E
specify the starting and ending line numbers, zero is the first line of the specify the starting and ending line numbers, zero is the first line of the
visible pane and negative numbers are lines in the history. visible pane and negative numbers are lines in the history.
.Ql -
to
.Fl S
is the start of the history and to
.Fl E
the end of the visible pane.
The default is to capture only the visible contents of the pane. The default is to capture only the visible contents of the pane.
.It Xo .It Xo
.Ic choose-client .Ic choose-client