From 525320071c661c874295fa6dbb83317bb0d9ebfa Mon Sep 17 00:00:00 2001 From: Tomasz Pala Date: Fri, 5 Nov 2010 13:19:19 +0200 Subject: [PATCH] Ticket #2135: End button in MC viewer jumps too far Previous solutions have broken one of the viewer features (http://www.midnight-commander.org/ticket/1778) What suggest is fixing PgDn in a way, that it switches to one-line mode after EOF and add a check to ensure, that at least one last line stays visible (4.7.1 behaviour of end/pgdn was irritating indeed). With this patch, PageDown at the last page scrolls file line by line instead of entire page. This is feature, not a bug. :) Signed-off-by: Slava Zanko --- src/viewer/move.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/viewer/move.c b/src/viewer/move.c index 2296ff45f..873ed9afe 100644 --- a/src/viewer/move.c +++ b/src/viewer/move.c @@ -158,9 +158,7 @@ mcview_move_down (mcview_t * view, off_t lines) if (view->dpy_end - view->dpy_start > last_byte - view->dpy_end) { - i = 0; - new_offset = view->dpy_end; - while (view->dpy_end < last_byte && lines-- > 0) + while (lines-- > 0) { new_offset = mcview_eol (view, view->dpy_end); if (view->text_wrap_mode) @@ -170,19 +168,21 @@ mcview_move_down (mcview_t * view, off_t lines) new_offset = mcview_eol (view, view->dpy_start); if (view->text_wrap_mode) new_offset = min (new_offset, view->dpy_start + (off_t) view->data_area.width); - view->dpy_start = new_offset; + if (new_offset < last_byte) + view->dpy_start = new_offset; + if (view->dpy_end >= last_byte) + break; } - view->dpy_end = last_byte; } else { - - for (i = 0; i < lines && view->dpy_end < last_byte && new_offset < last_byte; i++) + for (i = 0; i < lines && new_offset < last_byte; i++) { new_offset = mcview_eol (view, view->dpy_start); if (view->text_wrap_mode) new_offset = min (new_offset, view->dpy_start + (off_t) view->data_area.width); - view->dpy_start = new_offset; + if (new_offset < last_byte) + view->dpy_start = new_offset; } } }