aboutsummaryrefslogtreecommitdiffstats
path: root/src/calcurse.c
diff options
context:
space:
mode:
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.c
parent8dd694b56956a1c4ec3519743904222b465e10a5 (diff)
downloadcalcurse-066df02cbf44d58a9b1e3a30b1310dc0f460e4c4.tar.gz
calcurse-066df02cbf44d58a9b1e3a30b1310dc0f460e4c4.zip
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.c')
-rw-r--r--src/calcurse.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/calcurse.c b/src/calcurse.c
index d470661..757b3cd 100644
--- a/src/calcurse.c
+++ b/src/calcurse.c
@@ -54,7 +54,7 @@ static void do_storage(int day_changed)
if (day)
item = day->item;
- day_store_items(get_slctd_day(), 1);
+ day_store_items(get_slctd_day(), 1, day_get_nb());
ui_day_load_items();
if (day_changed)
@@ -143,7 +143,7 @@ static inline void key_add_item(void)
static inline void key_edit_item(void)
{
- if (wins_slctd() == APP) {
+ if (wins_slctd() == APP && !event_dummy(ui_day_selitem())) {
ui_day_item_edit();
do_storage(0);
wins_update(FLAG_CAL | FLAG_APP | FLAG_STA);
@@ -155,7 +155,7 @@ static inline void key_edit_item(void)
static inline void key_del_item(void)
{
- if (wins_slctd() == APP) {
+ if (wins_slctd() == APP && !event_dummy(ui_day_selitem())) {
ui_day_item_delete(reg);
do_storage(0);
wins_update(FLAG_CAL | FLAG_APP | FLAG_STA);
@@ -167,7 +167,7 @@ static inline void key_del_item(void)
static inline void key_generic_copy(void)
{
- if (wins_slctd() == APP) {
+ if (wins_slctd() == APP && !event_dummy(ui_day_selitem())) {
ui_day_item_copy(reg);
do_storage(0);
wins_update(FLAG_CAL | FLAG_APP);
@@ -185,7 +185,7 @@ static inline void key_generic_paste(void)
static inline void key_repeat_item(void)
{
- if (wins_slctd() == APP)
+ if (wins_slctd() == APP && !event_dummy(ui_day_selitem()))
ui_day_item_repeat();
do_storage(0);
wins_update(FLAG_CAL | FLAG_APP | FLAG_STA);
@@ -193,7 +193,7 @@ static inline void key_repeat_item(void)
static inline void key_flag_item(void)
{
- if (wins_slctd() == APP) {
+ if (wins_slctd() == APP && !event_dummy(ui_day_selitem())) {
ui_day_flag();
do_storage(0);
wins_update(FLAG_APP);
@@ -232,7 +232,7 @@ static inline void key_lower_priority(void)
static inline void key_edit_note(void)
{
- if (wins_slctd() == APP) {
+ if (wins_slctd() == APP && !event_dummy(ui_day_selitem())) {
ui_day_edit_note();
do_storage(0);
} else if (wins_slctd() == TOD) {