diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/apoint.c | 2 | ||||
-rw-r--r-- | src/args.c | 4 | ||||
-rw-r--r-- | src/calcurse.c | 97 | ||||
-rw-r--r-- | src/calcurse.h | 4 | ||||
-rw-r--r-- | src/config.c | 2 | ||||
-rw-r--r-- | src/custom.c | 10 | ||||
-rw-r--r-- | src/day.c | 66 | ||||
-rw-r--r-- | src/dmon.c | 4 | ||||
-rw-r--r-- | src/event.c | 2 | ||||
-rw-r--r-- | src/getstring.c | 2 | ||||
-rw-r--r-- | src/help.c | 2 | ||||
-rw-r--r-- | src/hooks.c | 2 | ||||
-rw-r--r-- | src/htable.h | 2 | ||||
-rw-r--r-- | src/ical.c | 24 | ||||
-rw-r--r-- | src/io.c | 2 | ||||
-rw-r--r-- | src/keys.c | 93 | ||||
-rw-r--r-- | src/listbox.c | 2 | ||||
-rw-r--r-- | src/llist.c | 2 | ||||
-rw-r--r-- | src/llist.h | 2 | ||||
-rw-r--r-- | src/llist_ts.h | 2 | ||||
-rw-r--r-- | src/mem.c | 2 | ||||
-rw-r--r-- | src/note.c | 2 | ||||
-rw-r--r-- | src/notify.c | 2 | ||||
-rw-r--r-- | src/pcal.c | 2 | ||||
-rw-r--r-- | src/queue.c | 2 | ||||
-rw-r--r-- | src/recur.c | 36 | ||||
-rw-r--r-- | src/sha1.c | 3 | ||||
-rw-r--r-- | src/sha1.h | 4 | ||||
-rw-r--r-- | src/sigs.c | 2 | ||||
-rw-r--r-- | src/strings.c | 3 | ||||
-rw-r--r-- | src/todo.c | 2 | ||||
-rw-r--r-- | src/ui-calendar.c | 13 | ||||
-rw-r--r-- | src/ui-day.c | 2 | ||||
-rw-r--r-- | src/ui-todo.c | 23 | ||||
-rw-r--r-- | src/utf8.c | 2 | ||||
-rw-r--r-- | src/utils.c | 2 | ||||
-rw-r--r-- | src/vars.c | 4 | ||||
-rw-r--r-- | src/vector.c | 2 | ||||
-rw-r--r-- | src/vector.h | 2 | ||||
-rw-r--r-- | src/wins.c | 2 |
40 files changed, 261 insertions, 177 deletions
diff --git a/src/apoint.c b/src/apoint.c index b4e8f2e..e138e5e 100644 --- a/src/apoint.c +++ b/src/apoint.c @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -112,7 +112,7 @@ static void version_arg(void) { printf(_("calcurse %s -- text-based organizer\n"), VERSION); putchar('\n'); - printf("%s\n", _("Copyright (c) 2004-2020 calcurse Development Team.")); + printf("%s\n", _("Copyright (c) 2004-2023 calcurse Development Team.")); printf("%s\n", _("This is free software; see the source for copying conditions.")); } diff --git a/src/calcurse.c b/src/calcurse.c index 308a332..c89d1dd 100644 --- a/src/calcurse.c +++ b/src/calcurse.c @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,37 +41,6 @@ #define HANDLE_KEY(key, fn) case key: fn(); break; int count, reg; -/* - * Store events and appointments for a range of days in the day vector - - * beginning with the selected day - and load them into the APP listbox. If no - * day-change occurs, reset the selected APP item and with it the selected day, - * thereby storing and loading the same range of days. - */ -static void do_storage(int day_changed) -{ - int pre_sel; - /* - * Save the selected item before rebuilding the day vector - - * unless a preselection is already set. - */ - if (!(pre_sel = day_check_sel_data())) - day_set_sel_data(ui_day_get_sel()); - - if (!day_changed) - ui_day_sel_reset(); - - /* The day_items vector. */ - day_store_items(get_slctd_day(), 1, day_get_days()); - /* The APP listbox. */ - ui_day_load_items(); - - if (day_changed && !pre_sel) - ui_day_sel_reset(); - else - ui_day_find_sel(); - - day_set_sel_data(&empty_day); -} static inline void key_generic_change_view(void) { @@ -98,7 +67,7 @@ static inline void key_generic_goto(void) wins_erase_status_bar(); ui_calendar_set_current_date(); ui_calendar_change_day(conf.input_datefmt); - do_storage(1); + day_do_storage(1); wins_update(FLAG_CAL | FLAG_APP | FLAG_STA); } @@ -107,7 +76,7 @@ static inline void key_generic_goto_today(void) wins_erase_status_bar(); ui_calendar_set_current_date(); ui_calendar_goto_today(); - do_storage(1); + day_do_storage(1); wins_update(FLAG_CAL | FLAG_APP | FLAG_STA); } @@ -125,14 +94,14 @@ static inline void key_generic_config_menu(void) wins_erase_status_bar(); wins_reset_status_page(); custom_config_main(); - do_storage(0); + day_do_storage(0); wins_update(FLAG_ALL); } static inline void key_generic_add_appt(void) { ui_day_item_add(); - do_storage(0); + day_do_storage(0); wins_update(FLAG_CAL | FLAG_APP | FLAG_STA); } @@ -148,7 +117,7 @@ static inline void key_add_item(void) case APP: case CAL: ui_day_item_add(); - do_storage(0); + day_do_storage(0); wins_update(FLAG_CAL | FLAG_APP | FLAG_STA); break; case TOD: @@ -164,7 +133,7 @@ static inline void key_edit_item(void) { if (wins_slctd() == APP && !event_dummy(ui_day_get_sel())) { ui_day_item_edit(); - do_storage(0); + day_do_storage(0); wins_update(FLAG_CAL | FLAG_APP | FLAG_STA); } else if (wins_slctd() == TOD) { ui_todo_edit(); @@ -176,7 +145,7 @@ static inline void key_del_item(void) { if (wins_slctd() == APP && !event_dummy(ui_day_get_sel())) { ui_day_item_delete(reg); - do_storage(0); + day_do_storage(0); wins_update(FLAG_CAL | FLAG_APP | FLAG_STA); } else if (wins_slctd() == TOD) { ui_todo_delete(); @@ -194,7 +163,7 @@ static inline void key_generic_paste(void) { if (wins_slctd() == APP) { ui_day_item_paste(reg); - do_storage(0); + day_do_storage(0); wins_update(FLAG_CAL | FLAG_APP); } } @@ -203,7 +172,7 @@ static inline void key_repeat_item(void) { if (wins_slctd() == APP && !event_dummy(ui_day_get_sel())) { ui_day_item_repeat(); - do_storage(0); + day_do_storage(0); wins_update(FLAG_CAL | FLAG_APP | FLAG_STA); } } @@ -212,7 +181,7 @@ static inline void key_flag_item(void) { if (wins_slctd() == APP && !event_dummy(ui_day_get_sel())) { ui_day_flag(); - do_storage(0); + day_do_storage(0); wins_update(FLAG_APP); } else if (wins_slctd() == TOD) { ui_todo_flag(); @@ -251,7 +220,7 @@ static inline void key_edit_note(void) { if (wins_slctd() == APP && !event_dummy(ui_day_get_sel())) { ui_day_edit_note(); - do_storage(0); + day_do_storage(0); } else if (wins_slctd() == TOD) { ui_todo_edit_note(); } @@ -291,7 +260,7 @@ static inline void key_generic_save(void) if (ret == IO_SAVE_RELOAD) { ui_todo_load_items(); ui_todo_sel_reset(); - do_storage(0); + day_do_storage(0); notify_check_next_app(1); ui_calendar_monthly_view_cache_set_invalid(); } @@ -326,7 +295,7 @@ static inline void key_generic_reload(void) ret == IO_RELOAD_MERGE) { ui_todo_load_items(); ui_todo_sel_reset(); - do_storage(0); + day_do_storage(0); notify_check_next_app(1); ui_calendar_monthly_view_cache_set_invalid(); } @@ -356,7 +325,7 @@ static inline void key_generic_import(void) wins_erase_status_bar(); io_import_data(IO_IMPORT_ICAL, NULL, NULL, NULL, NULL, NULL, NULL); ui_calendar_monthly_view_cache_set_invalid(); - do_storage(0); + day_do_storage(0); ui_todo_load_items(); wins_update(FLAG_ALL); } @@ -381,14 +350,14 @@ static inline void key_generic_export() break; } - do_storage(0); + day_do_storage(0); wins_update(FLAG_ALL); } static inline void key_generic_prev_day(void) { ui_calendar_move(DAY_PREV, count); - do_storage(1); + day_do_storage(1); wins_update(FLAG_CAL | FLAG_APP); } @@ -401,7 +370,7 @@ static inline void key_move_left(void) static inline void key_generic_next_day(void) { ui_calendar_move(DAY_NEXT, count); - do_storage(1); + day_do_storage(1); wins_update(FLAG_CAL | FLAG_APP); } @@ -414,7 +383,7 @@ static inline void key_move_right(void) static inline void key_generic_prev_week(void) { ui_calendar_move(WEEK_PREV, count); - do_storage(1); + day_do_storage(1); wins_update(FLAG_CAL | FLAG_APP); } @@ -425,7 +394,7 @@ static inline void key_move_up(void) } else if (wins_slctd() == APP) { if (!ui_day_sel_move(-1)) { ui_calendar_move(DAY_PREV, 1); - do_storage(1); + day_do_storage(1); ui_day_sel_dayend(); } wins_update(FLAG_APP | FLAG_CAL); @@ -438,7 +407,7 @@ static inline void key_move_up(void) static inline void key_generic_next_week(void) { ui_calendar_move(WEEK_NEXT, count); - do_storage(1); + day_do_storage(1); wins_update(FLAG_CAL | FLAG_APP); } @@ -449,7 +418,7 @@ static inline void key_move_down(void) } else if (wins_slctd() == APP) { if (!ui_day_sel_move(1)) { ui_calendar_move(DAY_PREV, day_get_days() - 2); - do_storage(1); + day_do_storage(1); ui_day_sel_daybegin(day_get_days() - 1); } wins_update(FLAG_APP | FLAG_CAL); @@ -462,28 +431,28 @@ static inline void key_move_down(void) static inline void key_generic_prev_month(void) { ui_calendar_move(MONTH_PREV, count); - do_storage(1); + day_do_storage(1); wins_update(FLAG_CAL | FLAG_APP); } static inline void key_generic_next_month(void) { ui_calendar_move(MONTH_NEXT, count); - do_storage(1); + day_do_storage(1); wins_update(FLAG_CAL | FLAG_APP); } static inline void key_generic_prev_year(void) { ui_calendar_move(YEAR_PREV, count); - do_storage(1); + day_do_storage(1); wins_update(FLAG_CAL | FLAG_APP); } static inline void key_generic_next_year(void) { ui_calendar_move(YEAR_NEXT, count); - do_storage(1); + day_do_storage(1); wins_update(FLAG_CAL | FLAG_APP); } @@ -491,7 +460,7 @@ static inline void key_start_of_week(void) { if (wins_slctd() == CAL) { ui_calendar_move(WEEK_START, count); - do_storage(1); + day_do_storage(1); wins_update(FLAG_CAL | FLAG_APP); } } @@ -500,7 +469,7 @@ static inline void key_end_of_week(void) { if (wins_slctd() == CAL) { ui_calendar_move(WEEK_END, count); - do_storage(1); + day_do_storage(1); wins_update(FLAG_CAL | FLAG_APP); } } @@ -657,7 +626,7 @@ static inline void key_generic_cmd(void) item->order = next; ui_calendar_set_slctd_day(sec2date(next)); day_set_sel_data(item); - do_storage(1); + day_do_storage(1); valid = 1; } @@ -702,7 +671,7 @@ static inline void key_generic_cmd(void) item->order = prev; ui_calendar_set_slctd_day(sec2date(prev)); day_set_sel_data(item); - do_storage(1); + day_do_storage(1); valid = 1; } @@ -812,7 +781,7 @@ int main(int argc, char **argv) */ wins_wrefresh(win[KEY].p); ui_calendar_monthly_view_cache_set_invalid(); - do_storage(1); + day_do_storage(1); ui_todo_load_items(); ui_todo_sel_reset(); wins_update(FLAG_ALL); @@ -832,7 +801,7 @@ int main(int argc, char **argv) que_show(); if (conf.systemevents) { que_save(); - do_storage(0); + day_do_storage(0); } wins_update(FLAG_ALL); que_rem(); @@ -842,7 +811,7 @@ int main(int argc, char **argv) resize = 0; wins_reset(); if (conf.multiple_days) { - do_storage(0); + day_do_storage(0); wins_update(FLAG_APP); } } diff --git a/src/calcurse.h b/src/calcurse.h index db8dd51..8322416 100644 --- a/src/calcurse.h +++ b/src/calcurse.h @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -307,6 +307,7 @@ struct conf { }; #define EMPTY_DAY_DEFAULT "--" +#define EMPTY_EVENT_DESC_DEFAULT _("(empty description)") /* Daemon-related configuration. */ struct dmon_conf { @@ -857,6 +858,7 @@ 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 *, const char *, int *); +void day_do_storage(int day_changed); void day_popup_item(struct day_item *); int day_check_if_item(struct date); unsigned day_chk_busy_slices(struct date, int, int *); diff --git a/src/config.c b/src/config.c index 3627cb8..4e0f7db 100644 --- a/src/config.c +++ b/src/config.c @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/custom.c b/src/custom.c index 744f9f9..2cd385c 100644 --- a/src/custom.c +++ b/src/custom.c @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1242,7 +1242,7 @@ void custom_config_main(void) old_layout = wins_layout(); custom_layout_config(); if (wins_layout() != old_layout) - wins_reset(); + wins_resize(); break; case 'G': case 'g': @@ -1268,7 +1268,11 @@ void custom_config_main(void) resize = 0; wins_reset(); } - + + /* needed to update app list */ + day_do_storage(0); + + /* wins_update(FLAG_ALL), but with custom bindings */ wins_set_bindings(bindings, ARRAY_SIZE(bindings)); wins_update_border(FLAG_ALL); wins_update_panels(FLAG_ALL); @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,7 +58,7 @@ static struct day_item sel_data = { 0, 0, 0, {NULL}}; /* * Save the item to become the selected APP item. - * Public function used to override the setting in do_storage(). + * Public function used to override the setting in day_do_storage(). */ int day_set_sel_data(struct day_item *d) { @@ -198,7 +198,8 @@ static void day_add_item(int type, time_t start, time_t order, union aptev_ptr i /* Get the message of an item. */ char *day_item_get_mesg(struct day_item *day) { - switch (day->type) { + switch (day->type) + { case APPT: return day->item.apt->mesg; case EVNT: @@ -212,6 +213,15 @@ char *day_item_get_mesg(struct day_item *day) } } +/* Get the display message of an item. */ +char *day_item_get_display_mesg(struct day_item *day) +{ + char *msg = day_item_get_mesg(day); + if (msg[0] == '\0') + return EMPTY_EVENT_DESC_DEFAULT; + return msg; +} + /* Get the note attached to an item. */ char *day_item_get_note(struct day_item *day) { @@ -529,7 +539,7 @@ day_display_item(struct day_item *day, WINDOW *win, int incolor, int width, if (width <= 0) return; - char *mesg = day_item_get_mesg(day); + char *mesg = day_item_get_display_mesg(day); ch_recur = (day->type == RECUR_EVNT) ? '*' : ' '; ch_note = day_item_get_note(day) ? '>' : ' '; @@ -578,6 +588,38 @@ void day_write_stdout(time_t date, const char *fmt_apt, const char *fmt_rapt, } } +/* + * Store events and appointments for a range of days in the day vector - + * beginning with the selected day - and load them into the APP listbox. If no + * day-change occurs, reset the selected APP item and with it the selected day, + * thereby storing and loading the same range of days. + */ +void day_do_storage(int day_changed) +{ + int pre_sel; + /* + * Save the selected item before rebuilding the day vector - + * unless a preselection is already set. + */ + if(!(pre_sel = day_check_sel_data())) + day_set_sel_data(ui_day_get_sel()); + + if (!day_changed) + ui_day_sel_reset(); + + /* The day_items vector. */ + day_store_items(get_slctd_day(), 1, day_get_days()); + /* The APP listbox. */ + ui_day_load_items(); + + if (day_changed && !pre_sel) + ui_day_sel_reset(); + else + ui_day_find_sel(); + + day_set_sel_data(&empty_day); +} + /* Display an item inside a popup window. */ void day_popup_item(struct day_item *day) { @@ -592,15 +634,19 @@ void day_popup_item(struct day_item *day) asprintf(¬epath, "%s%s", path_notes, day_item_get_note(day)); fp = fopen(notepath, "r"); + if (fp == NULL) { + item_in_popup(NULL, NULL, day_item_get_mesg(day), _("Event:")); + return; + } note_read_contents(note, note_size, fp); fclose(fp); mem_free(notepath); - asprintf(&msg, "%s\n\n%s\n%s", day_item_get_mesg(day), note_heading, note); + asprintf(&msg, "%s\n\n%s\n%s", day_item_get_display_mesg(day), note_heading, note); item_in_popup(NULL, NULL, msg, _("Event:")); mem_free(msg); } else { - item_in_popup(NULL, NULL, day_item_get_mesg(day), _("Event:")); + item_in_popup(NULL, NULL, day_item_get_display_mesg(day), _("Event:")); } } else if (day->type == APPT || day->type == RECUR_APPT) { char a_st[100], a_end[100]; @@ -619,15 +665,19 @@ void day_popup_item(struct day_item *day) asprintf(¬epath, "%s%s", path_notes, day_item_get_note(day)); fp = fopen(notepath, "r"); + if (fp == NULL) { + item_in_popup(a_st, a_end, day_item_get_mesg(day), _("Appointment:")); + return; + } note_read_contents(note, note_size, fp); fclose(fp); mem_free(notepath); - asprintf(&msg, "%s\n\n%s\n%s", day_item_get_mesg(day), note_heading, note); + asprintf(&msg, "%s\n\n%s\n%s", day_item_get_display_mesg(day), note_heading, note); item_in_popup(a_st, a_end, msg, _("Appointment:")); mem_free(msg); } else { - item_in_popup(a_st, a_end, day_item_get_mesg(day), _("Appointment:")); + item_in_popup(a_st, a_end, day_item_get_display_mesg(day), _("Appointment:")); } } else { EXIT(_("unknown item type")); @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -54,7 +54,7 @@ #define DMON_ABRT(...) do { \ DMON_LOG (__VA_ARGS__); \ - if (kill (getpid (), SIGINT) < 0) \ + if (kill (getpid (), SIGINT) == -1) \ { \ DMON_LOG (_("Could not stop daemon properly: %s\n"), \ strerror (errno)); \ diff --git a/src/event.c b/src/event.c index e0da4c1..7c371e4 100644 --- a/src/event.c +++ b/src/event.c @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/getstring.c b/src/getstring.c index 74c251e..8ea5df5 100644 --- a/src/getstring.c +++ b/src/getstring.c @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/hooks.c b/src/hooks.c index 7bfd548..f649076 100644 --- a/src/hooks.c +++ b/src/hooks.c @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/htable.h b/src/htable.h index 5266213..92be6e2 100644 --- a/src/htable.h +++ b/src/htable.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -214,7 +214,8 @@ static void ical_export_note(FILE *stream, char *name) asprintf(¬e_file, "%s/%s", path_notes, name); if (!(fp = fopen(note_file, "r")) || ungetc(getc(fp), fp) == EOF) { - fclose(fp); + if (fp) + fclose(fp); return; } string_init(¬e); @@ -520,6 +521,10 @@ ical_store_event(char *mesg, char *note, time_t day, time_t end, struct event *ev; struct recur_event *rev; + if (!mesg) + mesg = mem_strdup(_("(empty)")); + EXIT_IF(!mesg, _("ical_store_event: out of memory")); + /* * Repeating event. The end day is ignored, and the event becomes * one-day even if multi-day. @@ -572,6 +577,10 @@ ical_store_apoint(char *mesg, char *note, time_t start, long dur, struct recur_apoint *rapt; time_t day; + if (!mesg) + mesg = mem_strdup(_("(empty)")); + EXIT_IF(!mesg, _("ical_store_event: out of memory")); + if (has_alarm) state |= APOINT_NOTIFY; if (rpt) { @@ -682,7 +691,7 @@ static int ical_readline(FILE * fdi, char *buf, char *lstore, unsigned *ln) while (fgets(lstore, BUFSIZ, fdi) != NULL) { (*ln)++; if ((eol = strchr(lstore, '\n')) != NULL) { - if (*(eol - 1) == '\r') + if (strlen(lstore) > 1 && *(eol - 1) == '\r') *(eol - 1) = '\0'; else *eol = '\0'; @@ -1331,12 +1340,9 @@ static char *ical_read_summary(char *line, unsigned *noskipped, } /* An event summary is one line only. */ - if (strchr(summary, '\n')) { - ical_log(log, item_type, itemline, _("line break in summary.")); - (*noskipped)++; - mem_free(summary); - summary = NULL; - } + for (p = summary; *p; p++) + if (*p == '\n') + *p = ' '; leave: return summary; } @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -162,6 +162,47 @@ static struct keydef_s keydef[NBVKEYS] = { */ static char *keynames[KEY_MAX]; +/* Maps a key code to a custom key name */ +struct custom_keyname_s { + int keycode; + char* keyname; +}; + +#define CUSTOM_KEYS 26 + +/* + * Customized key names with calcurse short forms + */ +static struct custom_keyname_s custom_keynames[CUSTOM_KEYS] = { + { TAB, "TAB" }, + { RETURN, "RET" }, + { ESCAPE, "ESC" }, + { SPACE, "SPC" }, + { KEY_UP, "UP" }, + { KEY_DOWN, "DWN" }, + { KEY_LEFT, "LFT" }, + { KEY_RIGHT, "RGT" }, + { KEY_HOME, "HOM" }, + { KEY_END, "END" }, + { KEY_NPAGE, "PgD" }, + { KEY_PPAGE, "PgU" }, + { KEY_IC, "INS" }, + { KEY_DC, "DEL" }, + { KEY_F(1), "F1" }, + { KEY_F(2), "F2" }, + { KEY_F(3), "F3" }, + { KEY_F(4), "F4" }, + { KEY_F(5), "F5" }, + { KEY_F(6), "F6" }, + { KEY_F(7), "F7" }, + { KEY_F(8), "F8" }, + { KEY_F(9), "F9" }, + { KEY_F(10), "F10" }, + { KEY_F(11), "F11" }, + { KEY_F(12), "F12" }, +}; + + static void dump_intro(FILE * fd) { const char *intro = @@ -175,6 +216,16 @@ static void dump_intro(FILE * fd) fprintf(fd, "%s\n", intro); } +static bool is_customized(int c) { + int i; + + for (i = 0; i < CUSTOM_KEYS; i++) + if (c == custom_keynames[i].keycode) + return true; + + return false; +} + void keys_init(void) { int i; @@ -193,40 +244,20 @@ void keys_init(void) /* Insertion of ncurses names in the ASCII range ... */ for (i = 1; i < 128; i++) - if ((cp = keyname(i))) - keynames[i] = mem_strdup(cp); + if (!is_customized(i)) + if ((cp = keyname(i))) + keynames[i] = mem_strdup(cp); + /* ... and for the ncurses pseudo-characters. */ for (i = KEY_MIN; i < KEY_MAX; i++) - if ((cp = keyname(i))) - keynames[i] = mem_strdup(cp); + if (!is_customized(i)) + if ((cp = keyname(i))) + keynames[i] = mem_strdup(cp); /* Replace some with calcurse short forms. */ - keynames[TAB] = "TAB"; - keynames[RETURN] = "RET"; - keynames[ESCAPE] = "ESC"; - keynames[SPACE] = "SPC"; - keynames[KEY_UP] = "UP"; - keynames[KEY_DOWN] = "DWN"; - keynames[KEY_LEFT] = "LFT"; - keynames[KEY_RIGHT] = "RGT"; - keynames[KEY_HOME] = "HOM"; - keynames[KEY_END] = "END"; - keynames[KEY_NPAGE] = "PgD"; - keynames[KEY_PPAGE] = "PgU"; - keynames[KEY_IC] = "INS"; - keynames[KEY_DC] = "DEL"; - keynames[KEY_F(1)] = "F1"; - keynames[KEY_F(2)] = "F2"; - keynames[KEY_F(3)] = "F3"; - keynames[KEY_F(4)] = "F4"; - keynames[KEY_F(5)] = "F5"; - keynames[KEY_F(6)] = "F6"; - keynames[KEY_F(7)] = "F7"; - keynames[KEY_F(8)] = "F8"; - keynames[KEY_F(9)] = "F9"; - keynames[KEY_F(10)] = "F10"; - keynames[KEY_F(11)] = "F11"; - keynames[KEY_F(12)] = "F12"; + for (i = 0; i < CUSTOM_KEYS; i++) { + keynames[custom_keynames[i].keycode] = custom_keynames[i].keyname; + } } static void key_free(char *s) diff --git a/src/listbox.c b/src/listbox.c index 2b39aa8..d86f540 100644 --- a/src/listbox.c +++ b/src/listbox.c @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/llist.c b/src/llist.c index 04f16a1..d31f004 100644 --- a/src/llist.c +++ b/src/llist.c @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/llist.h b/src/llist.h index 1f7f419..0dd15bf 100644 --- a/src/llist.h +++ b/src/llist.h @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/llist_ts.h b/src/llist_ts.h index 1604d3e..a4b6184 100644 --- a/src/llist_ts.h +++ b/src/llist_ts.h @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/notify.c b/src/notify.c index 3491e8e..6eda361 100644 --- a/src/notify.c +++ b/src/notify.c @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/queue.c b/src/queue.c index a00ebad..41cb69b 100644 --- a/src/queue.c +++ b/src/queue.c @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/recur.c b/src/recur.c index 72cb40f..10523ad 100644 --- a/src/recur.c +++ b/src/recur.c @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -253,8 +253,13 @@ void recur_apoint_free(struct recur_apoint *rapt) mem_free(rapt->mesg); if (rapt->note) mem_free(rapt->note); - if (rapt->rpt) + if (rapt->rpt) { + recur_free_exc_list(&rapt->rpt->exc); + recur_free_int_list(&rapt->rpt->bywday); + recur_free_int_list(&rapt->rpt->bymonth); + recur_free_int_list(&rapt->rpt->bymonthday); mem_free(rapt->rpt); + } recur_free_exc_list(&rapt->exc); mem_free(rapt); } @@ -264,8 +269,13 @@ void recur_event_free(struct recur_event *rev) mem_free(rev->mesg); if (rev->note) mem_free(rev->note); - if (rev->rpt) + if (rev->rpt) { + recur_free_exc_list(&rev->rpt->exc); + recur_free_int_list(&rev->rpt->bywday); + recur_free_int_list(&rev->rpt->bymonth); + recur_free_int_list(&rev->rpt->bymonthday); mem_free(rev->rpt); + } recur_free_exc_list(&rev->exc); mem_free(rev); } @@ -1003,14 +1013,20 @@ static int find_occurrence(time_t start, long dur, struct rpt *rpt, llist_t *exc if (rpt->until && t >= NEXTDAY(rpt->until)) return 0; - /* Does it span the given day? */ - if (t + DUR(t) < day) + /* Does it span the given day? + * + * NOTE: An appointment ending at 00:00 is not considered to span the + * given day, unless the appointment is an appointment without + * specified end time, which is internally treated as appointment with + * duration 0. + */ + if (t + DUR(t) >= day || (t == day && dur == 0)) { + if (occurrence) + *occurrence = t; + return 1; + } else { return 0; - - if (occurrence) - *occurrence = t; - - return 1; + } } #undef DUR @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -43,6 +43,7 @@ #include <stdlib.h> #include <string.h> +#include "config.h" #include "sha1.h" #define rol(val, n) (((val) << (n)) | ((val) >> (32 - (n)))) @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,6 +52,6 @@ typedef struct { void sha1_init(sha1_ctx_t *); void sha1_update(sha1_ctx_t *, const uint8_t *, unsigned int); -void sha1_final(sha1_ctx_t *, uint8_t *); +void sha1_final(sha1_ctx_t *, uint8_t[SHA1_DIGESTLEN]); void sha1_digest(const char *, char *); void sha1_stream(FILE *, char *); @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/strings.c b/src/strings.c index b3dc1c4..ed90bc7 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -85,6 +85,7 @@ int string_vcatf(struct string *sb, const char *format, va_list ap) ap2); } sb->len += n; + va_end(ap2); return n; } @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/ui-calendar.c b/src/ui-calendar.c index f69ea4c..c1719d8 100644 --- a/src/ui-calendar.c +++ b/src/ui-calendar.c @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -560,9 +560,8 @@ draw_weekly_view(struct scrollwin *sw, struct date *current_day) if (j != WEEKINDAYS - 1 && i != DAYSLICESNO - 1) { WINS_CALENDAR_LOCK; - mvwhline(sw->inner, OFFY + 2 + i, - OFFX + 3 + 4 * j, ACS_S9, - 2); + mvwaddstr(sw->inner, OFFY + 2 + i, + OFFX + 3 + 4 * j, "__"); WINS_CALENDAR_UNLOCK; } if (slices[i]) { @@ -593,9 +592,9 @@ draw_weekly_view(struct scrollwin *sw, struct date *current_day) /* Draw marks to indicate midday on the sides of the calendar. */ WINS_CALENDAR_LOCK; custom_apply_attr(sw->inner, ATTR_HIGHEST); - mvwhline(sw->inner, OFFY + 1 + DAYSLICESNO / 2, OFFX, ACS_S9, 1); - mvwhline(sw->inner, OFFY + 1 + DAYSLICESNO / 2, - OFFX + WCALWIDTH - 1, ACS_S9, 1); + mvwaddch(sw->inner, OFFY + 1 + DAYSLICESNO / 2, OFFX, '<'); + mvwaddch(sw->inner, OFFY + 1 + DAYSLICESNO / 2, + OFFX + WCALWIDTH - 1, '>'); custom_remove_attr(sw->inner, ATTR_HIGHEST); WINS_CALENDAR_UNLOCK; diff --git a/src/ui-day.c b/src/ui-day.c index 0bd82bb..6a038fa 100644 --- a/src/ui-day.c +++ b/src/ui-day.c @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/ui-todo.c b/src/ui-todo.c index cad89fd..46933b3 100644 --- a/src/ui-todo.c +++ b/src/ui-todo.c @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -207,14 +207,16 @@ void ui_todo_draw(int n, WINDOW *win, int y, int hilt, void *cb_data) if (hilt) custom_apply_attr(win, ATTR_HIGHEST); - if (utf8_strwidth(todo->mesg) < width) { - mesg = todo->mesg; - } else { + mesg = todo->mesg; + if (mesg[0] == '\0') + mesg = EMPTY_EVENT_DESC_DEFAULT; + + if (utf8_strwidth(mesg) >= width) { width -= 3; - for (j = 0; todo->mesg[j] && width > 0; j++) { - if (!UTF8_ISCONT(todo->mesg[j])) - width -= utf8_width(&todo->mesg[j]); - buf[j] = todo->mesg[j]; + for (j = 0; mesg[j] && width > 0; j++) { + if (!UTF8_ISCONT(mesg[j])) + width -= utf8_width(&mesg[j]); + buf[j] = mesg[j]; } if (j) { buf[j - 1] = '.'; @@ -325,6 +327,11 @@ void ui_todo_popup_item(void) asprintf(¬epath, "%s%s", path_notes, item->note); fp = fopen(notepath, "r"); + if (fp == NULL) { + item_in_popup(NULL, NULL, item->mesg, _("TODO:")); + return; + } + note_read_contents(note, note_size, fp); fclose(fp); mem_free(notepath); @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/utils.c b/src/utils.c index f631c8c..2d30bfc 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -175,8 +175,6 @@ void vars_init(void) ui_calendar_set_first_day_of_week(MONDAY); - wins_set_sbar_width(col * SBARMINWIDTH / 100); - /* Pad structure to scroll text inside the appointment panel */ apad.length = 1; apad.first_onscreen = 0; diff --git a/src/vector.c b/src/vector.c index fd468ab..796ef8e 100644 --- a/src/vector.c +++ b/src/vector.c @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/vector.h b/src/vector.h index 86cb3b8..7648df2 100644 --- a/src/vector.h +++ b/src/vector.h @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without |