1054 Commits

Author SHA1 Message Date
Lukas Fleischer
9ef427693b Update copyright ranges
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2015-02-07 11:42:20 +01:00
Lukas Fleischer
4350494d3b Add a couple of shorthands to parse_date()
We now understand the shorthands "today", "yesterday", "tomorrow" and
"now" which might come in useful sometimes.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2015-02-07 11:37:15 +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
4fd8f0b11e Only werase() calendar if month is changed
Optimize the monthly view by only erasing the window content when a new
month is selected.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-10-17 22:40:02 +02:00
Tim Hentenaar
7f62fb185c Let SIGUSR1 trigger a reload
In an effort to better integrate the import process with external
applications, it's desirable to have a mechanism by which external
programs can trigger a reload of calcurse's data.

This patch adds that functionality via SIGUSR1. The reload request is
handled in the main loop. When the user is currently entering data, the
request is delayed until the main loop is re-entered.

Signed-off-by: Tim Hentenaar <tim@hentenaar.com>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-10-10 09:33:57 +02:00
Lukas Fleischer
7f06c25230 Factor out item reload code
Adds a new function io_reload_data() which can be used to reload all
appointments and TODO items.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-10-10 01:47:27 +02: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
76f151ff37 Correctly parse all types of iCal durations
This was supposed to be fixed in 6ca2535 (ical.c: Simplify and fix
ical_durtime2long(), 2014-07-28) but some cases were not covered.

Reported-by: Håkan Jerning <jerning@home.se>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-18 15:18:11 +02:00
Lukas Fleischer
0a2c4d20fe Retain comments in descriptions and config values
Comments should only be stripped if they start at the beginning of a
line. We do not want to chop off an TODO item description or a
configuration value.

Reported-by: Håkan Jerning <jerning@home.se>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-18 12:27:22 +02:00
Lukas Fleischer
f3fe3c818c Gracefully handle all day events in iCal imports
Do not create two events when importing an event that lasts an entire
day.

Reported-by: Jörn Tillmanns <tillmanns@tuxzone.org>
Reported-by: Håkan Jerning <jerning@home.se>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-18 12:20:09 +02:00
Lukas Fleischer
bcc820ea74 Handle CRLF line endings in iCal files
RFC 2445 mentions that CRLF line endings may be used in iCal files.
Handle them properly when importing.

Reported-by: Håkan Jerning <jerning@home.se>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-18 11:37:41 +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
Lukas Fleischer
9f24adfded args.c: Reword error messages
Use the same error message if option arguments have the same data type
and always add the violating value.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-06 16:26:45 +02:00
Lukas Fleischer
8ead883c32 io.c: Error out on non-existent calendar file
Show an error message and die if the user specified a non-existent
custom calendar file. This fixes some random hangs when calcurse is used
in non-interactive mode within scripts.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-06 15:59:15 +02:00
Lukas Fleischer
f9208c0b3d Use backwards-compatible out format for queries
Print TODO items before appointments in query outputs and add an empty
line between the list of TODO items and the list of appointments. This
is how items were printed before the big parser refactoring.

Also, add a test to ensure we do not unintentionally change that format
in the future.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-06 15:48:02 +02:00
Lukas Fleischer
c2dc3109ae Do not use filters in GC or import mode
Filtering items when running garbage collection or when importing data
might result in data loss, so simply ignore filters here.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-06 12:08:14 +02:00
Lukas Fleischer
aa682f7a11 Rework command line argument handling
Add a new range query mode (--days) and refactor the command line
argument parser.

Note: This slightly changes the behavior of some command line
parameters, since date arguments no longer use the input date format
from the configuration file!

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-06 12:08:14 +02:00
Lukas Fleischer
1878b7c4b0 Allow for filtering TODO items
The item filters now apply to both appointments and TODO items. Also,
add a new type mask "todo" and the following new filter options:

* --filter-priority
* --filter-completed
* --filter-uncompleted

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-06 12:08:14 +02:00
Lukas Fleischer
86553f35fe Add a query mode
Add a new parameter -Q that can be used to print all appointments inside
a given query range, followed by all TODO items. The date range can be
specified using the --from and --to arguments. The start date defaults
to the current day, the end date defaults to the day after the start
date if not specified.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-06 12:08:14 +02:00
Lukas Fleischer
9ce5861468 Add pattern filter option
This adds a new item filter option --filter-pattern and removes the
whole -S parameter logic, while making -S an alias for --filter-pattern.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-06 12:08:14 +02:00
Lukas Fleischer
bfe73d0e5d Add item filters
This adds the following filter options that allow for restricting the
set of items that are read from the appointments file:

* --filter-type
* --filter-start-from
* --filter-start-to
* --filter-start-after
* --filter-start-before
* --filter-end-from
* --filter-end-to
* --filter-end-after
* --filter-end-before

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-06 12:08:14 +02:00
Lukas Fleischer
ea900a863a Set default panel before showing system dialogs
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-03 23:51:10 +02:00
Lukas Fleischer
c093fcdfbf Make compact mode and default panel configurable
Create configuration entries for these (currently undocumented) options
which were added in 4d0c095 (Add compact panels support, 2012-11-25) and
in 660eef8 (Add configuration option to set a default panel,
2012-11-24).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-03 23:51:08 +02:00
Lukas Fleischer
0d481aa00c Document the reload feature
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-28 13:12:42 +02:00
Lukas Fleischer
b32adc8b7b Show system dialog after reloading items
Suggested-by: Håkan Jerning <jerning@home.se>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-28 12:51:14 +02:00
Lukas Fleischer
6aa21da8c6 ical.c: Parse multiple exception rules properly
There can be multiple EXDATE lines per event. Parse them correctly
instead of making the last line overwrite the previous ones.

