diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-08-13 22:32:19 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-08-13 22:32:19 +0000 |
commit | 9cdf8d176076b8aac19fce68982e2004b633f46b (patch) | |
tree | 8a54610ef5e57d83bf5e4dffba443e9d4e57e9ec | |
parent | 3015ce3f0f4f6170add12c34b658583b677f3b53 (diff) |
vi(1)-style half page scroll in copy and scroll modes. Move the vi full page
scroll key to C-b instead of C-u and use C-u/C-d for half page scrolling with
vi keys. In emacs mode, half page scrolling is bound to M-Up and M-Down.
Suggested by merdely (about a year ago :-)).
-rw-r--r-- | usr.bin/tmux/mode-key.c | 8 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 6 | ||||
-rw-r--r-- | usr.bin/tmux/window-copy.c | 20 | ||||
-rw-r--r-- | usr.bin/tmux/window-scroll.c | 18 |
4 files changed, 46 insertions, 6 deletions
diff --git a/usr.bin/tmux/mode-key.c b/usr.bin/tmux/mode-key.c index 2d8e4ac02e7..07f2ed7b21c 100644 --- a/usr.bin/tmux/mode-key.c +++ b/usr.bin/tmux/mode-key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mode-key.c,v 1.12 2009/07/30 20:41:48 nicm Exp $ */ +/* $OpenBSD: mode-key.c,v 1.13 2009/08/13 22:32:18 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -149,10 +149,12 @@ const struct mode_key_entry mode_key_vi_copy[] = { { ' ', 0, MODEKEYCOPY_STARTSELECTION }, { '$', 0, MODEKEYCOPY_ENDOFLINE }, { '0', 0, MODEKEYCOPY_STARTOFLINE }, + { '\002' /* C-b */, 0, MODEKEYCOPY_PREVIOUSPAGE }, { '\003' /* C-c */, 0, MODEKEYCOPY_CANCEL }, + { '\004' /* C-d */, 0, MODEKEYCOPY_HALFPAGEDOWN }, { '\006' /* C-f */, 0, MODEKEYCOPY_NEXTPAGE }, { '\010' /* C-h */, 0, MODEKEYCOPY_LEFT }, - { '\025' /* C-u */, 0, MODEKEYCOPY_PREVIOUSPAGE }, + { '\025' /* C-u */, 0, MODEKEYCOPY_HALFPAGEUP }, { '\033' /* Escape */, 0, MODEKEYCOPY_CLEARSELECTION }, { '\r', 0, MODEKEYCOPY_COPYSELECTION }, { '^', 0, MODEKEYCOPY_BACKTOINDENTATION }, @@ -237,11 +239,13 @@ const struct mode_key_entry mode_key_emacs_copy[] = { { 'q', 0, MODEKEYCOPY_CANCEL }, { 'v' | KEYC_ESCAPE, 0, MODEKEYCOPY_PREVIOUSPAGE }, { 'w' | KEYC_ESCAPE, 0, MODEKEYCOPY_COPYSELECTION }, + { KEYC_DOWN | KEYC_ESCAPE, 0, MODEKEYCOPY_HALFPAGEDOWN }, { KEYC_DOWN, 0, MODEKEYCOPY_DOWN }, { KEYC_LEFT, 0, MODEKEYCOPY_LEFT }, { KEYC_NPAGE, 0, MODEKEYCOPY_NEXTPAGE }, { KEYC_PPAGE, 0, MODEKEYCOPY_PREVIOUSPAGE }, { KEYC_RIGHT, 0, MODEKEYCOPY_RIGHT }, + { KEYC_UP | KEYC_ESCAPE, 0, MODEKEYCOPY_HALFPAGEUP }, { KEYC_UP, 0, MODEKEYCOPY_UP }, { 0, -1, 0 } diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 9776a5b3dbd..a3b5d71f05e 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.81 2009/08/13 20:11:58 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.82 2009/08/13 22:32:18 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -388,12 +388,14 @@ enum mode_key_cmd { MODEKEYCHOICE_UP, /* Copy keys. */ - MODEKEYCOPY_CANCEL, MODEKEYCOPY_BACKTOINDENTATION, + MODEKEYCOPY_CANCEL, MODEKEYCOPY_CLEARSELECTION, MODEKEYCOPY_COPYSELECTION, MODEKEYCOPY_DOWN, MODEKEYCOPY_ENDOFLINE, + MODEKEYCOPY_HALFPAGEDOWN, + MODEKEYCOPY_HALFPAGEUP, MODEKEYCOPY_LEFT, MODEKEYCOPY_NEXTPAGE, MODEKEYCOPY_NEXTWORD, diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index c2d64ed4be7..96fb55ce871 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.19 2009/08/13 22:11:43 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.20 2009/08/13 22:32:18 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -203,6 +203,24 @@ window_copy_key(struct window_pane *wp, struct client *c, int key) window_copy_update_selection(wp); window_copy_redraw_screen(wp); break; + case MODEKEYCOPY_HALFPAGEUP: + n = screen_size_y(s) / 2; + if (data->oy + n > screen_hsize(&wp->base)) + data->oy = screen_hsize(&wp->base); + else + data->oy += n; + window_copy_update_selection(wp); + window_copy_redraw_screen(wp); + break; + case MODEKEYCOPY_HALFPAGEDOWN: + n = screen_size_y(s) / 2; + if (data->oy < n) + data->oy = 0; + else + data->oy -= n; + window_copy_update_selection(wp); + window_copy_redraw_screen(wp); + break; case MODEKEYCOPY_STARTSELECTION: window_copy_start_selection(wp); window_copy_redraw_screen(wp); diff --git a/usr.bin/tmux/window-scroll.c b/usr.bin/tmux/window-scroll.c index 5a846b8baf7..e1ff8b76a10 100644 --- a/usr.bin/tmux/window-scroll.c +++ b/usr.bin/tmux/window-scroll.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-scroll.c,v 1.7 2009/08/13 22:11:43 nicm Exp $ */ +/* $OpenBSD: window-scroll.c,v 1.8 2009/08/13 22:32:18 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -165,6 +165,22 @@ window_scroll_key(struct window_pane *wp, unused struct client *c, int key) data->oy -= n; window_scroll_redraw_screen(wp); break; + case MODEKEYCOPY_HALFPAGEUP: + n = screen_size_y(s) / 2; + if (data->oy + n > screen_hsize(&wp->base)) + data->oy = screen_hsize(&wp->base); + else + data->oy += n; + window_scroll_redraw_screen(wp); + break; + case MODEKEYCOPY_HALFPAGEDOWN: + n = screen_size_y(s) / 2; + if (data->oy < n) + data->oy = 0; + else + data->oy -= n; + window_scroll_redraw_screen(wp); + break; default: break; } |