From 4030b0936ef94040d9b1c54607c804e7ec49a60d Mon Sep 17 00:00:00 2001 From: John Hernandez <129467592+H3rnand3zzz@users.noreply.github.com> Date: Thu, 25 Jan 2024 20:25:01 +0100 Subject: [PATCH] Fix underscrolling issue for alternative scrolling When user was scrolling down using alt + mouse wheel/arrows, he would be stuck in most of the cases after the buffer finishes due to the part of code that moves the "cursor" up to show full last page. New algorithm considers close to border cursor as passing for DB loading condition, at the same time it calculates offset, allowing flexible scroll size. The problem was introduced by @H3rnand3zzz in the following commit: 23692fedff4ec3a8c01e61697893450995bcbd3d --- src/ui/window.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ui/window.c b/src/ui/window.c index 60bf8604..0c32f0b4 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -694,7 +694,7 @@ win_page_down(ProfWin* window, int scroll_size) *page_start += scroll_size; // Scrolled down after reaching the bottom of the page - if ((*page_start == total_rows || (*page_start == page_space && *page_start >= total_rows)) && window->type == WIN_CHAT) { + if ((*page_start > total_rows - page_space || (*page_start == page_space && *page_start >= total_rows)) && window->type == WIN_CHAT) { int bf_size = buffer_size(window->layout->buffer); if (bf_size > 0) { ProfBuffEntry* last_entry = buffer_get_entry(window->layout->buffer, bf_size - 1); @@ -708,19 +708,19 @@ win_page_down(ProfWin* window, int scroll_size) g_date_time_unref(now); int offset = last_entry->y_end_pos - 1; - *page_start = offset; + *page_start = offset - page_space + scroll_size; } } total_rows = getcury(window->layout->win); - // only got half a screen, show full screen - if ((total_rows - (*page_start)) < page_space) + // near the end, but will display only part of the page space, move a bit back to show full page + if ((total_rows - *page_start) < page_space) { *page_start = total_rows - page_space; - - // went past end, show full screen - else if (*page_start >= total_rows) + // went past end, show last page + } else if (*page_start >= total_rows) { *page_start = total_rows - page_space - 1; + } window->layout->paged = 1; @@ -730,7 +730,7 @@ win_page_down(ProfWin* window, int scroll_size) } // switch off page if last line and space line visible - if ((total_rows) - *page_start == page_space) { + if (total_rows - *page_start == page_space) { window->layout->paged = 0; } }