#include "util.h"
#include "date.h"
-#include "event.h"
+#include "cal.h"
/* Test data */
static cal_t cal = {
static event_t events[8];
/* Event functions */
-event_t *dummy_get(cal_t *cal, year_t year, month_t month, day_t day, int days)
+event_t *dummy_events(cal_t *cal, year_t year, month_t month, day_t day, int days)
{
for (int i = 0; i < N_ELEMENTS(events); i++) {
date_t *s = &events[i].start;
#include "util.h"
#include "date.h"
-#include "event.h"
+#include "cal.h"
/* Local types */
typedef struct {
}
/* Event functions */
-event_t *ical_get(cal_t *cal, year_t year, month_t month, day_t day, int days)
+event_t *ical_events(cal_t *cal, year_t year, month_t month, day_t day, int days)
{
/* Load ical */
FILE *file = fopen("data/all.ics", "r");
# Sources
PROG = lackey
-PROG_SRC = main screen date event util
+PROG_SRC = main view date cal util
TEST = test
TEST_SRC = test date util
VIEWS = day week month year events todo settings help
./$<
clean:
- rm -f src/*.o view/*.o cal/*.o $(PROG) $(TEST)
+ rm -f src/*.o views/*.o cals/*.o $(PROG) $(TEST)
# Rules
-$(PROG): $(PROG_SRC:%=src/%.o) $(VIEWS:%=view/%.o) $(CALS:%=cal/%.o)
+$(PROG): $(PROG_SRC:%=src/%.o) $(VIEWS:%=views/%.o) $(CALS:%=cals/%.o)
$(CC) $(CFLAGS) -o $@ $+ $(LDFLAGS)
-$(TEST): $(TEST_SRC:%=src/%.o) $(CALS:%=cal/%.o)
+$(TEST): $(TEST_SRC:%=src/%.o) $(CALS:%=cals/%.o)
$(CC) $(CFLAGS) -o $@ $+ $(LDFLAGS)
%.o: %.c $(wildcard src/*.h) makefile
#include "util.h"
#include "date.h"
-#include "event.h"
+#include "cal.h"
/* Global data */
event_t *EVENTS;
/* Initialize */
-void event_init(void)
+void cal_init(void)
{
- EVENTS = event_get(2012, JAN, 0, 366);
+ EVENTS = cal_events(2012, JAN, 0, 366);
/* Debug */
for (event_t *e = EVENTS; e; e = e->next)
e->start.hour, e->start.min, e->name, e->desc);
}
-/* Event get */
-event_t *event_get(year_t year, month_t month, day_t day, int days)
+/* Get events */
+event_t *cal_events(year_t year, month_t month, day_t day, int days)
{
- return ical_get(0, year, month, day, days)
- ?: dummy_get(0, year, month, day, days);
+ return ical_events(0, year, month, day, days)
+ ?: dummy_events(0, year, month, day, days);
}
void *data;
} cal_t;
-/* Event types */
+/* Calendar items */
typedef struct event_t {
const cal_t *cal;
const char *name;
/* Global data */
extern event_t *EVENTS;
-/* Event functions */
-void event_init(void);
-event_t *event_get(year_t year, month_t month, day_t day, int days);
+/* Calendar functions */
+void cal_init(void);
+event_t *cal_events(year_t year, month_t month, day_t day, int days);
-/* Calendar implementation functions */
-event_t *dummy_get(cal_t *cal, year_t year, month_t month, day_t day, int days);
-event_t *ical_get(cal_t *cal, year_t year, month_t month, day_t day, int days);
+/* Calendar event functions */
+event_t *dummy_events(cal_t *cal, year_t year, month_t month, day_t day, int days);
+event_t *ical_events(cal_t *cal, year_t year, month_t month, day_t day, int days);
/* Test fuctions */
void ical_test(void);
#include "util.h"
#include "date.h"
-#include "event.h"
-#include "screen.h"
+#include "cal.h"
+#include "view.h"
/* Control-C handler, so we don't hose the therminal */
static void on_sigint(int signum)
/* Initialize */
util_init();
date_init();
- event_init();
- screen_init();
+ cal_init();
+ view_init();
- /* Draw initial screen */
- screen_draw();
+ /* Draw initial view */
+ view_draw();
/* Run */
while (1) {
case KEY_RESIZE:
endwin();
refresh();
- screen_resize();
- screen_draw();
+ view_resize();
+ view_draw();
continue;
case '\14':
clear();
case '\7':
- screen_draw();
+ view_draw();
continue;
}
- if (screen_run(chr, btn.bstate, btn.y, btn.x))
+ if (view_run(chr, btn.bstate, btn.y, btn.x))
continue;
debug("main: Unhandled key - Dec %3d, Hex %02x, Oct %03o, Chr <%c>\n",
chr, chr, chr, chr);
*/
#include "date.h"
-#include "event.h"
+#include "cal.h"
int main(int argc, char **argv)
{
#include <ncurses.h>
#include "date.h"
-#include "event.h"
-#include "screen.h"
+#include "cal.h"
+#include "view.h"
/* Static data */
static FILE *debug_fd = NULL;
#include "util.h"
#include "date.h"
-#include "event.h"
-#include "screen.h"
+#include "cal.h"
+#include "view.h"
/* Types */
typedef struct {
}
-/* Screen init */
-void screen_init(void)
+/* View init */
+void view_init(void)
{
for (int i = 0; i < N_ELEMENTS(views); i++) {
if (views[i].init) {
}
}
-/* Screen draw */
-void screen_resize(void)
+/* View draw */
+void view_resize(void)
{
for (int i = 0; i < N_ELEMENTS(views); i++) {
if (views[i].win)
}
}
-/* Screen draw */
-void screen_draw(void)
+/* View draw */
+void view_draw(void)
{
draw_header();
werase(views[active].win);
wrefresh(views[active].win);
}
-/* Screen set */
-int screen_set(int num)
+/* View set */
+int view_set(int num)
{
if (active != num) {
active = num;
- screen_draw();
+ view_draw();
}
return 1;
}
-/* Screen run */
-int screen_run(int key, mmask_t btn, int row, int col)
+/* View run */
+int view_run(int key, mmask_t btn, int row, int col)
{
/* Check for mouse events */
if (key == KEY_MOUSE && row == 0) {
for (int i = 0; i < N_ELEMENTS(views); i++) {
int end = start + strlen(views[i].name) - 1;
if (start <= col && col <= end && views[i].draw)
- return screen_set(i);
+ return view_set(i);
start = end + 2;
}
}
continue;
for (int j = 0; j < N_ELEMENTS(views[i].keys); j++)
if (views[i].keys[j] == key)
- return screen_set(i);
+ return view_set(i);
}
/* Shift windows */
num += N_ELEMENTS(views);
num %= N_ELEMENTS(views);
if (views[num].run)
- return screen_set(num);
+ return view_set(num);
}
/* Pass key to active view */
void event_box(WINDOW *win, event_t *event, int y, int x, int h, int w);
void event_line(WINDOW *win, event_t *event, int y, int x, int w, int full);
-/* Screen functions */
-void screen_init(void);
-void screen_resize(void);
-void screen_draw(void);
-int screen_run(int key, mmask_t btn, int row, int col);
+/* View functions */
+void view_init(void);
+void view_resize(void);
+void view_draw(void);
+int view_run(int key, mmask_t btn, int row, int col);
/* View init functions */
void day_init(WINDOW *win);
#include "util.h"
#include "date.h"
-#include "event.h"
-#include "screen.h"
+#include "cal.h"
+#include "view.h"
/* Static data */
static int line;
#include <util.h>
#include <date.h>
-#include <event.h>
-#include <screen.h>
+#include <cal.h>
+#include <view.h>
/* Static data */
static WINDOW *win;
#include "util.h"
#include "date.h"
-#include "event.h"
-#include "screen.h"
+#include "cal.h"
+#include "view.h"
/* Static data */
static WINDOW *win;
#include "util.h"
#include "date.h"
-#include "event.h"
-#include "screen.h"
+#include "cal.h"
+#include "view.h"
/* Static data */
static int line;
#include "util.h"
#include "date.h"
-#include "event.h"
-#include "screen.h"
+#include "cal.h"
+#include "view.h"
/* Constants */
#define MW (2*7+6)