#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);
void screen_init(void) {
Master = screen_frame_new();
Screen_List = vec_new(0);
+ state_set_focused_frame(Master);
}
void screen_update(void) {
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);
}
#ifndef SCREEN_H
#define SCREEN_H
+#include <ncurses.h>
+#include "workdir.h"
+
void screen_init(void);
void screen_update(void);
void screen_open(void);
static int FrameTopBuffer = 2;
static int FrameBotBuffer = 2;
+typedef struct {
+ WINDOW* p_win;
+ WorkDir_T* workdir;
+} frame_t;
+
#endif /* SCREEN_H */
#include "state.h"
+#include "screen.h"
/** Whether the system is currently running or not. */
static bool Running = 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)
{
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;
}
#define STATE_H
#include <stdbool.h>
+#include "screen.h"
bool state_get_running(void);
void state_set_running(bool val);
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 */