From: a bellenir Date: Mon, 28 Jul 2014 05:38:02 +0000 (+0000) Subject: window focus-switching X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=7f5c9a3bcd20685096a7da215c444eff5329df74;p=archive%2Fafm.git window focus-switching --- diff --git a/source/input.c b/source/input.c index e1ab9b3..f47c764 100644 --- a/source/input.c +++ b/source/input.c @@ -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}; diff --git a/source/screen.c b/source/screen.c index 1716a82..f514af7 100644 --- a/source/screen.c +++ b/source/screen.c @@ -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); +} + diff --git a/source/screen.h b/source/screen.h index c082b19..5cea675 100644 --- a/source/screen.h +++ b/source/screen.h @@ -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 */