- #include "screen.h"
- #include "state.h"
- #include "aardvark.h"
- #include "workdir.h"
+ /* external libraries */
#include <ncurses.h>
+ #include <unistd.h>
+ #include <stdio.h>
+
+ /* internal libraries */
+ #include "vec.h"
+#include "list.h"
#include "mem.h"
- typedef struct {
- WINDOW* p_win;
- } frame_t;
+ /* internal headers */
+ #include "screen.h"
+ #include "state.h"
+ #include "aardvark.h"
+ #include "workdir.h"
static void screen_place_windows(void);
static frame_t* screen_frame_new(void);
static void screen_frame_free(void* p_frame);
+ void screen_frame_draw_files(frame_t* frame);
-static frame_t* Master;
-static vec_t* Screen_List;
+static list_t* Screen_List;
+
++frame_t* master_frame(void){
++ return (frame_t*) Screen_List->head->contents;
++}
+
void screen_init(void) {
- Master = screen_frame_new();
- Screen_List = vec_new(0);
- state_set_focused_frame(Master);
+ Screen_List = list_new();
+ list_push_back(Screen_List, screen_frame_new());
++ state_set_focused_frame(master_frame());
+}
+
+void screen_deinit(void) {
+ mem_release(Screen_List);
}
void screen_update(void) {
getmaxyx(stdscr, lines, cols);
/* Print the master frame */
- p_frame = Master;
+ p_frame = list_at(Screen_List,0)->contents;
mvwin(p_frame->p_win, 0, 0);
- wresize(p_frame->p_win, lines, (vec_size(Screen_List) > 0) ? cols/2 : cols);
+ wresize(p_frame->p_win, lines, (num_frames > 1) ? cols/2 : cols);
wclear(p_frame->p_win);
+ screen_frame_draw_files(p_frame);
box(p_frame->p_win, 0 , 0);
wrefresh(p_frame->p_win);
mvwin(p_frame->p_win, pos, cols/2);
wresize(p_frame->p_win, height, cols/2);
wclear(p_frame->p_win);
+ screen_frame_draw_files(p_frame);
wmove(p_frame->p_win, 1, 1);
- wprintw(p_frame->p_win, "(%d, %d)", i*height, cols/2);
box(p_frame->p_win, 0 , 0);
wrefresh(p_frame->p_win);
+ /* Get the next one */
+ id++;
pos += height;
+ p_node = p_node->next;
}
}
#ifndef WORKDIR_H
#define WORKDIR_H
- void workdir_init(int windex);
+ #include "vec.h"
- void workdir_prev(void);
+void workdir_deinit(void);
+
+ typedef struct {
+ int idx;
+ char* path;
+ vec_t* vfiles;
+ int top_index;
+ } WorkDir_T;
- void workdir_next(void);
+ WorkDir_T* workdir_new(char* path);
- void workdir_cd(void);
+ void workdir_prev(WorkDir_T*);
- void workdir_ls(void);
+ void workdir_next(WorkDir_T*);
+
+ void workdir_cd(WorkDir_T*);
+
+ void workdir_ls(WorkDir_T*);
#endif /* WORKDIR_H */