1717 Commits

Author SHA1 Message Date
Lukas Fleischer
8ab3106f6b git-version-gen: Add default version
Instead of bailing out early in the build process when neither a version
file nor a valid Git repository is detected, use a hardcoded default
version string. This fixes building from shallow clones or Git
snapshots.

Also fixes GitHub issue #22.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-08 22:35:36 +02:00
Lukas Fleischer
2fe9c7efce Reload data after resolving save conflict
After resolving a save conflict with the merge tool, we need to reload
the data files to import the result of the conflict resolution.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-08 21:23:25 +02:00
Lukas Fleischer
e943a8a4db Unset modification flag after merging
Turn off the local modification flag to avoid a bogus warning when
reloading the data files immediately after the merge process.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-08 21:22:22 +02:00
Lukas Fleischer
f69698569f Recompute hashes after saving
After saving the data files, we need to recompute and store the hashes
to make sure the updated contents is reflected.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-08 21:21:45 +02:00
Lukas Fleischer
380124c7a2 Factor out hash computation
Move code to compute the hash of a data file to a separate function.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-08 21:21:11 +02:00
Lukas Fleischer
7a0134204e Use a shared input/output mutex
Replace the save mutex with a common mutex, which is locked whenever
read or write operations on the data files are performed. Also, since
this mutex is an implementation detail, mark the locking functions
static and remove them from the header file.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-08 21:08:54 +02:00
Lukas Fleischer
0f3d1988bf Interrupt periodic save when launching process
To avoid interactions between the periodic save thread and external
processes, stop the periodic save thread before launching an external
program and restart the thread as soon as the program is terminated.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-08 21:08:54 +02:00
Lukas Fleischer
57dd3d6b66 Only reload if data files were changed
Instead of blindly reloading data in io_reload_data(), compare the
stored hashes of the data files with hashes of the current file contents
and only reload if any of the hashes differs.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-08 21:08:54 +02:00
Lukas Fleischer
ba85d9b6f5 Factor out check for external modifications
Move the check to compare the stored hashes of the data files with the
current hash to a separate function. This makes the code easier to read
and reusable.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-08 21:08:54 +02:00
Lukas Fleischer
9137590e7a Do not blindly overwrite files when saving
When reading the data files, compute a cryptographic hash of the file
contents and store it. When saving the files later, ensure that the hash
still matches the current file contents. If it does not, show a warning
to the user and ask whether she wants to execute the merge tool.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-08 21:08:53 +02:00
Lukas Fleischer
fb1524b4e2 Use .new as file extension when merging
Using the file name extension .sav and naming the variables "backup" is
slightly misleading, since the affected files actually contain the
updated content and not some old snapshot. Use the term "new" instead.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-08 21:08:53 +02:00
Lukas Fleischer
e5a824e576 Factor out merge routine
Move the code, which runs the merge tool with current and updated data
files, to a separate function to make it reusable.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-08 21:08:53 +02:00
Lukas Fleischer
74d90e7cbc Add CALCURSE_{EDITOR,PAGER,MERGETOOL} environment variables
Support environment variables specific to calcurse to override $EDITOR,
$PAGER and $MERGETOOL.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-08 21:08:53 +02:00
Lars Henriksen
d20f9a5d2e Make the day heading position configurable
The date at the top of the appointments list may be positioned either to
the left, in the middle or to the right. Default is to the right. Can be
configured from the general options menu.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-08 21:08:53 +02:00
Lars Henriksen
172efd7179 Remove phase of moon feature
The computation never really worked before and it seems like the feature
is not very helpful, sometimes even confusing (see GitHub issue #21).

The macro ISLEAP is moved to calcurse.h.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-08 21:08:53 +02:00
Lars Henriksen
90fe21af88 Fix phase of moon calculation
The reported phase was often one day early because calculations were
based on midnight. For full and new moon this is changed to noon. For
first and last quarter a direct check of the appearance of the half moon
during the selected day is performed.

Comments are relocated and expanded.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-08 21:08:53 +02:00
Lars Henriksen
3095bf4214 Add missing string initialization
When introducing the fmt_day_heading() function in commit d56cc7a (Make
heading in appointments panel configurable, 2017-08-19), we forgot to
initialize the dynamic string. This resulted in calling mem_free() with
a garbage pointer, potentially resulting in a segmentation fault. Fix
this by calling string_init() before using the string.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-04 16:34:19 +02:00
Lukas Fleischer
2e584f03e6 Replace remaining uses of wgetch() by keys_wgetch()
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-03 16:37:35 +02:00
Lukas Fleischer
53f0f1d2e3 Add a function to wait for any key press
Introduce a new function keys_wait_for_any_key() and use it instead of
wgetch() whenever the return value is discarded.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-03 16:37:35 +02:00
Lukas Fleischer
8373ecfe51 Improve default selection when editing key bindings
When adding a new key binding, automatically select the new binding.
When removing a key binding, keep the selection index (unless the last
binding of a row is removed).

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-03 15:51:01 +02:00
Lukas Fleischer
6521d8cc0a Use strncpy() properly in general_option_edit()
Always use strncpy() to copy strings between fixed-size buffers and pass
the buffer size as maximal length parameter.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-03 09:31:33 +02:00
Lukas Fleischer
578091f051 Add support for UTF-8 key bindings
A new function keys_wgetch() reads full UTF-8 characters instead of
single ASCII characters only.

Key bindings for regular ASCII characters are stored in a hash map while
the actions of keys with higher code points are stored in a linked list
for space efficiency.

The key serialization methods are updated to handle UTF-8 characters as
well; extended UTF-8 characters (characters not in the ASCII range) are
serialized by using the hexadecimal representation of the corresponding
code points (e.g. "U+00E4").

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-30 16:39:23 +02:00
Lukas Fleischer
8544e4a570 Rename keys_getch() to keys_get()
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-30 16:26:10 +02:00
Lukas Fleischer
273e32d43d Factor out UTF-8 code point decoding
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-30 16:17:28 +02:00
Lukas Fleischer
6cb26c2f27 Relocate HANDLE_KEY macros
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-30 16:15:39 +02:00
Quentin Hibon
04fb4caf8f Implement CTRL-U in getstring()
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-29 20:14:39 +02:00
Lars Henriksen
26aeddd490 Use nl_langinfo() for month and day names
Use the locale setting to fetch the month names and abbreviated day
names.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-28 07:30:38 +02:00
Lukas Fleischer
fad4a5f4e0 Add basic Travis CI support
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-28 07:30:38 +02:00
Lars Henriksen
3efb3e42c9 Remove extra star from recurrent appointments
In the appointments panel, an appointment has a '-' to mark the time
span, and the description on the following line is slightly indented.
When the appointment is changed into a recurrent one, the '-' is changed
to a '*', making it easily distinguishable but the description also gets
a '*', thus breaking the pattern. Drop the extra '*'.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-28 07:30:38 +02:00
Lars Henriksen
e12875b420 Remove some leftovers from the past
Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-28 07:30:38 +02:00
Lukas Fleischer
bebc46fb63 Rename README to README.md
Make sure that the Markdown syntax already used in the README file is
recognized by repository browsers such as cgit or GitHub.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-28 07:30:38 +02:00
Lars Henriksen
d56cc7acfe Make heading in appointments panel configurable
Add a new configuration variable format.dayheading to set the format of
the date displayed at the top of the event and appointment list.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-28 07:30:38 +02:00
Lukas Fleischer
550a2e9379 Extend strings API for formatted dates
Add two new functions string_catftime(), resp. string_strftime(), which
can be used to append, resp. print, a formatted date to a dynamic
string.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-28 07:30:38 +02:00
Lars Henriksen
0c63b4661f Make the selected day in the calendar stand out
Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-28 07:30:38 +02:00
Lukas Fleischer
8d85a58a26 ical-002: Fix broken test
In the expected output, the punctual appointment (lasting one second in
the iCal data) was missing. The test was not failing because calcurse
did not print the missing item due to a bug. This bug was fixed by
7924315 (Fix support for punctual appointments at 00:00, 2017-08-28),
making the test case fail. Fix the test case as well such that
everything behaves as expected again.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-28 07:30:15 +02:00
Lukas Fleischer
7924315bfb Fix support for punctual appointments at 00:00
When checking whether an appointment belongs to a given day in
apoint_inday(), the return value was 0 if the end time of the
appointment matched 00:00 on that day (because we do not want to include
appointments starting on the day before and lasting until midnight).
However, this means that punctual appointments at 00:00 were not
included in any day. Fix the apoint_inday() logic to take this into
consideration.

Fixes GitHub issue #39.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-28 07:06:06 +02:00
Lukas Fleischer
e76b96c9ff calcurse-caldav: Specify depth in the initial request
For the initial calendar-query request, set the Depth header to 1. This
is required because according to RFC 4791, the depth value defaults to 0
if no header is specified.

Fixes GitHub issue #38.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-28 06:42:53 +02:00
Lars Henriksen
b36dd2e614 Fix empty warning box when key is already in use
When adding a key already in use for another action, a warning box is
displayed. The text length is limited by the window width through the
use of strncpy(). If the limit is exceeded, the string will have no null
termination, resulting in unpredictable behaviour.

A similar problem in fatalbox() is fixed as well.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-12 15:40:02 +02:00
Lars Henriksen
53db74ab34 Fix fatal error when using the help command
Check that an action is defined for the key.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-12 15:38:55 +02: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
43cd40e8ce Include stdarg.h when using variable argument lists
Fixes GitHub issue #36.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-07-28 16:09:43 +02:00
Lukas Fleischer
5722d2ea4c Fix segmentation fault when changing colors
The pair_content() function can be used to retrieve a color pair. The
foreground and the background color numbers are written to addresses
specified by the second and third parameters. While both parameters were
optional in older ncurses implementations (making it possible to pass
NULL pointers if the one does not care about either foreground or
background color), recent implementations seem to assume that both
parameters are valid pointers. Thus, instead of passing NULL, we need to
pass a pointer to a dummy variable when we do not care about the
background color.

Partly fixes GitHub issue #31.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-07-28 16:02:46 +02:00
Lukas Fleischer
5aa7a0962a Fix another error in the notification code
In addition to checking whether a recurrent item predates the current
next appointment, we need to check that the actual occurrence of the
item predates the current appointment as well.

Fixes GitHub issue #26.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-02-11 11:50:51 +01:00
Lukas Fleischer
2084f353e3 Fix notification of recurrent appointments
The recur_apoint_starts_before() filter function expected the second
parameter to be passed by value, whereas its only caller passed the
value by reference. For consistency with apoint_starts_after(), change
the signature and the implementation of recur_apoint_starts_before()
such that the parameter is passed by reference.

Also, add a comment to the only caller of recur_apoint_starts_before()
to clarify on why recur_apoint_starts_before() is used.

Fixes GitHub issue #25.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-02-09 08:43:32 +01:00
Lukas Fleischer
ed6035afb1 Do not read past NUL character in ical_get_value()
Make sure we never read beyond the end of the buffer, even if the
terminating quote of a quoted string is missing.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-02-08 07:32:35 +01:00
Lukas Fleischer
e4e2e0eb20 Gracefully parse iCal parameters with colons
According to RFC 5545, iCalendar content lines can have optional
parameters, which can be quoted strings containing colons (":"). Make
sure that such colons are not interpreted as delimiters marking the
start of the value string.

Also, add a test case that covers this corner case.

Reported-by: Håkan Jerning <jerning@home.se>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-02-07 21:54:05 +01:00
Lukas Fleischer
3375fddb4e Release 4.2.2
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-01-14 14:09:46 +01: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
e2086c426c calcurse-caldav: Use right diffs when synchronizing
Some parameters where swapped accidentally when reworking the diff
computation in c8d3d87 (calcurse-caldav: Compute diffs before
synchronizing, 2016-12-13) such that the synchronization functions were
working with incorrect diffs since that commit. Exchange the parameters
again to fix this.

Reported-by: Guillaume Laurès <guillaume@lauresfamily.fr>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-12-15 18:41:24 +01:00
Lukas Fleischer
6a80e156dd calcurse-caldav: Fix scrambled comment
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-12-13 18:47:38 +01:00