aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd-copy-mode.c6
-rw-r--r--tmux.112
-rw-r--r--tmux.h2
-rw-r--r--window-copy.c26
4 files changed, 39 insertions, 7 deletions
diff --git a/cmd-copy-mode.c b/cmd-copy-mode.c
index d729ada6..e04b561b 100644
--- a/cmd-copy-mode.c
+++ b/cmd-copy-mode.c
@@ -28,8 +28,8 @@ enum cmd_retval cmd_copy_mode_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_copy_mode_entry = {
"copy-mode", NULL,
- "Mt:u", 0, 0,
- "[-Mu] " CMD_TARGET_PANE_USAGE,
+ "Met:u", 0, 0,
+ "[-Meu] " CMD_TARGET_PANE_USAGE,
0,
cmd_copy_mode_exec
};
@@ -66,7 +66,7 @@ cmd_copy_mode_exec(struct cmd *self, struct cmd_q *cmdq)
if (wp->mode != &window_copy_mode) {
if (window_pane_set_mode(wp, &window_copy_mode) != 0)
return (CMD_RETURN_NORMAL);
- window_copy_init_from_pane(wp);
+ window_copy_init_from_pane(wp, args_has(self->args, 'e'));
}
if (args_has(args, 'M')) {
if (wp->mode != NULL && wp->mode != &window_copy_mode)
diff --git a/tmux.1 b/tmux.1
index a2f6cb96..43dce715 100644
--- a/tmux.1
+++ b/tmux.1
@@ -1133,7 +1133,7 @@ The synopsis for the
command is:
.Bl -tag -width Ds
.It Xo Ic copy-mode
-.Op Fl Mu
+.Op Fl Meu
.Op Fl t Ar target-pane
.Xc
Enter copy mode.
@@ -1143,6 +1143,16 @@ option scrolls one page up.
.Fl M
begins a mouse drag (only valid if bound to a mouse key binding, see
.Sx MOUSE SUPPORT ) .
+.Fl e
+specifies that scrolling to the bottom of the history (to the visible screen)
+should exit copy mode.
+While in copy mode, pressing a key other than those used for scrolling will
+disable this behaviour.
+This is intended to allow fast scrolling through a pane's history, for
+example with:
+.Bd -literal -offset indent
+bind PageUp copy-mode -eu
+.Ed
.El
.Pp
Each window displayed by
diff --git a/tmux.h b/tmux.h
index a8cd8532..080d670d 100644
--- a/tmux.h
+++ b/tmux.h
@@ -2068,7 +2068,7 @@ extern const char window_clock_table[14][5][5];
/* window-copy.c */
extern const struct window_mode window_copy_mode;
-void window_copy_init_from_pane(struct window_pane *);
+void window_copy_init_from_pane(struct window_pane *, u_int);
void window_copy_init_for_output(struct window_pane *);
void printflike(2, 3) window_copy_add(struct window_pane *, const char *, ...);
void window_copy_vadd(struct window_pane *, const char *, va_list);
diff --git a/window-copy.c b/window-copy.c
index 460dd10b..d18c0424 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -135,7 +135,8 @@ struct window_copy_mode_data {
u_int selx;
u_int sely;
- u_int rectflag; /* are we in rectangle copy mode? */
+ int rectflag; /* in rectangle copy mode? */
+ int scroll_exit; /* exit on scroll to end? */
u_int cx;
u_int cy;
@@ -175,6 +176,7 @@ window_copy_init(struct window_pane *wp)
data->backing_written = 0;
data->rectflag = 0;
+ data->scroll_exit = 0;
data->inputtype = WINDOW_COPY_OFF;
data->inputprompt = NULL;
@@ -206,7 +208,7 @@ window_copy_init(struct window_pane *wp)
}
void
-window_copy_init_from_pane(struct window_pane *wp)
+window_copy_init_from_pane(struct window_pane *wp, u_int scroll_exit)
{
struct window_copy_mode_data *data = wp->modedata;
struct screen *s = &data->screen;
@@ -219,6 +221,7 @@ window_copy_init_from_pane(struct window_pane *wp)
data->backing = &wp->base;
data->cx = data->backing->cx;
data->cy = data->backing->cy;
+ data->scroll_exit = scroll_exit;
s->cx = data->cx;
s->cy = data->cy;
@@ -419,6 +422,13 @@ window_copy_key(struct window_pane *wp, struct client *c, struct session *sess,
}
cmd = mode_key_lookup(&data->mdata, key, &arg);
+ if (cmd != MODEKEYCOPY_PREVIOUSPAGE &&
+ cmd != MODEKEYCOPY_NEXTPAGE &&
+ cmd != MODEKEYCOPY_SCROLLUP &&
+ cmd != MODEKEYCOPY_SCROLLDOWN &&
+ cmd != MODEKEYCOPY_HALFPAGEUP &&
+ cmd != MODEKEYCOPY_HALFPAGEDOWN)
+ data->scroll_exit = 0;
switch (cmd) {
case MODEKEYCOPY_APPENDSELECTION:
if (sess != NULL) {
@@ -461,6 +471,10 @@ window_copy_key(struct window_pane *wp, struct client *c, struct session *sess,
case MODEKEYCOPY_SCROLLDOWN:
for (; np != 0; np--)
window_copy_cursor_down(wp, 1);
+ if (data->scroll_exit && data->oy == 0) {
+ window_pane_reset_mode(wp);
+ return;
+ }
break;
case MODEKEYCOPY_PREVIOUSPAGE:
for (; np != 0; np--)
@@ -476,6 +490,10 @@ window_copy_key(struct window_pane *wp, struct client *c, struct session *sess,
else
data->oy -= n;
}
+ if (data->scroll_exit && data->oy == 0) {
+ window_pane_reset_mode(wp);
+ return;
+ }
window_copy_update_selection(wp, 1);
window_copy_redraw_screen(wp);
break;
@@ -498,6 +516,10 @@ window_copy_key(struct window_pane *wp, struct client *c, struct session *sess,
else
data->oy -= n;
}
+ if (data->scroll_exit && data->oy == 0) {
+ window_pane_reset_mode(wp);
+ return;
+ }
window_copy_update_selection(wp, 1);
window_copy_redraw_screen(wp);
break;