190 Commits

Author SHA1 Message Date
Lars Henriksen
5942c0760d 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>
2020-06-13 10:56:15 -04:00
Lars Henriksen
467815d465 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>
2020-03-22 13:40:28 -04:00
Lukas Fleischer
5ad76df5fe Update copyright ranges
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-01-30 19:22:23 +01:00
Lars Henriksen
066df02cbf 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>
2019-05-22 01:56:59 -04:00
Lars Henriksen
371c7eb00f 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>
2019-04-13 11:58:04 +02:00
vxid
2c50f0700a Change -C and -D long option names
The config dir long option has been changed from --conf to --confdir.
The data dir long option has been changed from --directory to --datadir.

Both old options are kept for backward compatibility but are removed
from the manual.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-03-13 17:01:54 +01:00
Lars Henriksen
8cbd456640 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>
2019-01-11 18:11:52 +01:00
Lars Henriksen
f2ca5980e9 Initialize data paths once only
Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-01-08 01:23:21 +01:00
Lars Henriksen
b9f23e134a Purge option glorified
The invert filter option is automatically set for -P (and cannot be used
on the command line). The intention is that the grep option (-G) is used
to find the items that should be removed. To remove them, the same
command is run with -P instead of -G.

In general, purge will remove matching items (silently).

Backward compatibility for option -F (no invert filter).

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-01-07 16:58:08 +01:00
Lars Henriksen
42abbf5346 Filter option: invert
New filter option: --filter-invert. When present it inverts (negates)
the other filter options combined. This is mostly useful with the -G
option (with -Q the output is limited by the query range (day range)).

