+
+#ifndef __MENU_H__
+#define __MENU_H__
+
/* ncurses doesn't support multiline menu items,
* so i wrote my own menu lib */
typedef struct Menu Menu;
typedef struct MenuItem MenuItem;
-extern Menu* create_menu(MenuItem* item_list);
-extern int set_menu_items(Menu* menu, MenuItem* item_list);
+extern Menu* create_menu(MenuItem** item_list);
+extern int set_menu_items(Menu* menu, MenuItem** item_list);
extern MenuItem* get_menu_items(Menu* menu);
+
+#endif
+#ifndef __PARSER_H__
+#define __PARSER_H__
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern void log_todo(Board* board);
+#endif
+#ifndef __RENDER_H__
+#define __RENDER_H__
+
#include <ncurses.h>
enum TaskasaurColors {
extern int init_tscurses(void);
extern int exit_tscurses(void);
+#endif
--- /dev/null
+
+#ifndef __UTILS_H__
+#define __UTILS_H__
+
+#define \
+array_length(type, array) \
+({ \
+ type* m_arr; \
+ int m_len; \
+ \
+ m_arr = (type*)array; \
+ m_len = 0; \
+ \
+ while (m_arr[m_len] != 0) { \
+ m_len += 1; \
+ } \
+ \
+ m_len; \
+})
+
+#endif
make: taskasaur
+all: taskasaur
+
parser.o: parser.c headers/parser.h
$(CC) -c parser.c
menu.o: menu.c headers/menu.h
$(CC) -c menu.c
-taskasaur: taskasaur.c parser.o render.o menu.o
+utils.o: utils.c headers/utils.h
+ $(CC) -c utils.c
+
+taskasaur: taskasaur.c parser.o render.o menu.o utils.o
$(CC) -o $@ $^ -lncurses -lmd4c
clean:
+#include <stdlib.h>
#include <stddef.h>
+#include <ncurses.h>
#include "headers/menu.h"
+#include "headers/utils.h"
typedef struct MenuItem {
char* contents;
} MenuItem;
typedef struct Menu {
- MenuItem* menu_items;
+ MenuItem** menu_items;
int menu_length;
int selected_item;
+ WINDOW* menu_win;
} Menu;
+int render_menu(Menu* menu);
Menu*
-create_menu(MenuItem* item_list)
+create_menu(MenuItem** item_list)
{
+ Menu *new_menu;
+
+ new_menu = malloc(sizeof(Menu));
+ new_menu->menu_items = item_list;
+ new_menu->menu_length = array_length(MenuItem*, item_list);
+ new_menu->selected_item = 0;
+ WINDOW* menu_win = NULL;
+
return NULL;
}
int
-set_menu_items(Menu* menu, MenuItem* item_list)
+set_menu_items(Menu* menu, MenuItem** item_list)
{
return 0;
}
{
return NULL;
}
+
+int
+render_menu(Menu* menu)
+{
+
+ for (int i = 0; i < menu->menu_length; i++) {
+
+ /* color selected item */
+
+ }
+
+ return 0;
+}
+
+
#include "headers/parser.h"
#include "headers/render.h"
+#include "headers/menu.h"
+#include "headers/utils.h"
int
main(int argc, char** argv)
getch();
exit_tscurses();
+
return 0;
}
--- /dev/null
+
+#include "headers/utils.h"
+
+