Reported-by: Håkan Jerning <jerning@home.se>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-28 12:43:00 +02:00
Lukas Fleischer
6ca2535f5e ical.c: Simplify and fix ical_durtime2long()
Correctly parse all types of durations. Before this change, durations
without an hour or minute component were not parsed properly.

Reported-by: Håkan Jerning <jerning@home.se>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-28 12:43:00 +02:00
Lukas Fleischer
a366b5c2ba io.c: Remove superfluous space from message
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-28 12:43:00 +02:00
Lukas Fleischer
132cf86a6f ui-day.c: Reorganize some free() operations
Fixes regressions introduced in 21fc7a4 (Replace several uses of
snprintf() by asprintf(), 2014-07-21).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-27 11:05:12 +02:00
Lukas Fleischer
d6eee30215 Do not error out when calling xfree(NULL)
Calling free() with NULL as parameter is perfectly safe, no need to
error out here.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-27 10:58:03 +02:00
Lukas Fleischer
3fe9942017 Fix find_basedir() and display_help()
Fixes two regressions introduced in 21fc7a4 (Replace several uses of
snprintf() by asprintf(), 2014-07-21).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-27 10:58:00 +02:00
Lukas Fleischer
f52ca8fe12 config.c: Rework configuration serialization
Avoid preallocating buffers on the stack, use dynamic memory allocation
instead.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-22 12:08:41 +02:00
Lukas Fleischer
66ce00153b Refactor new_tempfile()
Avoid preallocating buffers on the stack, use dynamic memory allocation
instead. Also, change the semantics of new_tempfile() so that it returns
the full name of the temporary file and fix all call sites.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-22 11:47:18 +02:00
Lukas Fleischer
21fc7a4b74 Replace several uses of snprintf() by asprintf()
Use asprintf() in some cold code paths. While allocating memory on the
heap is a bit slower, using asprintf() is a bit more memory efficient
and less prone to buffer overflow errors.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-22 11:47:14 +02:00
Lukas Fleischer
6203966fbf Add vasprintf() and asprintf()
The new utils.c functions vasprintf() and asprintf() are analogs to
sprintf() and vsprintf(). However, instead of requiring a buffer that is
large enough to hold the output data, the functions allocate a string
and return a pointer to it.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-22 11:06:54 +02:00
Lukas Fleischer
9d8d0c18b0 Small code cleanups
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-18 17:19:37 +02:00
Lukas Fleischer
919a40f561 Use wins_set_bindings() for the configuration menu
Make use of the general key binding context switching implementation for
the configuration main menu.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-18 10:26:36 +02:00
Lukas Fleischer
035faa883b Make bindings always fill the whole status bar
Compute padding for key bindings in the status bar such that they use
all available space (without exceeding the given page size).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-18 09:51:13 +02:00
Lukas Fleischer
8d9e4c6102 Always fix selection in listbox_load_items()
Since commit 80a7267 (Fix selection in listbox_load_items(),
2014-07-18), listbox_fix_sel() is called if the selection is out of
range after loading the new set of items. However, we should *always*
fix the selection to make sure the selection doesn't move to a caption
row when reloading items.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-18 09:16:45 +02:00
Lukas Fleischer
e9d4d3c505 Do not use malloc() or xmalloc()
Use mem_malloc() instead which automatically picks the right
implementation depending on whether memory debugging is enabled or not.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-18 08:47:23 +02:00
Lukas Fleischer
58f6ac62aa Do not display dialog on periodic save
When periodic save is enabled, do not print the "The data files were
successfully saved" dialog every time io_save_cal() is called.

Reported-by: Håkan Jerning <jerning@home.se>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-18 08:41:45 +02:00
Lukas Fleischer
d0916ced78 Initialize prompt buffers in the configuration menus
malloc() does not make sure that the buffer is initialized to contain
all zeros. Initialize the buffer with the empty string.

Reported-by: Håkan Jerning <jerning@home.se>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-18 08:38:15 +02:00
Lukas Fleischer
80a7267f8c Fix selection in listbox_load_items()
Call listbox_fix_sel() after setting an initial selection in
listbox_load_items() to make sure we do not pick a caption row.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-18 08:30:09 +02:00
Lukas Fleischer
0ad6ff74df keys.c: Merge keydef and binding_labels
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-17 21:16:33 +02:00
Lukas Fleischer
76563c9b90 Rework key binding context switching
Store key binding contexts using another data structure to optimize
space usage and execution time.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-17 21:08:55 +02:00
Lukas Fleischer
8f28b8f9cc Pause notification thread when reloading items
Prevent the notification thread from accessing data structures for
appointments and todo items while we are recreating them.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-17 20:12:27 +02:00
Lukas Fleischer
ae7d2d4c6b Only run the merge tool on files with differences
If the backup file and the data file are equal, there is no need to run
the merge tool.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-17 12:03:34 +02:00