From 4284ca91bc0fd04851a34c67dae1068f3c1defc9 Mon Sep 17 00:00:00 2001 From: Lars Henriksen Date: Sat, 16 Mar 2019 08:27:45 +0100 Subject: Implement scrolling in the appointments panel With multiple days in the APP panel, up/down movements should change behaviour at the top and bottom of the list displayed, and load the previous/next lot of days. This requires that the move function returns the result of the operation. Furthermore, the ability to move the selection to the beginning of a day is needed when moving down (in order to move from the first day to the last day). For this reason a DAY_SEPARATOR has been inserted also after the last day of a lot. Appointments have a listbox height of three to separate them clearly when there is more than one in a day. This leaves a spurious empty line at the end of a day with appointments. The DAY_SEPARATOR height is reduced from two to one, and a new EMPTY_SEPARATOR of height one is inserted in any day with only events. When scrolling up the DAY_HEADING becomes visible when the selection reaches the first item of the day. The length of the separator (between events and appointments) is adjusted to leave a space to the window border at both ends, thereby making it a part of the day, not a separation between days. The dummy event must also be recognisable when not the selected item and is only inserted in interactive mode. The test for a saved selection must also recognise caption items which have item pointer NULL. The function day_get_nb() has been renamed day_get_days(). Signed-off-by: Lars Henriksen Signed-off-by: Lukas Fleischer --- src/calcurse.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/calcurse.c') diff --git a/src/calcurse.c b/src/calcurse.c index b99f210..6313818 100644 --- a/src/calcurse.c +++ b/src/calcurse.c @@ -60,7 +60,7 @@ static void do_storage(int day_changed) ui_day_sel_reset(); /* The day_items vector. */ - day_store_items(get_slctd_day(), 1, day_get_nb()); + day_store_items(get_slctd_day(), 1, day_get_days()); /* The APP listbox. */ ui_day_load_items(); @@ -414,7 +414,12 @@ static inline void key_move_up(void) if (wins_slctd() == CAL) { key_generic_prev_week(); } else if (wins_slctd() == APP) { - ui_day_sel_move(-1); + if (!ui_day_sel_move(-1)) { + ui_calendar_move(DAY_PREV, 1); + do_storage(1); + ui_day_sel_dayend(); + wins_update(FLAG_CAL); + } wins_update(FLAG_APP); } else if (wins_slctd() == TOD) { ui_todo_sel_move(-1); @@ -434,7 +439,12 @@ static inline void key_move_down(void) if (wins_slctd() == CAL) { key_generic_next_week(); } else if (wins_slctd() == APP) { - ui_day_sel_move(1); + if (!ui_day_sel_move(1)) { + ui_calendar_move(DAY_NEXT, 1); + do_storage(1); + ui_day_sel_daybegin(day_get_days() - 1); + wins_update(FLAG_CAL); + } wins_update(FLAG_APP); } else if (wins_slctd() == TOD) { ui_todo_sel_move(1); -- cgit v1.2.3-54-g00ecf