path: root/src/calcurse.h
diff options
authorLars Henriksen <LarsHenriksen@get2net.dk>2018-12-17 10:42:13 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2019-05-22 01:56:59 -0400
commit066df02cbf44d58a9b1e3a30b1310dc0f460e4c4 (patch)
tree6b873c9ceccada341913096186c7c165f46c9ea7 /src/calcurse.h
parent8dd694b56956a1c4ec3519743904222b465e10a5 (diff)
Introduce multiple days in the appointments panel
Overview of existing implementation ----------------------------------- The APP panel displays the 'day_items' vector in the 'lb_apt' listbox. A listbox consists of a scrollwin (structure) in which a number of items is displayed. The listbox keeps track of: - the number of items - the selected item - the type of each item in an array type[] - the height of each item (ie. how many screen lines) in an array ch[] - how to display an item (on the screen) The latter three are handled by functions fn_type(), fn_height(), fn_draw(). The first two are used to fill in the corresponding array entry, type[] or ch[], for item number i, the third draws item number i. The items are taken from the global variables vector_t day_items int day_items_nb in day.c. Items include captions (DAY_HEADING, DAY_SEPARATOR). Everything is sorted for display (DAY_HEADING, events, DAY_SEPARATOR, appts). These are filled in ("stored") [by day_store_items() for the selected day in the calendar], before being "loaded" into the listbox. See do_storage() in calcurse.c and ui_day_item_add() in ui-day.c. New APP panel design -------------------- Several days are displayed in the APP panel by loading them with day_store_items(). With several days come several headings and separators. DAY_SEPARATOR is reinterpreted to separate days, and a new separator, EVNT_SEPARATOR, separates events from appointments. To sort everything, an 'order' member of type time_t is added to the day_item structure. It is set for headings and separators as well as for appointments and events as follows: item order --------------------- DAY_HEADING BGNOFDAY (= midnight) EVNT_SEPARATOR BGNOFDAY DAY_SEPARATOR ENDOFDAY event start time (midnight) appointment start time (first day) BGNOFDAY (following days, if any) The sort function day_cmp() (used by vector_sort) is extended to sort by order first. The order field always indicates the day to which an item belongs. This comes in handy, because with several days in the APP panel it is necessary to distinguish between the selected day in the calendar and the selected day in the APP panel. This raises the question which day should actions (commands) operate on: the one selected in the calendar or the one selected in the APP panel? Unquestionably the one on the APP panel which is the one tacitly implied. In most cases it is not a problem, though, because actions work on the selected item and the selected day does not come into play. But in some cases it does: delete item When deleting an occurrence of a repeated item, the selected day is the exception day to add. view item day_popup_item() needs the day of the selected item for display of correct start/end times. cut/paste item Paste needs the selected day in which to paste. add item The day of the new item is taken from the calendar. Instead a dummy event is inserted in an empty day. This makes the day selectable, which is otherwise impossible with only the DAY_HEADING displayed. The dummy event is selectable but cannot be edited or deleted (but viewed or piped). With more than one day in the day_items vecter, an appointment spanning more than one day may occur more than once in the vector (with start/end times suitably adjusted for display). A day_item is no longer (always) identified by the aptev_ptr (item) value. Instead the combination (order, item.<ptr>) is used; order is roughly the day. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/calcurse.h')
1 files changed, 10 insertions, 3 deletions
diff --git a/src/calcurse.h b/src/calcurse.h
index 6d6f205..3ee0900 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -172,6 +172,7 @@
#define NOHILT 0 /* 'No highlight' argument */
#define NOFORCE 0
#define FORCE 1
+#define DUMMY -1 /* The dummy event */
#define ERROR_MSG(...) do { \
char msg[BUFSIZ]; \
@@ -417,9 +418,10 @@ enum day_item_type {
/* Available item types. */
@@ -460,6 +462,7 @@ struct item_filter {
struct day_item {
enum day_item_type type;
time_t start;
+ time_t order;
union aptev_ptr item;
@@ -797,6 +800,7 @@ void custom_keys_config(void);
void custom_config_main(void);
/* day.c */
+int day_get_nb(void);
void day_free_vector(void);
char *day_item_get_mesg(struct day_item *);
char *day_item_get_note(struct day_item *);
@@ -805,7 +809,7 @@ long day_item_get_duration(struct day_item *);
int day_item_get_state(struct day_item *);
void day_item_add_exc(struct day_item *, time_t);
void day_item_fork(struct day_item *, struct day_item *);
-void day_store_items(time_t, int);
+void day_store_items(time_t, int, int);
void day_display_item_date(struct day_item *, WINDOW *, int, time_t, int, int);
void day_display_item(struct day_item *, WINDOW *, int, int, int, int);
void day_write_stdout(time_t, const char *, const char *, const char *,
@@ -829,6 +833,7 @@ void dmon_stop(void);
/* event.c */
extern llist_t eventlist;
+extern struct event dummy;
void event_free_bkp(void);
struct event *event_dup(struct event *);
void event_free(struct event *);
@@ -842,6 +847,7 @@ void event_write(struct event *, FILE *);
struct event *event_scan(FILE *, struct tm, int, char *, struct item_filter *);
void event_delete(struct event *);
void event_paste_item(struct event *, time_t);
+int event_dummy(struct day_item *);
/* getstring.c */
enum getstr getstring(WINDOW *, char *, int, int, int);
@@ -1092,6 +1098,7 @@ void todo_free_list(void);
/* ui-day.c */
struct day_item *ui_day_selitem(void);
+time_t ui_day_selday(void);
void ui_day_set_selitem_by_aptev_ptr(union aptev_ptr);
void ui_day_set_selitem(struct day_item *);
void ui_day_item_add(void);