+#ifndef __CONFIG_H__
+#define __CONFIG_H__
+
+#include <ncurses.h>
+
static char font[] = "Source Code Pro:size=12";
#define BINDING_JUMP_BOTTOM 'G'
#define BINDING_SELECT '\n'
+#endif
utils.o: utils.c headers/utils.h
$(CC) -c utils.c
+# include config.h as depend
+
taskasaur: taskasaur.c parser.o render.o menu.o utils.o
$(CC) -o $@ $^ -lncurses -lmd4c
#include <ncurses.h>
#include "headers/menu.h"
+#include "headers/render.h"
#include "headers/utils.h"
typedef struct MenuItem {
cur_line = 0;
for (int i = 0; i < menu->menu_length; i++) {
+
+ int wrapped_lines;
+ char* wrapped_text;
+ int text_color;
/* wrap text by inserting newlines */
- mvwprintw(menu->menu_win, cur_line, 0, menu->menu_items[i]->contents);
+ wrapped_text = wrap_text(menu->menu_items[i]->contents, menu->max_width, &wrapped_lines);
/* color selected item */
+ text_color = (i == menu->selected_item) ? TS_SELECTED : TS_NONSELECTED;
+
+ wattron(menu->menu_win, COLOR_PAIR(text_color));
+ mvwprintw(menu->menu_win, cur_line, 0, wrapped_text);
+ wattroff(menu->menu_win, COLOR_PAIR(text_color));
+
+ cur_line += wrapped_lines;
- cur_line += 1;
+ free(wrapped_text);
}
MenuItem** item_list = malloc(4*sizeof(MenuItem*));
for (int i = 0; i < 3; i++) {
- item_list[i] = create_menuitem("lmao");
+ item_list[i] = create_menuitem("Many of you are probably feeling a little sad.");
}
- item_list[3] = 0;
Menu* menu = create_menu(item_list);