100 Commits
  • Allow newlines in SUMMARY by replacing them with blanks
    Addresses Github issue #414 (Android calendar allows them).
    
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Allow undefined actions in keys configuration file
    In the keys file there are three possibilities for each action:
    
    1. One or several keys are assigned to it
    2. It is marked as UNDEFINED (new)
    3. It is missing from the file
    
    On load of the keys file, calcurse respectively
    
    1. Assigns the key(s)
    2. Assigns "UNDEFINED" (new)
    3. Assigns a default key if possible
    
    If default keys were assigned, the user is informed of the number of
    actions affected, and the keys file is updated.
    
    After load each action must either have keys assigned or be undefined.
    If not, calcurse exits with a failure. If there are syntax/semantic
    errors in the file, calcurse rejects the file and exits.
    
    When an interactive user leaves the keys configuration menu, a warning
    is issued if any action is UNDEFINED. The keys file is always updated.
    
    Addresses GitHub issue #298.
    
    Additionally: Description of concepts and data structures used for
    keyboard keys and virtual keys (actions) as well as name changes and
    comments to improve readability.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Todo resort() optimization
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Keep a linked list sorted
    A general linked list function, llist_reorder(), is introduced that will reorder
    a list after a list element has changed.
    
    Some refactoring to avoid code dupliction.
    
    Background
    
    The four linked lists of appointment panel items (appointments, recurring
    appointments, events, recurring events) are kept sorted by inserting elements
    in order, either when they are first loaded from disk or when new are added.
    The ordering is by start time (numerical) and description (alphabetical).
    
    The user is allowed to change start time as well as description. A change is
    committed directly to the list item (unlike cut/paste where an item is deleted
    and then inserted). This may break the order.
    
    The order property is used when events are loaded from the evenlist into the
    day_item vector, see LLIST_FIND_FOREACH_CONT, and when looking for the next
    upcoming appointment, see apoint_check_next().
    
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Improve performance of recur_prev_occurrence()
    And fix item start day for prev command
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Introduce macro DAY
    DAY(t) is midnight (the day) of time_t t.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix parsing of UNTIL in iCal import
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Do not remove an empty note file after edit session
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Return failure if import skips any item
    Other items may have been imported succesfully.
    
    Adresses Github issue #323, last part.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Make iCal event import independent of property ordering
    Refactoring of ical.c: properties DTSTART, DTEND, DURATION, RRULE and EXDATE are
    saved and only processed after encountering END:VEVENT.
    
    Adresses Github issue #323, follow-up question.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Add p(revious) command
    The p(rev) command finds the previous occurrence of a recurrent item, analogous
    to the n(ext) command.
    
    A bug in the next command is corrected..
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Replace 'ical_rpt_t' with 'struct rpt'
    Refactoring and simplification only, no functional change. All error checking
    and logging done before call of ical_store_event/apoint().
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Extend icalendar export
    Export now covers advanced recurrence rules and properties imported to a note
    file.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Update use of note file for import
    Removes the parts of commit 'Extend use of note file for ical import' that
    relate to STATUS. The STATUS property is (partly) supported for todos already.
    
    Corrects insertion of a separator: always insert it before imported properties
    (also when there is no description).
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Improve event text for cancelled periodic save
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Revert "Interrupt periodic save when launching process"
    This reverts commit 0f3d198 (Interrupt periodic save when launching
    process, 2017-09-08).
    
    Stopping and starting periodic save when external/hook programs are run
    causes deadlocks. The periodic save thread cannot be stopped/started at
    will, but should be started once and run uninterrupted as long as
    calcurse runs. Only if the configuration parameter is changed, must the
    thread be stopped and possibly restarted.
    
    The reasons are
    
    - the start routine unconditionally starts a thread.
    - the mechanism used to detect whether a thread is running or not, is
      designed to be used by the main calcurse thread only and with only one
      running thread of each kind (the thread ID of each running thread is
      kept in a variable; if the thread is not running, the variable has the
      main thread ID as value).
    
    Any load hook will be run at the initial dataload, and the stop/start
    calls will start a perodic save thread (this is true for the notify
    thread as well). Later when threads are started, a second periodic save
    thread is started (for the notify thread, a running thread is stopped
    before restart).
    
    When hooks are run by the periodic save thread, the stop call breaks
    down, leading to two running save threads (if not the case already) and
    subsequently to a deadlock when one thread tries to stop the other.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Run hooks quietly
    Hooks should not be run like external programs, but like load and save
    operations that do not take possession of the terminal.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Remove SIGCHLD signal handler
    The purpose is to make child_wait() reliable. The handler is meant for
    the notify main thread, but signal handlers are shared by all threads.
    In the calcurse main thread and the periodic save thread (hooks) the
    handler and child_wait() will compete (if the signal handler kicks in
    first, the waitpid() call in child_wait() will fail with errno ECHILD).
    
    All child processes in the main thread, the notify thread, the periodic
    save thread and the notify demon are explicitly waited for.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix configuration menu 'Quit' action
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Improve help texts for recurrence rules
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Icalendar templates for recurrence rules
    To provide a starting point for advanced repeating items.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Remove systemdialogs option from configuration
    The option controls the welcome window and the export/import result messages.
    The former is dropped. The latter are now always displayed unless calcurse is
    invoked with the "quiet" option (-q).
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Allow repeat count input (for until) in interactive UI
    Shortened repetition type text.
    
    Avoid "duration" in until-contexts (reserve it for appointment duration):
    "duration" changed to "increment" in user texts as well as source.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Extend import of recurrence rules
    Support has been implemented for recurrence rule parts BYMONTH, BYMONTHDAY and
    BYDAY.  A new test has been added.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Update import of basic recurrence rules
    Conversion of COUNT to UNTIL was a simple calculation which assumed one
    repetiton per period (day, week, month or year); it does not take exception
    days and invalid dates into account. Solved by a new function which returns the
    n'th occurrence of a recurrence rule.
    
    In calcurse UNTIL is interpreted as a day (DATE), in RFC 5545 as a time of day
    (DATE-TIME). This has implications when a recurrence rule has an occurrence on
    the UNTIL day, see comment in ical.c
    
    An "Import:" note is added when a multi-day event is imported and turned into a
    calcurse all-day event.
    
    Icalendar quotes in comments have been updated to RFC 5545.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Support import of time zones (RFC 5545)
    The property parameter time zone identifier (TZID) is recognized in DTSTART,
    DTEND and EXDATE and the DATE-TIME value converted to a local time. The time
    zone identifier is logged in the note file.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Let RETURN set frequency type to current value in repeat command UI
    In addition, the prompt text is shortened.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Include start day in error message for recurrence rule
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix "next occurrence" for multi-day appointments
    Better name: day for occur.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix recurrence rule expansion with ordered weekday
    When the order of a weekday in BYDAY rule expansion (like -5SA or 5SU
    for monthly or 55WE for yearly) exceeds the number of available weekdays
    in the period (month or year), rule expansion with negative order could
    result in a floating point exception. The reason: the modified frequency
    might become zero.
    
    Solution. Check order against number of available weekdays and terminate
    expansion early whenever possible (also for positive orders).
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Take value data type of event start into account in iCal import/export
    The patch derives the item type (appointment or event) from the DTSTART
    value type. It is then used to perform an extended check of date/time
    values and reject non-conformant import files (like those reported in
    Github issues #81, (calcurse) events.
    
    The patch includes parsing and code corrections and minor refactoring.
    
    Background:
    
    Ical events are of two types, in calcurse called appointments and
    events. RFC 5545 has no distinguishing names for them, but describes
    them in section 3.6.1. The event type is derived from the value type of
    the DTSTART property. The value type may be either DATE-TIME
    (appointment) or DATE (event). If not specified by a VALUE property
    parameter in DTSTART, the default value type is DATE-TIME. The value
    type must be set explicitly to DATE to get an event. Other properties
    and rrule parts must agree with the DTSTART value type (DTEND, DURATION,
    EXDATE and UNTIL).
    
    Previously the type of an imported event was derived from the format of
    the DTSTART value. The DTSTART value type was not taken into account
    when importing, and not specified for recurring events when exporting
    (commit 0114289 solved it for events, see GitHub PR #97).
    
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Support interactive test of recurrence rule extensions
    The generic command 'next' is introduced.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Help for recurrence rule extensions
    The help command has been updated for "repeat".
    
    Context dependent, very terse information is built into the repeat
    command (edit command) for display in the status bar when editing the
    Weekdays, Months and Monthdays lists.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Treat recurrent events and appointments alike
    The day vector (or "day_items" vector) is used to load the appointments
    panel with "day_items" (captions, appointments, events). A multi-day
    appointment has several "day_items" in the day vector. This may also be
    the case for a recurring item.
    
    The day_item structure has a member "start", which for day_items for
    recurring appointments is set to the occurrence found by
    recur_item_find_occurrence(), and is used to tell days of a multi-day
    appointment apart.
    
    For day_items for recurring events it was set to "day" of the
    recur_event structure (the same value for all occurrences) and not used.
    The value is now the occurrence found by recur_event_find_occurrence().
    
    The patch is backwards compatible and future-proof.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix preselection
    The preselected item is not searched for if the range of days is changed
    (day_changed = 1). The patch is meant to future-proof the
    selected-item-algorithm and is backwards compatible.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Refactor the repeat command
    Code duplication has been eliminated by calling update_rept() from the
    repeat command ui_day_item_repeat().
    
    The repeat command asks for simple or advanced repetition.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • User interface for recurrence rules
    The function update_rept() is extended with editing of the three
    recurrence rule lists for BYMONTH, BYMONTHDAY and BYDAY.
    
    The integers of the bymonth and bymonthday lists are edited directly as
    integers, while those of the bywday list are mapped to localized weekday
    names (as they appear in the calendar panel) with an optional integer
    prefix (in RFC5545 style: 1MO, -2SA).
    
    The RFC5545 (icalendar) requirement that the start day must be the first
    occurrence and must match the recurrence rule, is met by testing that an
    occurrence indeed appears on the start day, in these circumstances:
    
    - when a recurrent item is loaded from file
    - when the recurrence rule of an item is edited interactively
    - when a recurrent appointment gets a new start time
    - when a recurrent appointment is moved
    
    Copy and paste of a recurrent item will only retain the basic recurrence
    properties of type, frequency, until and exception days.
    
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Tests for recurrence rule extensions
    Test cases include all the examples from RFC5545 which are supported.
    
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Recurrence rule extensions
    Terms and concepts are from RFC 5545 (the iCalendar specification).
    
    Overall design
    --------------
    
    Calcurse is extended with full support for BYMONTH, BYDAY and BYMONTHDAY
    recurrence rule (rrule) parts. The three rule parts are lists of,
    respectively, months, weekdays and monthdays. The lists are added to
    'struct rpt' as linked lists of integers, and the data file format is
    extended accordingly (details below). Load and save of the lists follow
    the pattern of the existing list of exception dates, also in 'struct
    rpt'.
    
    The function recur_item_find_occurence() is split into a front-end and a
    back-end. The back-end, called find_occurrence(), is the original
    function extended with rrule reductions; the front-end retains the
    original name and performs rrule expansions. Front-end plus back-end are
    backwards compatible and require no changes in calling functions.
    
    There is no user interface in this patch.
    
    Data file extensions
    --------------------
    
    The BYMONTH, BYDAY and BYMONTHDAY lists are added to that part of an
    item line which describes the recurrence rule (the "{...}" part). Each
    list is - like the list of exception days - a space-separated string of
    values identified by the initial character.  Each list is optional and,
    if present, must follow the until date and precede the exception day
    list. The lists must appear in order BYMONTHDAY list, BYDAY list and
    BYMONTH list.
    
    The possible list values are
    
    - BYMONTH: m1, m2, ..., m12
    - BYDAY: w0, w1, ..., w6, w7, w-7, w8, w-8, ..., w377, w-377
    - BYMONTHDAY: d1, d2, ..., d31, d-1, d-2, ..., d-31
    
    which are interpreted as (cf. RFC 5545)
    
    - BYMONTH: January, February, ..., December.
    - BYDAY: SU, MO, ..., SA, +1SU, -1SU, +1MO, -1MO, ..., +53SA, -53SA
    - BYMONTHDAY: the first, the second, ..., the 31st, the last,
      the last but one, ..., the last but 30 day of the month
    
    Examples:
    
    Thursday, TH, is w4; Saturday, SA, is w6.
    
    The seventh Thursday, +7TH, is w53 (7 * 7 + 4 = 53); the last but second
    Saturday, -2SA, is w-20 (2 * 7 + 6 = 20); the last day of the month is
    d-1.
    
    Note that the values w-1, w-2, ..., w-6 are not used.
    
    A recurrent appointment with a BYDAY rule part:
    
    06/23/2019 @ 12:00 -> 06/23/2019 @ 13:00 {1W w0 w6} |every week on Sunday and Saturday
    
    An event with a BYDAY and a BYMONTH rule part:
    
    10/27/2019 [1] {1Y w-7 m10} every year on last Sunday in October
    
    An event with until date, a BYMONTH rule part and an exception day:
    
    06/23/2019 [1] {1Y -> 08/31/2021 m5 m6 m7 !07/23/2020} every year on the 23rd in May, June and July for three years, starting on Sunday, 23 June 2019, but not on 23 July 2020.
    
    Recurrence set expansion and reduction
    ---------------------------------------
    
    In calcurse a recurrence rule is a quadruple (s, d, r, e) consisting of
    start, duration, repetition pattern and exception days and is
    implemented as:
    
    	(time_t start, long dur, struct rpt *rpt, llist_t *exc)
    
    In RFC 5545 parlance, a recurrence rule defines a recurrence set
    consisting of all recurrence instances (occurrences) not earlier than
    start which match the rule pattern. With this concept in mind,
    recur_item_find_occurremce() may be thought of as a membership function
    for a recurrence set. The call
    
    	recur_item_find_occurrence(s, d, r, e, day, occurrence)
    
    returns true if day belongs to the recurrence set of (s, d, r, e); if so
    occurrence points to the recurrence instance (the set member).
    
    For a recurrence rule with only the basic DAYLY, WEEKLY, MONTHLY or
    YEARLY type and frequency the recurrence set consists of periodically
    repeated instances.  The BYxxx rule parts modify the recurrence set by
    reducing or expanding it as specified by RFC 5545.
    
    Expansion is implemented in the front-end by modifications of start
    and/or frequency of the rule (s, d, r, e), often several times, in such
    a way that the desired recurrence instances are included in the
    recurrence set. This is possible because the front-end as the very first
    thing checks for early days (day < s). When day is known not to be
    early, start (s) can safely be moved backwards. Likewise, if frequency
    must be changed, the front-end checks whether the frequency repetition
    applies to the week, month or year of day.
    
    Reduction is easier and is performed in the back-end along with the
    existing validity checks. It consists in checking whether month, day of
    month or weekday of a found occurrence is on the appropriate list.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Refactor edit of exception days
    The patch contains no functional changes, but is a necessary
    precondition for extensions of update_rept() (in ui-day.c) with further
    recurrence rules.
    
    The reason is that recurrence parameters must be treated as a whole: if
    an edit session is cancelled at any point, no value should change, and
    all parameters should remain as they were. Hence, the new values must
    only be set after all of them have been determined. This was not the
    case for the list of exception days, but as long as it was treated last,
    it did not matter.
    
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Improve data load error reporting
    The last part of loading appointments and events is performed by four
    "scan" functions called from io_load_app(). Failure in this part of data
    load does not use io_load_error().
    
    The four "scan" functions are changed to return an error message on
    failure and NULL otherwise (the previous return value was not used).
    
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Refactor function calls: recurrence parameters as a single argument
    The recurrence parameters are type, frequency, until date and exception
    list (in RFC 5545 parlance FREQ, INTERVAL, UNTIL and EXDATE's). When
    these are passed in a function call, the argument list becomes long and
    not very readable.  When support for extended recurrence rules is
    implemented, the number of recurrence parameters increases, and function
    signatures must be amended.
    
    Solution: The "struct rpt" is extended with the exception list; any
    future recurrence parameters are added here. A pointer to this structure
    replaces the recurrence parameters in function calls.
    
    Note: Each recurrent event and appoinment instance has (a pointer to) a
    "struct rpt" and in addition an exception list. The latter is retained
    to avoid the derived changes, and the exception list in the structure is
    initialized to an empty list when the recurrent instance is created.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Use "struct rpt" to shorten argument lists
    Also, prepare for extension of the structure, shorten names and
    rearrange comments.
    
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Extend use of note file for iCal import
    iCal import to an item note file is extended from DESCRIPTION to
    LOCATION, COMMENT and STATUS for both events and todos.
    
    Addresses GitHub issue #9.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Accept empty DESCRIPTION in ical import
    Adresses GitHub issue #274.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix missing EOL in imported note
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Extend iCalendar import tests
    Tests ical-010.sh and ical-011.sh assume that Github issue #265 has been fixed
    (escape-encoding by export).
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix decoding of escaped characters in imported text
    Stick strictly to RFC 5545, 3.3.11, Text, for SUMMARY and DESCRIPTION.
    Adresses Github issue #271.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix ical import logging
    The following issues have been fixed:
    
    Functions ical_read_event() and ical_read__todo() do not check the return value
    of functions which may fail, in which case an item is not skipped even though
    a problem may have been logged by the called function.
    
    Function ical_read_note() fails on empty DESCRIPTION, but does not log it.
    
    Function ical_read_exdate() may log a failure, but cannot fail itself.
    
    Function ical_read_summary() can fail, but not log a failure.
    
    Function ical_read_todo() do not skip a todo with an invalid priority.
    
    Additionally:
    
    A safety check has been added to ical_get_value(), and log messages resulting
    from failures have been made uniform.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix display of interactively imported todos
    Todos were imported (and saved), but not loaded into the listbox for display.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Improve ical import logging
    The log file is not deleted if items were skipped (adresses Github issue #269).
    The log file includes the import file name and time.
    The import line numbers have been corrected (and tests amended).
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Refactor cut and paste registers
    Register REG_BLACK_HOLE can neither be copied into nor pasted from and
    has been removed from the input routine.
    
    Register 36 was not used.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix next recurrent appointment deleted
    If the notify bar displays a recurrent appointment after midnight as next
    upcoming appointment, the bar is not updated when the appointment/occurrence is
    deleted.  The problem is not seen in 4.3.0 because of the bug described in
    commit 8cbd456, Fix next recurring appointment.  The problem and the solution is
    the same, this time in the function notify_same_recur_item().
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix empty string in updatestring()
    If the update results in an empty string (return value GETSTRING_RET), the
    original string remains whereas it should be empty.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Make the text for empty days configurable
    The default is "--"; a single space makes the text invisible.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix save of interactively imported data
    Adresses Github issue #249.
    
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Test for DST and recurrent items
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • DST and recurrent items
    The patch adresses two issues with the function recur_item_find
    ocurrence(), one major: mktime(), and one minor: item duration. In
    addition, some refactoring is done.
    
    The following recurrent appointments demonstrate the problems (as
    described in the message) and are used as test cases in the associated
    test commit.
    
    03/29/2019 @ 12:00 -> 03/30/2019 @ 11:00 {2D -> 04/03/2019} |two-day - every other day - not on 1/4
    03/31/2019 @ 12:00 -> 03/31/2019 @ 13:00 {1D -> 04/01/2019} |daily - not on 31/3, twice on 1/4
    03/31/2019 @ 04:00 -> 03/31/2019 @ 05:00 {1W} |weekly - appears after one week
    03/31/2019 @ 12:00 -> 03/31/2019 @ 12:00 {1M} |monthly - never appears
    03/31/2019 @ 12:00 -> 03/31/2019 @ 12:00 {1Y} |yearly - never appears
    10/20/2019 @ 00:00 -> 10/21/2019 @ 01:00 {1W -> 11/03/2019} |25 hours - ends on 27th, but continues on 28th
    03/24/2019 @ 00:00 -> 03/25/2019 @ 00:00 {1W -> 04/07/2019} |24 hours - does not continue on April 1
    
    The root cause is two mktime() calls in recur_item_find_occurrence(),
    both of which use an inherited tm_isdst value in the tm structure. In
    such cases mktime() will "normalize" the tm stucture if tm_isdst is 0 or
    1 and in disagreement with the rest of the tm contents (just like 32 May
    will be normalized to 1 June).
    
    Example. In 2019 DST started on 31/3 at 02:00:00 (in the European
    Union). If the (local) time "31/3/2018 00:00:00" is passed to mktime()
    with tm_isdst = 0, the return value is (say) T sec and the tm structure
    is unchanged, because DST is not in effect at midnight. If the same call
    is performed with tm_isdst = 1, the return value becomes (T - 3600) sec
    and the tm structure is normalized to "30/3/2018 23:00:00", tm_isdst =
    0.
    
    In recur_item_find_occurrence(), the normalized tm structure with wrong
    day and time is used in ensuing calculations, leading to wrong dates and
    the errors observed.
    
    The first mktime() call is used to calculate the "day span" of the
    occurrence before the occurrence itself has been determined. But once
    the occurence is known, the "day span" is easily determined, and there
    is no need for the first mktime() call.
    
    Events have no explicit duration. However, recur_event_find_occurrence()
    and recur_event_inday() set the duration of an event to DAYINSEC before
    passing it on to recur_item_find_occurrence(). The value is not correct
    on the day when DST begins or ends. The interpretation of the daylength
    should be left to the called function. Hence, duration is set to -1 to
    signal no (explicit) duration.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Set time-of-day consistently to midnight for until day
    A day begins on midnight (inclusive) and ends on midnight (exclusive). A
    day as a whole is represented by the initial midnight, i.e. time-of-day
    is 00:00.
    
    On load of recurrent appointments (but not events) time-of-day for the
    until day is set to 23:59. For a newly created recurrent appointment the
    setting depends on the input method: time-of-day is set to 00:00 if
    until day is given as a date (day, month and year), but to time-of-day
    for the start day if given as an offset (+dd).
    
    The resulting behaviour is only visible in interactive use of calcurse
    as proved by the following scenario.
    
    1) Create an appointment with start time 12:00, end time 11:59 (multi
       day).
    
    2) Turn it into a recurrent appointment of type daily, frequency 3,
       until day +3.
    
    The appointment is correctly displayed with two 2-day occurrences three
    days apart.
    
    3) Edit the appointment and select Repetition. Accept existing type,
       frequency and end day (now as a date).
    
    The second day of the second occurrence disappears.
    
    4) Repeat 3), but set the end day as an offset (+3).
    
    The second day of the second occurrence reappears.
    
    The inconsistencies have been eliminated, and time-of-day for the until
    day is now always 00:00.
    
    Also, until day may equal start day, so midnights should be compared.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • DST: fix date_change() thoroughly
    Explicit setting of Daylight Saving Time should be avoided before as well as
    after the mktime() call.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix monthly and yearly recurrence algorithms
    The calculation of the year of the most recent occurrence for year dates before
    the start date (disregarding the year) is incorrect for frequencies greater than
    one. The most recent occurrence (for a date as mentioned) is either too far or
    too close in the past. In most cases it does no harm because the most recent
    ocurrence is in the past and does not span the date (i.e. there is no occurrence
    on the day). But the following appointment shows the presence of the bug:
    
    12/31/2019 @ 12:00 -> 01/01/2020 @ 12:00 {2Y} |new year
    
    The occurence on 1 Jan 2020 is missing, because the most recent occurrence is
    too far in the past (31 Dec 2018 instead of 31 Dec 2019). An occurrence appears
    on 1 Jan 2021, because the most recent occurence is too close in the past (31
    Dec 2020 instead of 31 Dec 2019).
    
    A similar miscalculation affects the monthly rule as proved by
    
    3/31/2019 @ 12:00 -> 4/1/2019 @ 11:00 {2M} |change of month
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix edit of empty exception day list
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Treat recurrence item parameters as a unit
    An edit session, and in particular, a cancelled edit session should encompass
    all parameters.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix recurrent appointment end time when duration is zero
    Fixes a regression introduced in 223810c (Major overhaul of
    appointment/event input routines., 2017-11-06) and 16d3032 (Refactoring
    update_duration/day_edit_duration., 2017-10-18).
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Return at least two days in multiple days mode
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Remove appointments panel scrollbar in multiple days mode
    A scrollbar gives the impression of a fixed list. But the list on
    display is automatically and silently changed as needed for movements in
    the panel or the calendar, thus creating the illusion of an endless
    list.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix sidebar width to accommodate calendar week column
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix missing calculation of number of days on resize
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Automate the calculation of number of days to load
    Instead of having the user tell how many days to load, calcurse can
    calculate an overestimation from the running configuration (panel size,
    appearance of headers and separators etc.)
    
    The configuration variable conf.multiple_days is turned into a Boolean
    that switches the feature on and off.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Make separation of days conspicuous
    ... by adding a horizontal line from border to border above the day
    heading and turning the event separator into an empty line. The
    horizontal line is left out for the first day loaded.
    
    Also reduce the number of empty lines at the end of a day to at most
    one.
    
    A new configuration variable, header_line, turns the horizontal line on
    and off.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Derive selected day from selected item
    Previously, with only one day visible at a time, the appointments panel
    displayed the details of the day selected in the calendar (slctd_day);
    information required for operations on items (day_items) can often be
    derived from the selected day. The items available are derived from the
    selected day. In particular, the selected item is derived from the
    selected day.
    
    With multiple days in the APP panel, the relation between selected day
    (in the calendar) and the selected item (in the APP panel) has, in a
    way, been turned around. The selected item may now be moved between days
    without explicitly changing the selected day. Implicitly it is changed
    when the target day of a move is unavailable.
    
    This commit draws the full consequence: the selected day in the calendar
    is always (set to) the day of the selected item in the APP panel.
    
    The static variable 'struct date slctd_day' lives in ui_calendar.c and
    is accessible through various public functions. To these are added
    ui_calendar_set_slctd_day() which sets slctd_day directly.
    
    The selected day retains its significance for load of the day vector (in
    day_store_items()): the range of loaded days begins with the selected
    day.  Movements (up/down) in the APP panel will change the selected day
    as the selected item moves among the already loaded days. Only when the
    target of a movement is unreachable, will further days be loaded. On the
    other hand, if the same range of days must be reloaded because of a
    changed item, the selected item - and with it the selected day - must be
    reset to the first day item (see do_storage()).
    
    Movements in the calendar (generic-next-day, etc.) are not affected and
    behave as previously, i.e. they will cause a range of days to be loaded
    with the selected day as the first and the selected item as the first of
    the selected day.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Add configuration variables for multiple days
    The number of days displayed in the APP panel has been made
    configurable, maximum 21 days, default seven days.
    
    With several days in the APP panel, it may be desirable to "squeeze" the
    entries by leaving out the final empty line of each appointment and
    lower the number of lines between consecutive days (0, 1, or 2). Both
    are made general configuration options. To make a uniform display, an
    empty line is added to a day without appointments, if appointments have
    an empty line.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Add week numbers in the calendar and full first and last week
    Much in the calendar is based on the selected day, struct date
    slctd_day, in ui-calendar.c.
    
    On the screen it is highlighted with a deviating colour. The highlight
    effect has been changed to a pair of red square brackets that do not
    obscure the day colour.
    
    The week number (in the frame) used to be that of the selected day, but
    has no obvious relation to the days in the APP panel. It has been
    replaced by the year day number of the selected day. The week numbers of
    all visible weeks are displayed to the left of the calendar.
    
    Dates are displayed also for the overlapping parts of the first and last
    week of the month (which do not belong to the month).
    
    Days are accessible in the appointments panel as well as in the
    calendar. Hence, validation of days (= inside UNIX time limits) must be
    extended from the calendar (in ui_calendar_move()) to include loaded
    days (in day_store_items()).
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • 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 <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Redesign selected-item implementation for the APP panel
    The day vector, day_items, is displayed in the appointments panel; the
    selected day_item object is highlighted (when the panel has the focus).
    When items are inserted, edited, moved etc., and when the day is
    changed, the day vector is rebuilt and displayed anew.
    
    Problem: How shall the selection be set automatically in the context of
    the new day vector?
    
    In previous versions all of the above is mostly handled by the function
    do_storage() in calcurse.c The function saves data about the selection
    as needed, rebuilds the day vector, loads the listbox and sets the
    selection from the saved selection data.  This works well in "single
    day" calcurse in cases where the selected item is present in the day
    vector both before and after the rebuild, or when the item ordering in
    the listbox is unaffected by the changes.  But when a new item is added
    the selection cannot be set to the new object by do_storage().  Instead
    the necessary operations are performed by ui_day_item_add(), and
    do_storage() is bypassed. In general, when an item cannot be found in
    the new vector, the item which occupies the old place in the list gets
    selected, e.g. when an item is deleted. When an item is turned into a
    repeating one, the old item is deleted and a new is created. Here the
    new selection is not always the affected item, but in any case not far
    away.  Generally, with only one day in the panel an erronous selection
    might not be noticed or be accurate by chance.
    
    In "multiple day" calcurse the existing scheme works less well; in
    addition the day vector may now contain more than one object that refer
    to the same event or appointment (recurrent items or multi-day
    appointments). The scheme has therefore been modified. The do_storage()
    function is no longer bypassed, but handles day vector rebuild, load of
    listbox and item selection exclusively. To make that possible, data
    about the selected item is no longer saved in a local automatic
    variable, private to do_storage(), but in an external static variable in
    day.c, which may be set not only by do_storage(). The variable is
    declared as
    
    static struct day_item sel_data;
    
    and used as follows:
    
    1. On startup sel_data is initialized to empty (i.e. no selection).
    2. In any operation involving the appointments panel:
       2.1 Do the work and if necessary set sel_data. This is the case when
           deleting, adding or pasting an item, and when turning an ordinary
           item into a recurrent one.
       2.2 Call do_storage().
    3. In do_storage():
       3.1 If sel_data is empty, set it to the current selection.
       3.2 Rebuild the day vector.
       3.3 Set the selection from sel_data.
       3.4 Set sel_data to empty.
    
    Further remarks
    ---------------
    
    The selection is found in the new day vector by searching for the saved
    (order, item.<pointer>) pair. Previously the item.<pointer> alone
    sufficed and in some cases it still does. In case the item cannot be
    found, the selection stays in the same day as before the rebuild.
    
    An attempt at more consistently named APP-related functions has led to:
    ui_day_sel_date() replaces ui_day_sel_day() ui_day_get_sel() replaces
    ui_day_selitem()
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • 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>
  • Simplify day storage
    The function day_process_storage() is a wrapper for day_store_items().
    It has an unused second argument, and is only used twice to load the
    selected day. It has been removed.
    
    A new function, get_slctd_day(), is the equivalant of get_today() and
    replaces the very awkwardly named ui_calendar_get_slctd_day_sec().
    
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix initialization of the day_items vector
    This patch fixes all failings tests, but one, in PR #193.
    
    Until now the missing initialization of day_items_nb has caused no
    problems, because the variable was assigned to (=) before being used. In
    the Multiple days implementation it is repeatedly increased (+=) in a
    loop without being initialized first. Indeed, this may considered an
    easily fixed bug. But the initialization really belongs in
    day_init_vector() so that the call day_item_count(0) returns 0 if done
    right after the call day_init_vector(). The bug only shows up in command
    line mode because day_items_nb is not used in interactive mode.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Refactor listbox code
    The changes are related to the selected item and the visible lines in
    the scroll window viewport.
    
    In particular, the function listbox_fix_visible_region() has been
    eliminated, and functions previously only called by it have been
    removed. It performed several tasks that are now elsewhere. One was
    removed in an earlier commit (scroll window pad improvement). The task
    of making a multi-line item visible has been moved to
    listbox_item_in_view(). The task of making a caption line above a text
    line visible is listbox specific (for the ap_list) and will be moved to
    ui_day_sel_move(), where it is needed.
    
    Boundary checks for the listbox selection have been moved to
    listbox_fix_sel().
    
    For future use listbox_sel_move() returns success or failure.
    
    The function wins_scrollwin_ensure_visible() has been renamed
    wins_scrollwin_in_view().
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Improve scroll window pad
    A scroll window consists of a pad to write on, and a window through
    which to view the pad, the viewport. The pad may change in size when new
    contents are loaded into the scroll window. If so, the pad size is set
    with wins_scrollwin_set_linecount(). But the offset into the pad (the
    top line to be displayed in the viewport) is not adjusted, although it
    may not be appropriate for the new pad size. The same is the case when a
    scroll window is resized and the viewport changes size. This is probably
    the cause of the problem solved by commit 0b46ad4, Avoid blank space
    after the last list box item, and the fix has been removed.
    
    The wins_scrollwin_set_linecount() has been renamed
    wins_scrollwin_set_pad() and sets size as well as offset. The offset is
    only changed if necessary.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Test cases for impossible dates in recurrence rule
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Impossible dates in recurrence rules
    According to RFC 5545 dates like 30 February and 31 June must be ignored
    when derived from a recurrence rule.
    
    calcurse relies on mktime() "normalization" of dates (e.g. turning 32
    December 2019 into 1 January 2020 when moving from 31 December to the
    next day).
    
    Normalization may also lead to impossible dates in monthly and yearly
    recurrence rules, and this must be avoided.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • New test cases for next appoinment
    The change by commit "Fix display of time left before next appointment"
    is not detected by the existing test because the time set has zero
    seconds.
    
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix display of time left before next appointment
    In the notify bar, the clock is shown in hours, minutes and seconds,
    whereas the time left to the next appointment is shown in hours and
    minutes only. When you read the clock in hours and minutes (discarding
    the seconds), you are mentally rounding down to the nearest minute. To
    agree with that reading, the time left (in seconds) should be
    (programmatically) rounded up to the nearest minute for display.
    
    In that way the time left is counted down whenever the minute "hand" of
    the clock "ticks", and reaches zero when the clock reaches the time of
    the next appointment, not one minute before. Also, the clock (in hours
    and minutes) and the time left always add up to the time of the next
    appointment.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix daemon notification for short warning periods
    When the warning period for notifications is less than 60 seconds
    (DAEMON_SLEEP_TIME), the daemon may be at sleep when the appointment
    comes up. If that happens, no notification is launched. In stead, the
    daemon should launch the notification early.
    
    Addresses GitHub issue #204, part 2.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix one-second warning period for notifications
    Adresses GitHub issue #204, the interactive part.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Avoid deadlock in config_save()
    Must not exit with nbar.mutex locked.
    
    Addresses GitHub issue #201.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix calendar (re)draw
    Window erasure is moved to the drawing functions.
    
    Adresses GitHub issue #196.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix vector_remove()
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • View or edit exception days of a recurrent item
    The exception days are presented for viewing/editing as a string of
    space-separated dates (in the user-preferred input format). After
    editing the string is checked for valid dates, but there is no check
    that a date is meaningful (an occurrence day of the item between start
    day and until day). Although possible, it is best to add exception days
    in the usual way by deletion of occurrences.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix empty dynamic string
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix deletion of a multi-day recurrent appointment
    When the selected day in the calendar is a continuation day (not the first day)
    of such an appointment, deleting the occurrence does not work. The reason is
    that the selected day, and not the first day of the occurrence, is added as an
    exception day.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Overflow check for 32-bit types only
    Included is a check of the 'until' date for pasted recurrent items.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Legalese for queue.c
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Fix next recurring appointment
    Recurring appointments do not show up in the notification bar as next
    appointment. This was partly corrected by 2084f35 (Fix notification of
    recurrent appointments, 2017-02-09) and 5aa7a09 (Fix another error in
    the notification code, 2017-02-11).
    
    The search function recur_apoint_starts_before() had a wrong second
    argument, but is really of no use: the start time of a recurring
    appointment is the start time of the very first occurrence (in the
    past). A comparison against the item in the notify_app structure tells
    nothing of the start time of the current day; at most it eliminates some
    future recurring appointments. The function can be dropped, and the
    entire recurring appointment list looked through.
    
    The proper start time is found in the main search loop (and called
    real_recur_start_time) and must be compared against the item in the
    notify_app structure.
    
    But because recur_apoint_find_occurrence() is limited to a particular
    day (second argument), two searches are necessary to cover 24 hours.
    
    Unrelated cleanups: removed function return value; changed long to
    time_t.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Initialize data paths once only
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
  • Explicit calendar and todo view configuration
    The configuration settings for calendar view (monthly/weekly) and todo
    view (hide/show completed) used to be saved automatically on calcurse
    exit, with values taken from the current interactive settings. They
    could not be set explicitly in the configuration menues. Configuration
    settings are no longer saved on program exit, but on exit from the
    configuration menu. This means that the saved values are those that were
    current when the configuration menu was entered. To change a saved
    value, you must set the view as desired and then enter/exit the
    configuration menu.
    
    The preferred calendar and todo views are no longer automatically taken
    from the interactive settings, but are explicitly set in the general
    options menu.  Default values are monthly view and hide completed view.
    
    Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
    Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>