]> git.mdlowis.com Git - archive/afm.git/commitdiff
window focus-switching
authora bellenir <a@bellenir.com>
Mon, 28 Jul 2014 05:38:02 +0000 (05:38 +0000)
committera bellenir <a@bellenir.com>
Mon, 28 Jul 2014 05:38:02 +0000 (05:38 +0000)
source/input.c
source/screen.c
source/screen.h

index e1ab9b31a3c2c1d81dea9f744a1e76475a1bbb8d..f47c764c2c005057cc8c531d340a563c9a076a9f 100644 (file)
@@ -106,8 +106,9 @@ static binding_t Default_Bindings[] = {
     { "D",  &handle_page_down },
     { "l",  &handle_expand },
     { "h",  &handle_collapse },
-    //{ "wj", NULL },
-    //{ "wk", NULL },
+    { "wj", &screen_focus_next },
+    { "wk", &screen_focus_prev },
+    { "w\n", &screen_focus_master }
 };
 
 static char Key_Buffer[16] = {0};
index 1716a822ba4715f710f75863f7260e637836edfc..f514af79e795a5aefff97caf50151c1b1e9bba79 100644 (file)
@@ -114,11 +114,32 @@ static void screen_place_windows(void) {
 }
 
 static void screen_refresh_curr_frame(void) {
-    /* Print the master frame */
-    Frame_T* p_frame = list_at(Frame_List,0)->contents;
+    Frame_T* p_frame = state_get_focused_frame();
     wclear(p_frame->p_win);
     frame_draw_files(p_frame);
     box(p_frame->p_win, 0 , 0);
     wrefresh(p_frame->p_win);
 }
 
+void screen_focus_next(void){
+       list_node_t* focused = state_get_focused_node();
+       if(focused->next != NULL){
+               state_set_focused_node(focused->next);
+               state_set_screen_dirty(true);
+       }
+}
+
+void screen_focus_prev(void){
+       int i = get_focused_frame_index();
+       if(i > 0){
+               list_node_t* prev = list_at(Frame_List, i-1);
+               if(prev) state_set_focused_node(prev);
+               state_set_screen_dirty(true);
+       }
+}
+
+void screen_focus_master(void){
+       state_set_focused_node(Frame_List->head);
+       state_set_screen_dirty(true);
+}
+
index c082b195dd4e2dc17595150e90b69aa842bf39ef..5cea6753cb96256f48b1499a6893476591478486 100644 (file)
@@ -12,6 +12,9 @@ void screen_deinit(void);
 void screen_update(void);
 void screen_open(void);
 void screen_close(void);
+void screen_focus_next(void);
+void screen_focus_prev(void);
+void screen_focus_master(void);
 
 
 #endif /* SCREEN_H */