WINDOW *win;
} view_t;
+/* Macros */
+#define VIEW(name) \
+ void name##_init(WINDOW *win); \
+ void name##_size(int,int); \
+ void name##_draw(void); \
+ int name##_run(int,mmask_t,int,int)
+
+/* Prototypes */
+VIEW(day);
+VIEW(week);
+VIEW(month);
+VIEW(year);
+VIEW(events);
+VIEW(todo);
+VIEW(settings);
+VIEW(help);
+
/* View data */
view_t views[] = {
{ "Day", day_init, day_size, day_draw, day_run, {KEY_F(1), '1', } },
static int get_color(const char *cat)
{
return cat == NULL ? 0 :
- !strcmp(cat, "class") ? COLOR_CLASS :
- !strcmp(cat, "ec") ? COLOR_EC :
- !strcmp(cat, "work") ? COLOR_WORK : COLOR_OTHER ;
+ match(cat, "class") ? COLOR_CLASS :
+ match(cat, "ec") ? COLOR_EC :
+ match(cat, "work") ? COLOR_WORK : COLOR_OTHER ;
}
/* Helper functions */
mvwprintw(win, y, x, "%s", desc);
}
+/* Curses functions */
+void wmvresize(WINDOW *win, int top, int left, int rows, int cols)
+{
+ int y = getpary(win);
+ if (top < y)
+ mvderwin(win, top, left);
+ wresize(win, rows, cols);
+ if (top > y)
+ mvderwin(win, top, left);
+}
+
+void wshrink(WINDOW *win, int top)
+{
+ int x = getparx(win);
+ int y = getpary(win);
+ int r = getmaxy(win);
+ int c = getmaxx(win);
+ int rows = r + (y - top);
+ if (top < y) mvderwin(win, top, x);
+ if (rows != r) wresize(win, rows, c);
+ if (top > y) mvderwin(win, top, x);
+}
+
/* View init */
void view_init(void)
{
views[i].win = newwin(LINES-hdr, COLS, hdr, 0);
views[i].init(views[i].win);
}
+ if (views[i].size)
+ views[i].size(LINES-hdr, COLS);
}
}