From: Andy Spencer Date: Sun, 21 Oct 2012 07:20:43 +0000 (+0000) Subject: Rename stuff X-Git-Url: http://pileus.org/git/?p=lackey;a=commitdiff_plain;h=9d6df8f874cef59df16086c71031db2ba0267d3a Rename stuff --- diff --git a/cal/dummy.c b/cals/dummy.c similarity index 93% rename from cal/dummy.c rename to cals/dummy.c index fb87063..62e1dd3 100644 --- a/cal/dummy.c +++ b/cals/dummy.c @@ -19,7 +19,7 @@ #include "util.h" #include "date.h" -#include "event.h" +#include "cal.h" /* Test data */ static cal_t cal = { @@ -40,7 +40,7 @@ static event_t event = { 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; diff --git a/cal/ical.c b/cals/ical.c similarity index 98% rename from cal/ical.c rename to cals/ical.c index 817da8d..b39f901 100644 --- a/cal/ical.c +++ b/cals/ical.c @@ -21,7 +21,7 @@ #include "util.h" #include "date.h" -#include "event.h" +#include "cal.h" /* Local types */ typedef struct { @@ -139,7 +139,7 @@ static void add_events(icalarray *array, icalcomponent *comp, } /* 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"); diff --git a/makefile b/makefile index e3f3638..be2232c 100644 --- a/makefile +++ b/makefile @@ -8,7 +8,7 @@ LDFLAGS ?= -lncursesw -lical # 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 @@ -25,13 +25,13 @@ run-$(TEST): $(TEST) ./$< 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 diff --git a/src/event.c b/src/cal.c similarity index 79% rename from src/event.c rename to src/cal.c index df37549..800a7f8 100644 --- a/src/event.c +++ b/src/cal.c @@ -17,15 +17,15 @@ #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) @@ -34,9 +34,9 @@ void event_init(void) 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); } diff --git a/src/event.h b/src/cal.h similarity index 76% rename from src/event.h rename to src/cal.h index 5af341f..3191733 100644 --- a/src/event.h +++ b/src/cal.h @@ -22,7 +22,7 @@ typedef struct { void *data; } cal_t; -/* Event types */ +/* Calendar items */ typedef struct event_t { const cal_t *cal; const char *name; @@ -37,13 +37,13 @@ typedef struct event_t { /* 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); diff --git a/src/main.c b/src/main.c index 75fb53c..e02cda0 100644 --- a/src/main.c +++ b/src/main.c @@ -22,8 +22,8 @@ #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) @@ -60,11 +60,11 @@ int main(int argc, char **argv) /* 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) { @@ -81,16 +81,16 @@ int main(int argc, char **argv) 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); diff --git a/src/test.c b/src/test.c index 53822f9..8d6c9af 100644 --- a/src/test.c +++ b/src/test.c @@ -16,7 +16,7 @@ */ #include "date.h" -#include "event.h" +#include "cal.h" int main(int argc, char **argv) { diff --git a/src/util.c b/src/util.c index 86bc373..24a8f37 100644 --- a/src/util.c +++ b/src/util.c @@ -22,8 +22,8 @@ #include #include "date.h" -#include "event.h" -#include "screen.h" +#include "cal.h" +#include "view.h" /* Static data */ static FILE *debug_fd = NULL; diff --git a/src/screen.c b/src/view.c similarity index 93% rename from src/screen.c rename to src/view.c index c555e32..d91dae9 100644 --- a/src/screen.c +++ b/src/view.c @@ -22,8 +22,8 @@ #include "util.h" #include "date.h" -#include "event.h" -#include "screen.h" +#include "cal.h" +#include "view.h" /* Types */ typedef struct { @@ -125,8 +125,8 @@ void event_line(WINDOW *win, event_t *event, int y, int x, int w, int full) } -/* 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) { @@ -136,8 +136,8 @@ void screen_init(void) } } -/* 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) @@ -147,8 +147,8 @@ void screen_resize(void) } } -/* Screen draw */ -void screen_draw(void) +/* View draw */ +void view_draw(void) { draw_header(); werase(views[active].win); @@ -156,18 +156,18 @@ void screen_draw(void) 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) { @@ -175,7 +175,7 @@ int screen_run(int key, mmask_t btn, int row, int col) 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; } } @@ -186,7 +186,7 @@ int screen_run(int key, mmask_t btn, int row, int col) 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 */ @@ -198,7 +198,7 @@ int screen_run(int key, mmask_t btn, int row, int col) 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 */ diff --git a/src/screen.h b/src/view.h similarity index 93% rename from src/screen.h rename to src/view.h index 9f9d4e9..f263353 100644 --- a/src/screen.h +++ b/src/view.h @@ -28,11 +28,11 @@ 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); diff --git a/view/day.c b/views/day.c similarity index 99% rename from view/day.c rename to views/day.c index 4ddc1d3..4c21c67 100644 --- a/view/day.c +++ b/views/day.c @@ -22,8 +22,8 @@ #include "util.h" #include "date.h" -#include "event.h" -#include "screen.h" +#include "cal.h" +#include "view.h" /* Static data */ static int line; diff --git a/view/events.c b/views/events.c similarity index 98% rename from view/events.c rename to views/events.c index 8b888cd..1a8f8b9 100644 --- a/view/events.c +++ b/views/events.c @@ -21,8 +21,8 @@ #include #include -#include -#include +#include +#include /* Static data */ static WINDOW *win; diff --git a/view/help.c b/views/help.c similarity index 100% rename from view/help.c rename to views/help.c diff --git a/view/mkview.sh b/views/mkview.sh similarity index 100% rename from view/mkview.sh rename to views/mkview.sh diff --git a/view/month.c b/views/month.c similarity index 99% rename from view/month.c rename to views/month.c index fb1ec8c..c40324f 100644 --- a/view/month.c +++ b/views/month.c @@ -22,8 +22,8 @@ #include "util.h" #include "date.h" -#include "event.h" -#include "screen.h" +#include "cal.h" +#include "view.h" /* Static data */ static WINDOW *win; diff --git a/view/settings.c b/views/settings.c similarity index 100% rename from view/settings.c rename to views/settings.c diff --git a/view/todo.c b/views/todo.c similarity index 100% rename from view/todo.c rename to views/todo.c diff --git a/view/week.c b/views/week.c similarity index 99% rename from view/week.c rename to views/week.c index e9d7c04..a38ad94 100644 --- a/view/week.c +++ b/views/week.c @@ -22,8 +22,8 @@ #include "util.h" #include "date.h" -#include "event.h" -#include "screen.h" +#include "cal.h" +#include "view.h" /* Static data */ static int line; diff --git a/view/year.c b/views/year.c similarity index 98% rename from view/year.c rename to views/year.c index 086c0e8..5aecc42 100644 --- a/view/year.c +++ b/views/year.c @@ -20,8 +20,8 @@ #include "util.h" #include "date.h" -#include "event.h" -#include "screen.h" +#include "cal.h" +#include "view.h" /* Constants */ #define MW (2*7+6)