diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-08-13 22:11:44 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-08-13 22:11:44 +0000 |
commit | 3015ce3f0f4f6170add12c34b658583b677f3b53 (patch) | |
tree | 1fafdc3fbfcc1bb809049c1595b85d71beda829a /usr.bin | |
parent | 86268d21224b820c6b3f040263d88cd0ac335a1c (diff) |
Scroll by two less than the number of lines in the screen, like emacs, rather
than by the entire screen, to make it easier to pull things out from under the
line indicator. Suggested by claudio.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/window-copy.c | 18 | ||||
-rw-r--r-- | usr.bin/tmux/window-scroll.c | 18 |
2 files changed, 26 insertions, 10 deletions
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index 2e915bb145c..c2d64ed4be7 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.18 2009/08/13 19:35:20 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.19 2009/08/13 22:11:43 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -130,11 +130,15 @@ window_copy_pageup(struct window_pane *wp) { struct window_copy_mode_data *data = wp->modedata; struct screen *s = &data->screen; + u_int n; - if (data->oy + screen_size_y(s) > screen_hsize(&wp->base)) + n = 1; + if (screen_size_y(s) > 2) + n = screen_size_y(s) - 2; + if (data->oy + n > screen_hsize(&wp->base)) data->oy = screen_hsize(&wp->base); else - data->oy += screen_size_y(s); + data->oy += n; window_copy_update_selection(wp); window_copy_redraw_screen(wp); } @@ -167,6 +171,7 @@ window_copy_key(struct window_pane *wp, struct client *c, int key) { struct window_copy_mode_data *data = wp->modedata; struct screen *s = &data->screen; + u_int n; switch (mode_key_lookup(&data->mdata, key)) { case MODEKEYCOPY_CANCEL: @@ -188,10 +193,13 @@ window_copy_key(struct window_pane *wp, struct client *c, int key) window_copy_pageup(wp); break; case MODEKEYCOPY_NEXTPAGE: - if (data->oy < screen_size_y(s)) + n = 1; + if (screen_size_y(s) > 2) + n = screen_size_y(s) - 2; + if (data->oy < n) data->oy = 0; else - data->oy -= screen_size_y(s); + data->oy -= n; window_copy_update_selection(wp); window_copy_redraw_screen(wp); break; diff --git a/usr.bin/tmux/window-scroll.c b/usr.bin/tmux/window-scroll.c index 1522ee53e54..5a846b8baf7 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.6 2009/08/05 16:26:38 nicm Exp $ */ +/* $OpenBSD: window-scroll.c,v 1.7 2009/08/13 22:11:43 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -101,11 +101,15 @@ window_scroll_pageup(struct window_pane *wp) { struct window_scroll_mode_data *data = wp->modedata; struct screen *s = &data->screen; + u_int n; - if (data->oy + screen_size_y(s) > screen_hsize(&wp->base)) + n = 1; + if (screen_size_y(s) > 2) + n = screen_size_y(s) - 2; + if (data->oy + n > screen_hsize(&wp->base)) data->oy = screen_hsize(&wp->base); else - data->oy += screen_size_y(s); + data->oy += n; window_scroll_redraw_screen(wp); } @@ -130,6 +134,7 @@ window_scroll_key(struct window_pane *wp, unused struct client *c, int key) { struct window_scroll_mode_data *data = wp->modedata; struct screen *s = &data->screen; + u_int n; switch (mode_key_lookup(&data->mdata, key)) { case MODEKEYCOPY_CANCEL: @@ -151,10 +156,13 @@ window_scroll_key(struct window_pane *wp, unused struct client *c, int key) window_scroll_pageup(wp); break; case MODEKEYCOPY_NEXTPAGE: - if (data->oy < screen_size_y(s)) + n = 1; + if (screen_size_y(s) > 2) + n = screen_size_y(s) - 2; + if (data->oy < n) data->oy = 0; else - data->oy -= screen_size_y(s); + data->oy -= n; window_scroll_redraw_screen(wp); break; default: |