1614 Commits

Author SHA1 Message Date
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
Lukas Fleischer
7920e761c9 Reintroduce key bindings in configuration menus
The key bindings display in the status bar was removed from the general
options menu in bd182fb (Use generic list box for general options,
2014-05-13) and from the notification options menu in 5eea05a (Use
generic list box for notification options, 2014-05-13). Display the new
key bindings to use for navigation.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-17 09:08:46 +02:00
Lukas Fleischer
6792a2e204 Split out code to set bindings
Split wins_status_bar() into wins_set_bindings(), wins_update_bindings()
and wins_status_bar(). This allows for using wins_set_bindings() to set
custom key bindings to be displayed.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-17 08:49:16 +02:00
Lukas Fleischer
33414c6fa1 wins.c: Drop NB_*_CMDS
Store the current number of commands in a static variable and drop the
NB_*_CMDS variables which we outdated anyway.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-17 08:41:36 +02:00
Lukas Fleischer
71234ec0bd Refactor wins_launch_external()
Allow for passing an arbitrary number of arguments. This also allows us
to remove wins_launch_external2() and use wins_launch_external() at all
call sites instead.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-16 23:53:30 +02:00
Lukas Fleischer
b37ed2fcc8 Avoid cancelling the save thread during saving
Ensure that we never cancel the periodic save thread when it currently
saves the configuration and data files.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-16 23:39:07 +02:00
Lukas Fleischer
5aec540895 Allow for merging data files when reloading
This allows for merging the (unsaved) items with the items from the data
files when invoking the reload operation. To this end, an external merge
tool (defaults to vimdiff) is used.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-16 23:31:31 +02:00
Lukas Fleischer
e93030befb Add a cleanup handler for the notify main thread
Make sure we do not leave behind unusable mutexes when calling
pthread_cancel().

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-16 23:19:10 +02:00
Lukas Fleischer
e6b0282a18 day.c: Fix typo in error message
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-16 20:09:29 +02:00
Lukas Fleischer
46d260a438 Warn when reloading with unsaved modifications
Since the reload operation overwrites all changes, warn before reloading
if there are unsaved modifications.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-16 20:05:21 +02:00
Lukas Fleischer
b36d253dce Automatically select first item in list boxes
If the selection is empty during listbox_load_items() and there is at
least one item in the list, automatically select the first item.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-16 16:13:07 +02:00
Lukas Fleischer
6550591b08 Add a key binding to reload appointments and todos
This allows for reloading the appointment and todo item files without
having to restart calcurse.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-16 16:03:26 +02:00
Lukas Fleischer
f7f49da17c Initialize linked list for recurrent items
When switching to the generic linked list implementation for recurring
events in 9fab248 (Use generic lists for recurring apointments and
events., 2011-04-16), no initialization routine for the list of
recurring events was added. Fix this and properly initialize the list on
startup.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-16 15:52:33 +02:00
Lukas Fleischer
bd784775aa Release 3.2.1
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-09 00:40:37 +02:00
Lukas Fleischer
e33f53aad5 Do not highlight items on inactive windows
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-09 00:38:51 +02:00
Lukas Fleischer
cac973fee3 Load todo items on startup
Reload (and show) items into the list box after reading data files.

Reported-by: BARE Willy sprl <barewillysprl@euphonynet.be>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-09 00:33:01 +02:00
Lukas Fleischer
00ceca6000 Release 3.2.0
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-08 15:53:06 +02:00
Lukas Fleischer
490e5a4e1d po/: Translation updates from Transifex
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-08 15:52:41 +02:00
Lukas Fleischer
63141268e0 test/: Remove temporary errors file in tests
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-08 15:47:09 +02:00
Lukas Fleischer
e97c32563f test/Makefile.am: Add missing test data
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-08 15:28:54 +02:00
Lukas Fleischer
7904af5d9d Implement test initialization properly
Make test-init.sh work even if tests are executed from another
directory.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-08 15:12:37 +02:00
Lukas Fleischer
8aaaf18268 src/Makefile.am: Add vector.h to source files
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-08 13:53:45 +02:00
Lukas Fleischer
f338302d86 .tx/config: Remove trailing slash from URI
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-08 13:53:37 +02:00
Lukas Fleischer
a32f6b008a Make sure that tmppath is always NULL-terminated
Fixes GitHub issue #5.

Reported-by: dcb314
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-08 13:24:25 +02:00
Lukas Fleischer
936d5f139f ical.c: Remove newlines from item summaries
Newline characters are not allowed in calcurse item descriptions.
Replace any newlines in iCal summary lines with spaces.

Fixes GitHub issue #6.

Reported-by: Jonathan McCrohan <jmccrohan@gmail.com>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-08 13:14:08 +02:00
Jack Nagel
82aa3e3f43 Define _DARWIN_C_SOURCE to get SIGWINCH on OS X
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-08 13:01:01 +02:00
Lukas Fleischer
9dc36589ae Fix SHA1 calculation of long notes
sha1_update() modifies the input data, so we need to duplicate the input
before calculating the hash. Otherwise, input data longer than 64 bytes
will be garbled.

Reported-by: Hakan Jerning <jerning@home.se>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-08 12:54:03 +02:00
Lukas Fleischer
0529b864b0 Fix segmentation fault
This adds some more accurate checks to avoid a segmentation fault that
occurred when accessing a nonexistent item.

Fixes GitHub issue #7.

Reported-by: Bromind <martin.vassor@hotmail.fr>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-06-25 12:35:43 +02:00
Lukas Fleischer
0b46ad4faa Avoid blank space after the last list box item
Automatically scroll down the list box when resizing creates some blank
space below the list of items.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-19 21:43:27 +02:00
Lukas Fleischer
990897b2f0 Resize panels properly
Rewrite the panel resize code and remove the code that reinitializes the
caption and the selected item when the window is resized.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-19 10:54:50 +02:00
Lukas Fleischer
e026481f11 listbox_resize(): Avoid segmentation fault
Only try to fix the visible region if an item is selected.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-19 10:37:21 +02:00
Lukas Fleischer
d971d7aa35 Fix calendar centering
Adjust the positions of the weekly and monthly views inside the calendar
panel.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-19 10:25:58 +02:00
Lukas Fleischer
7e76d617ab Use an enum for the type field of day_item
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18 11:24:04 +02:00
Lukas Fleischer
4cd2fd36d5 Add default cases to some switch statements
This squelches several compiler warnings.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18 11:22:22 +02:00