diff options
author | 2015-09-13 13:31:40 +0000 | |
---|---|---|
committer | 2015-09-13 13:31:40 +0000 | |
commit | 47f0136494ac7c4768d11d4de16a0e44e94fe94c (patch) | |
tree | dbab9615fafd2fb0d3700d46aea7b47fd3e29603 /usr.bin/tmux/window-copy.c | |
parent | - FOO=bar; export FOO -> export FOO=bar (diff) | |
download | wireguard-openbsd-47f0136494ac7c4768d11d4de16a0e44e94fe94c.tar.xz wireguard-openbsd-47f0136494ac7c4768d11d4de16a0e44e94fe94c.zip |
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/tmux/window-copy.c')
-rw-r--r-- | usr.bin/tmux/window-copy.c | 28 |
1 files changed, 25 insertions, 3 deletions
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; |