The ouput from "calcurse -G <filter options>" is the (set) complement of
"calcurse -G <filter options> --filter-invert". Here <filter options>
may be any combination of filter options.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-01-07 16:58:06 +01:00
Lars Henriksen
9300e9154c CLI: detect conflicting filter options
Several start/end-time filter options set the same filter criterion.
Only allow one such filter option at a time.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-01-07 16:58:03 +01:00
Lars Henriksen
620c4eeca5 CLI: Revert to and update of parse_datetimearg()
An earlier commit ("CLI: take input date format from configuration file,
do not accept time") replaced parse_datetimearg() with parse_datearg()
and eliminated time-of-day from command line date arguments. This made
the full use of filter options impossible.

That earlier commit is reverted and updated. The parse_datearg()
function is replaced by an updated parse_datetimearg() function that

- takes the date format from the configuration file
- accepts date, date-time or time

The updated parse_datetimearg() function has been extended to report
back the type of the date string received in order to set (filter)
options correctly.  Input dates for query ranges (--from, --to, --days)
are still limited to dates only.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-01-07 16:58:01 +01:00
Lars Henriksen
ad183c61a9 CLI: do not start daemon if calcurse is running
Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-01-07 16:57:53 +01:00
Lars Henriksen
4ba2cc46d7 CLI: time assignments for filter options
Explanation. There is an important difference between "to <date>" (e.g.
to 15/11/2018)  and "to <date time>" (e.g. to "15/11/2018 13:30"):
<date> is a time span (of 24 hours), while <date time> is a point in
time.

"To <date>" really means "to the end of <date>", while "before <date>"
means "before the beginning of <date>". There are 24 hours between the
two, whereas there is only one second between "before <date time>" and
"to <date time>".  Similar for from/after.

An earlier commit introduced parse_datearg() that only accepts a date
without a time. Hence, a date should be treated as a time span from
midnight to one second before next midnight.

The commit also fixes an error detection bug (filter.start_from/to and
filter.end_from/to were updated too early).

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-01-07 16:57:51 +01:00
Lars Henriksen
42e296c840 CLI: long options to override configuration file settings
The input and output date formats may be set from the command line.
Intended for scripts that must be independent of the local user
configuration.

Cannot be used in interactive mode.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-01-07 16:57:49 +01:00
Lars Henriksen
3d7bb89c88 CLI: take input date format from configuration file, do not accept time
Before this patch the input date parsing accepts three formats:
yyyy/mm/dd, mm/dd/yyyy, yyyy-mm-dd. They are tried in sequence. It also
accepts an additional time (hh:mm), or a time without a date.

There are several issues with this:

- it is not documented
- the date format dd/mm/yyyy is not accepted
- print_date() and filter option settings (in parse_args()) can only
  handle midnight times (which are the result of a date without time)
- it is highly uncertain what happens if a time (without a date) is
  given; at least the -d option treats a time without colon (1215 for
  12:15) as a number

It seems that acceptance of time input is a by-product and not needed.
For these reasons the input date parsing has been changed:

- the format is taken from the configuration file (as is the case for
  the output date format)
- only a date, and no time, is accepted

Because the input date format is used during parsing of the command
line, the configuration file must be loaded first, i.e. the options -D
or -C must be parsed before the remaining ones. Loading the
configuration file may result in errors (e.g. caused by changes between
versions). For this reason config_load() has been made more tolerant and
issues warnings instead of exiting.

A followup patch will introduce two options to allow the configuration
file settings to be overridden for input and output date formats.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-01-07 16:57:48 +01:00
Lars Henriksen
215e90d348 Command line options: -P, option check, usage, help
Option -F/--filter renamed to -P/--purge; -F retained as deprecated.
Check for non-option arguments and for filter, format and query-range
options only.  Update of help and usage messages.

Fixed --status output when calcurse is not running.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-01-07 16:57:46 +01:00
Lars Henriksen
03880a82bf Fix day range for queries
In "--from a --to z", a is included in the range, z not. This is
non-intuitive and disagrees with the semantics of "to" in filter options
like --filter-start-to, where "to" (and "from") are used inclusively (as
opposed to "before" and "after"). It also has the effect that "--from
today --to tomorrow" has a range of 1 day, "--to z" a range of 0 days
(otherwise not allowed), and "--to today --days -1" is allowed and
displays yesterday!

The implementation has been fixed to agree with "inclusive" semantics.
Options --from and -days with negative range are allowed, while --to and
--days are disallowed also when the range is negative.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2019-01-07 16:57:43 +01:00
Lars Henriksen
4285e88593 Rewrite of io_init()
The introduction of the "-C <confdir>" option is an opportunity to
review the initialization of data paths. It lead to a rewrite.

Two "root" directories are used (data and configuration files); by
default they are identical. The statically allocated path buffers are
turned into dynamically allocated buffers.

Missing files/directories now include hooks.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2018-12-14 10:35:11 +01:00
Lars Henriksen
5ad0019b23 Only reload if data files were changed (replacement)
This is a replacement for commits 57dd3d6 and 912124b.

The idea is to move the check for modified files and the list initialization
into io_load_data(), and let io_load_data() decide what to load. A new
argument is used to force a load.

The return code from new_data() (the renamed version of
io_check_data_files_modified()) tells which files have changed.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2018-10-21 20:01:34 +02:00
Lars Henriksen
ddc3fda5f1 Initialize variables in non-interactive mode in all cases
The changed handling of thread ids implies that they must be initialized
before exit of calcurse where they are used. Hence the function
vars_init() is now called irrespective of command line arguments.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2018-08-19 09:10:06 +02:00
Quentin Hibon
e9611ce3a6 Use a path instead of a file for -C option
Allows to specify a configuration directory containing:
* conf
* keys
* hooks

When used in combination with -D $ddir, $ddir contains all the other
files not mentioned above.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2018-08-05 18:36:25 +02:00
Quentin Hibon
407d5abd23 Add option to specify the configuration file used
The configuration file (~/.calcurse/conf by default) can now be
specified with -C or --conf.

Workaround for GitHub issue #86.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2018-05-28 06:29:09 +02:00
Lukas Fleischer
b82a3b9276 Allow for passing negative arguments to -d
When specifying date ranges using -d, allow for passing negative values
to indicate that the date range should start a certain number of days
ago.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-12-13 09:06:32 +01:00
Lars Henriksen
0df373f26a Check for optional argument to -s option
Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-12 15:38:24 +02:00
Lukas Fleischer
9f6678bc49 Update copyright ranges
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-01-12 08:40:30 +01:00
Lukas Fleischer
0d74c14fd1 Do not start the daemon more than once
Avoid starting multiple daemon instances if the --daemon argument is
passed and the daemon is already running. Terminate the already running
instance before spawning a new one instead.

Suggested-by: Vlad Glagolev <scm@vaygr.net>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-10-19 18:19:02 +02:00
Lukas Fleischer
9ef5fe2191 Always use memory management wrappers
Use mem_*() wrappers instead of directly accessing libc functions when
allocating/deallocating memory.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-10-13 19:51:43 +02:00
Lukas Fleischer
07954626c6 Support format strings when dumping imported items
In commit 3eae7ce (Add --list-imported command line option, 2016-01-12),
we added an option to print the hashes of imported items to stdout.
Extend this command line option such that it dumps the items using the
specified formatting strings. With the new behavior it is, for example,
easier to check items for import errors.

Also, rename the option from --list-imported to --dump-imported (it is
not part of any official release yet so we do not need to care about
backwards compatibility).

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-02-11 18:33:57 +01:00
Lukas Fleischer
62f04c3f9a Support format specifiers in grep mode
Honor --format-* parameters when using the -G operation. In the case of
recurring items, the first occurrence is used.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-02-05 19:09:36 +01:00
Lukas Fleischer
e9c8197e4e Refactor grep mode
Split io_save_{apts,todo}() into functions that write raw data to a file
and functions that write formatted items to stdout such that one can
easily extend the grep mode for format string support in a follow-up
commit.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-02-05 19:06:54 +01:00
Lukas Fleischer
978d24a9d2 Update copyright ranges
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-01-30 11:21:53 +01:00
Lukas Fleischer
03c4465baf Fix behavior of --todo with an optional argument
The previous behavior of --todo was to always only list uncompleted
items, unless zero was specified as additional argument. Restore and
document this behavior.

Also, fix two tests that failed because the --todo output is now sorted.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-01-28 18:37:31 +01:00
Lukas Fleischer
41389abd55 args.c: Revise help/usage/version output
Remove obsolete options from the help text, add new options, clean
everything up, cut translatable strings into atomic chunks.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-01-28 08:55:54 +01:00
Lukas Fleischer
6061fec01d Add a --daemon command-line parameter
When specifying --daemon, calcurse immediately forks and runs the
notification daemon in the background.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-01-28 00:04:00 +01:00
Lukas Fleischer
caee34449c Export item UIDs upon request
Add a new --export-uid command line option that adds each item's hash to
the UID property when exporting.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-01-15 18:25:05 +01:00
Lukas Fleischer
3eae7ce828 Add --list-imported command line option
When this option is used together with -i/--import, the object
identifiers of imported objects are printed to stdout.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-01-13 17:39:44 +01:00
Lukas Fleischer
c58087d591 Add command line option to suppress dialogs
Implement a -q/--quiet command line option to disable system dialogs
temporarily.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-01-13 17:39:44 +01:00
Lukas Fleischer
6d9129764b Implement filter mode
Add a new -F mode that is identical to -G but writes the result back to
the calcurse data files instead of stdout.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-01-13 17:39:44 +01:00
Lukas Fleischer
7f8c62bf57 Add an option to filter by object hash
Implement a new --filter-hash option to filter by object identifiers.
Each object having an identifier that has the specified pattern as a
prefix is matched. Patterns starting with an exclamation mark (!) are
interpreted as negative patterns.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-01-13 17:39:44 +01:00
Lukas Fleischer
0145ba12ec Use time_t instead of long in several places
Start converting some variables and return values to store times from
long to time_t.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2015-02-24 13:57:47 +01:00
Lukas Fleischer
7a631b2b63 Use date_sec_change() for adding day deltas
Fixes tests range-002.sh and search-001.sh.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2015-02-22 11:34:11 +01:00
Lukas Fleischer
a6c73232a8 Use LONG_MAX for invalid dates in parse_datearg()
We cannot use -1 here since negative values are valid dates.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2015-02-22 11:34:11 +01:00
Lukas Fleischer
9ef427693b Update copyright ranges
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2015-02-07 11:42:20 +01:00
Lukas Fleischer
a12833ec08 Handle dates past January 19th, 2038
Try to support dates past year 2038 on systems with 64-bit time_t.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2015-02-07 09:52:36 +01:00
Lukas Fleischer
8553a99161 Add io_load_data() wrapper
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-10-10 01:38:25 +02:00
Lukas Fleischer
aca92e619d Fix parsing of times in parse_datetimearg()
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-09 15:43:08 +02:00
Lukas Fleischer
519107dc47 Extend date formats for filters
Allow for specifying both date and time in all dates and date ranges
used in filters.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-09 12:56:13 +02:00
Lukas Fleischer
e1af76eb8d Add --filter-{start,end}-range
These are shorthands for --filter-start-from/--filter-start-to and
--filter-end-from/--filter-end-to.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-08 23:57:52 +02:00
Lukas Fleischer
c2a9292bf4 Add a grep mode
This allows for printing a subset of the items in the data files by
using filters.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-07 16:34:48 +02:00