summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2015-09-13 13:31:41 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2015-09-13 13:31:41 +0000
commit5bc858f7c2fad8c213f6828ea8a674e0f9cd506f (patch)
tree7acae19011ec935263662702865d97ac81866708 /usr.bin
parent2810709d4cf2b4ceab521012b8e1216181ca597e (diff)
Add copy-mode -e to exit copy mode when scrolling off the bottom, useful
for quick view of history, from Cam Hutchison.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/cmd-copy-mode.c8
-rw-r--r--usr.bin/tmux/tmux.116
-rw-r--r--usr.bin/tmux/tmux.h4
-rw-r--r--usr.bin/tmux/window-copy.c28
4 files changed, 44 insertions, 12 deletions
diff --git a/usr.bin/tmux/cmd-copy-mode.c b/usr.bin/tmux/cmd-copy-mode.c
index 0916be98aeb..08889f2999e 100644
--- a/usr.bin/tmux/cmd-copy-mode.c
+++ b/usr.bin/tmux/cmd-copy-mode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-copy-mode.c,v 1.20 2015/04/21 15:34:32 nicm Exp $ */
+/* $OpenBSD: cmd-copy-mode.c,v 1.21 2015/09/13 13:31:40 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 8a7793032c6..59ff090bfd3 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.449 2015/09/10 08:58:14 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.450 2015/09/13 13:31:40 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: September 10 2015 $
+.Dd $Mdocdate: September 13 2015 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -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/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 85f0929b935..8913f21d8c5 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.556 2015/09/11 14:41:50 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.557 2015/09/13 13:31:40 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c
index 3fae9aa2cf9..fe9cb7808ec 100644
--- a/usr.bin/tmux/window-copy.c
+++ b/usr.bin/tmux/window-copy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-copy.c,v 1.132 2015/08/29 09:25:00 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.133 2015/09/13 13:31:40 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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;