]> git.mdlowis.com Git - archive/afm.git/commitdiff
fix scrolling with expanded items
authorabellenir <a@bellenir.com>
Sat, 26 Jul 2014 10:11:43 +0000 (10:11 +0000)
committerabellenir <a@bellenir.com>
Sat, 26 Jul 2014 10:11:43 +0000 (10:11 +0000)
source/screen.c

index f7c789112e42936a0814e05aa29369a6c65f57c1..d2a3955434b10aa0d83954cd6aa2c470e8e7ad70 100644 (file)
@@ -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){