]> git.mdlowis.com Git - archive/afm.git/commitdiff
fix highlighting for new windows & fix segfault when closing windows
authora bellenir <a@bellenir.com>
Mon, 28 Jul 2014 08:45:45 +0000 (08:45 +0000)
committera bellenir <a@bellenir.com>
Mon, 28 Jul 2014 08:45:45 +0000 (08:45 +0000)
source/frame.c
source/screen.c

index 17b36344a2f4a851fc87a7183b8f38c65f5b8235..1b618616df564644e87b309d1308f9249e3ed146 100644 (file)
@@ -102,9 +102,6 @@ void frame_draw_files(Frame_T* frame){
     while (file_i < vec_size(frame->workdir->vfiles)){
         File_T* file = (File_T*)vec_at(frame->workdir->vfiles, file_i);
         bool dir = is_dir(file->path);
-        if(frame == state_get_focused_frame() && file_i == frame->workdir->idx){
-            wattron(frame->p_win, A_STANDOUT | A_BOLD);
-        }
         if(dir) wattron(frame->p_win, COLOR_PAIR(DIRECTORY));
         mvwaddnstr(frame->p_win, frame_i, 1, file->name, cols-2);
         frame_i++;
@@ -116,6 +113,7 @@ void frame_draw_files(Frame_T* frame){
         file_i++;
         if((frame_i+FrameBotBuffer) > rows) break;
     }
+    if(frame == state_get_focused_frame()) frame_set_highlighting(frame, true, false);
 }
 
 
@@ -124,9 +122,9 @@ void frame_set_highlighting(Frame_T* frame, bool highlight, bool refresh_win){
                int line = FrameTopBuffer + count_double_lines_to_idx(frame, false) + frame->workdir->idx - frame->top_index;
                attr_t newattr= highlight ? (A_STANDOUT|A_BOLD) : A_NORMAL;
                File_T* file = (File_T*) vec_at(frame->workdir->vfiles, frame->workdir->idx);
-               short color = (is_dir(file->path) ? DIRECTORY : 0);
+               short color = (file && is_dir(file->path) ? DIRECTORY : 0);
                mvwchgat(frame->p_win, line, 0, -1, newattr, color, NULL);
-               if(file->expanded) mvwchgat(frame->p_win, line+1, color, -1, newattr, 0, NULL);
+               if(file && file->expanded) mvwchgat(frame->p_win, line+1, color, -1, newattr, 0, NULL);
                if(frame_scroll(frame)) state_set_screen_dirty(true);
                if(refresh_win) wrefresh(frame->p_win);
        }
index d452942c17030e4fa0ae5dae768d65096106664d..ab6d9822a6264269d055ba3870cfb63f6899982b 100644 (file)
@@ -62,8 +62,10 @@ static int get_focused_frame_index(void){
 void screen_close(void) {
     if (Frame_List->head != Frame_List->tail) {
         int i = get_focused_frame_index();
-        list_node_t* new_focus = state_get_focused_node()->next;
         if(i >= 0){ /* negative if node not found */
+                       list_node_t* doomed_node = state_get_focused_node();
+                       mem_retain(doomed_node);
+                       list_node_t* new_focus = doomed_node->next;
             /* TODO: add function to list that allows removing with node pointer instead of just index */
             list_delete(Frame_List, i);
             // new_focus will be null if rm-d tail: set it to new tail
@@ -71,6 +73,7 @@ void screen_close(void) {
             state_set_focused_node(new_focus);
             state_set_screen_dirty(true);
             state_set_screen_resized(true);
+            mem_release(doomed_node);
         }
     }
 }