From ed1f3e3687416e2f681f56d1fc246e454b8f3014 Mon Sep 17 00:00:00 2001 From: abellenir Date: Sat, 26 Jul 2014 10:11:43 +0000 Subject: [PATCH] fix scrolling with expanded items --- source/screen.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/source/screen.c b/source/screen.c index f7c7891..d2a3955 100644 --- a/source/screen.c +++ b/source/screen.c @@ -134,13 +134,23 @@ static void screen_frame_free(void* p_frame_ptr) { if(p_frame->workdir) mem_release(p_frame->workdir); } +static int count_double_lines(frame_t* p_frame){ + int count = 0; + for(int i = p_frame->top_index; i <= p_frame->workdir->idx; i++) + if (((File_T*)vec_at(p_frame->workdir->vfiles, i))->expanded) count++; + return count; +} + static void screen_frame_scroll(frame_t* p_frame){ int rows,cols; getmaxyx(p_frame->p_win, rows, cols); - if(p_frame->workdir->idx < p_frame->top_index) + if(p_frame->workdir->idx < p_frame->top_index){ p_frame->top_index = p_frame->workdir->idx; - else if (p_frame->top_index < p_frame->workdir->idx-(rows-FrameTopBuffer-FrameBotBuffer)) - p_frame->top_index = p_frame->workdir->idx-(rows-FrameTopBuffer-FrameBotBuffer); + }else{ + int doublelines = count_double_lines(p_frame); + if (p_frame->top_index < doublelines+p_frame->workdir->idx-(rows-FrameTopBuffer-FrameBotBuffer)) + p_frame->top_index = doublelines+p_frame->workdir->idx-(rows-FrameTopBuffer-FrameBotBuffer); + } } void screen_frame_draw_files(frame_t* frame){ -- 2.54.0