From 9f1e1c3ed45b016ab66da3397a78796204e57ed0 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Mon, 17 Jun 2013 05:33:43 +0000 Subject: [PATCH] Common updates to support event and todo editing --- src/cal.c | 6 +++--- src/cal.h | 6 +++--- src/view.c | 20 +++++++++++++++----- src/view.h | 14 +++++++++++++- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/cal.c b/src/cal.c index b519d58..d02e885 100644 --- a/src/cal.c +++ b/src/cal.c @@ -33,9 +33,9 @@ CAL(dummy); CAL(ical); /* Global data */ -cal_t *CALS; -event_t *EVENTS; -todo_t *TODOS; +cal_t *CAL, *CALS; +event_t *EVENT, *EVENTS; +todo_t *TODO, *TODOS; /* Local data */ static date_t start; diff --git a/src/cal.h b/src/cal.h index 72bcd95..13b12d0 100644 --- a/src/cal.h +++ b/src/cal.h @@ -55,9 +55,9 @@ typedef struct todo_t { } todo_t; /* Global data */ -extern cal_t *CALS; -extern event_t *EVENTS; -extern todo_t *TODOS; +extern cal_t *CAL, *CALS; +extern event_t *EVENT, *EVENTS; +extern todo_t *TODO, *TODOS; /* Calendar functions */ void cal_init(void); diff --git a/src/view.c b/src/view.c index 3527849..2e5e78e 100644 --- a/src/view.c +++ b/src/view.c @@ -81,9 +81,12 @@ view_t *menu[] = { &spacer, &settings_view, &help_view }; -/* Global data */ +/* Config data */ int COMPACT = 0; +/* Global data */ +edit_t EDIT = EDIT_NONE; + /* Local data */ view_t *view = &day_view; view_t *active = &day_view; @@ -206,7 +209,7 @@ void event_line(WINDOW *win, event_t *event, int y, int x, int w, int flags) mvwaddch(win, y, x++, ACS_BLOCK); if (color) wattroff(win, COLOR_PAIR(color)); - if (flags & SHOW_ACTIVE) + if (flags & SHOW_ACTIVE && event == EVENT) wattron(win, A_REVERSE | A_BOLD); if (flags & SHOW_DETAILS) { if (all_day(&event->start, &event->end)) @@ -226,7 +229,7 @@ void event_line(WINDOW *win, event_t *event, int y, int x, int w, int flags) if (flags & SHOW_DETAILS && event->loc) { mvwprintw(win, y, x, " @ %s", event->loc); } - if (flags & SHOW_ACTIVE) + if (flags & SHOW_ACTIVE && event == EVENT) wattroff(win, A_REVERSE | A_BOLD); } @@ -250,7 +253,7 @@ void todo_line(WINDOW *win, todo_t *todo, int y, int x, int w, int flags) x += 2; /* Set background */ - if (flags & SHOW_ACTIVE) + if (flags & SHOW_ACTIVE && todo == TODO) wattron(win, A_REVERSE | A_BOLD); mvwhline(win, y, x, ' ', COLS-x); @@ -275,7 +278,7 @@ void todo_line(WINDOW *win, todo_t *todo, int y, int x, int w, int flags) mvwprintw(win, y, x, "%s", desc); /* Reset flags */ - if (flags & SHOW_ACTIVE) + if (flags & SHOW_ACTIVE && todo == TODO) wattroff(win, A_REVERSE | A_BOLD); } @@ -387,3 +390,10 @@ int view_run(int key, mmask_t btn, int row, int col) /* Pass key to active view */ return view->run(key, btn, row, col); } + +/* View event */ +void view_edit(edit_t mode) +{ + EDIT = mode; + set_view(active, &edit_view); +} diff --git a/src/view.h b/src/view.h index 7f967ea..03d7922 100644 --- a/src/view.h +++ b/src/view.h @@ -32,8 +32,19 @@ #define SHOW_DETAILS 0x1 #define SHOW_ACTIVE 0x2 +/* Edit modes */ +typedef enum { + EDIT_NONE, + EDIT_CAL, + EDIT_EVENT, + EDIT_TODO, +} edit_t; + /* Config data */ -extern int COMPACT; +extern int COMPACT; // reduce layout spacing + +/* Global data */ +extern edit_t EDIT; // edit mode 0=cal 1=event 3=todo /* Curses functions */ void wmvresize(WINDOW *win, int top, int left, int rows, int cols); @@ -50,3 +61,4 @@ void view_config(const char *group, const char *name, const char *key, const cha void view_resize(void); void view_draw(void); int view_run(int key, mmask_t btn, int row, int col); +void view_edit(edit_t mode); -- 2.43.2