]> git.mdlowis.com Git - archive/afm.git/commitdiff
add focused window to state
authora bellenir <a@bellenir.com>
Wed, 23 Jul 2014 22:41:30 +0000 (22:41 +0000)
committera bellenir <a@bellenir.com>
Wed, 23 Jul 2014 22:41:30 +0000 (22:41 +0000)
source/screen.c
source/screen.h
source/state.c
source/state.h

index 8357496eef77ffc5cc8e7acc6a5c0a8f6dce374b..89aed2bc2089a5b0a801527e209f2afdc10e2d88 100644 (file)
@@ -7,11 +7,6 @@
 #include "vec.h"
 #include "mem.h"
 
-typedef struct {
-    WINDOW* p_win;
-    WorkDir_T* workdir;
-} frame_t;
-
 static void screen_place_windows(void);
 static frame_t* screen_frame_new(void);
 static void screen_frame_free(void* p_frame);
@@ -23,6 +18,7 @@ static vec_t* Screen_List;
 void screen_init(void) {
     Master = screen_frame_new();
     Screen_List = vec_new(0);
+    state_set_focused_frame(Master);
 }
 
 void screen_update(void) {
@@ -105,12 +101,12 @@ void screen_frame_draw_files(frame_t* frame){
        wattroff(frame->p_win, A_UNDERLINE);
        //list files
        while (i < vec_size(frame->workdir->vfiles)){
-               if(i == frame->workdir->idx){
+               if(frame == state_get_focused_frame() && i == frame->workdir->idx){
                        wattron(frame->p_win, A_STANDOUT);
                        wattron(frame->p_win, A_BOLD);
                }
         mvwaddnstr(frame->p_win, FrameTopBuffer+i-frame->workdir->top_index, 1, vec_at(frame->workdir->vfiles, i), cols-2);
-               if(i == frame->workdir->idx){
+               if(frame == state_get_focused_frame() && i == frame->workdir->idx){
                        wattroff(frame->p_win, A_STANDOUT);
                        wattroff(frame->p_win, A_BOLD);
                }
index ef8a66976b597646762928f3f638352508510abc..ff017f62b3cffd69e59e094d6a1313648fe93b13 100644 (file)
@@ -7,6 +7,9 @@
 #ifndef SCREEN_H
 #define SCREEN_H
 
+#include <ncurses.h>
+#include "workdir.h"
+
 void screen_init(void);
 void screen_update(void);
 void screen_open(void);
@@ -16,4 +19,9 @@ void screen_close(void);
 static int FrameTopBuffer = 2;
 static int FrameBotBuffer = 2;
 
+typedef struct {
+    WINDOW* p_win;
+    WorkDir_T* workdir;
+} frame_t;
+
 #endif /* SCREEN_H */
index 18532da8ba030a3daf2c4e277bf928bc223cec77..e8158c3b0f54e56cc19d23335463df933b667aa9 100644 (file)
@@ -1,4 +1,5 @@
 #include "state.h"
+#include "screen.h"
 
 /** Whether the system is currently running or not. */
 static bool Running = true;
@@ -12,8 +13,8 @@ static bool Resized = true;
 /** Whether the aardvark should be displayed */
 static bool AardvarkOn = false;
 
-/** The currently focused frame id */
-static int Focused_Index = 0;
+/** A pointer to the currently focused frame */
+static frame_t* Focused_Frame = 0;
 
 bool state_get_running(void)
 {
@@ -55,13 +56,12 @@ void state_set_aardvark_mode(bool val)
     AardvarkOn = val;
 }
 
-int state_get_focused_frame(void)
-{
-    return Focused_Index;
+frame_t* state_get_focused_frame(void) {
+       return Focused_Frame;
 }
 
-void state_set_focused_frame(int id)
+void state_set_focused_frame(frame_t *p_frame)
 {
-    Focused_Index = id;
+    Focused_Frame = p_frame;
 }
 
index 6c89af83aba6c39afdd1c1d00745871813e96747..92d89d60db23127951df0c1322f4285a0a7ed92e 100644 (file)
@@ -8,6 +8,7 @@
 #define STATE_H
 
 #include <stdbool.h>
+#include "screen.h"
 
 bool state_get_running(void);
 void state_set_running(bool val);
@@ -17,7 +18,7 @@ bool state_get_screen_resized(void);
 void state_set_screen_resized(bool val);
 bool state_get_aardvark_mode(void);
 void state_set_aardvark_mode(bool val);
-int state_get_focused_frame(void);
-void state_set_focused_frame(int id);
+frame_t* state_get_focused_frame(void);
+void state_set_focused_frame(frame_t* p_frame);
 
 #endif /* STATE_H */