summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2014-07-22Replace several uses of snprintf() by asprintf()Lukas Fleischer
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-22Add vasprintf() and asprintf()Lukas Fleischer
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-18Small code cleanupsLukas Fleischer
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-18Use wins_set_bindings() for the configuration menuLukas Fleischer
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-18Make bindings always fill the whole status barLukas Fleischer
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-18Always fix selection in listbox_load_items()Lukas Fleischer
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-18Do not use malloc() or xmalloc()Lukas Fleischer
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-18Do not display dialog on periodic saveLukas Fleischer
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-18Initialize prompt buffers in the configuration menusLukas Fleischer
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-18Fix selection in listbox_load_items()Lukas Fleischer
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-17keys.c: Merge keydef and binding_labelsLukas Fleischer
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-17Rework key binding context switchingLukas Fleischer
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-17Pause notification thread when reloading itemsLukas Fleischer
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-17Only run the merge tool on files with differencesLukas Fleischer
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-17Reintroduce key bindings in configuration menusLukas Fleischer
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-17Split out code to set bindingsLukas Fleischer
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-17wins.c: Drop NB_*_CMDSLukas Fleischer
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-16Refactor wins_launch_external()Lukas Fleischer
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-16Avoid cancelling the save thread during savingLukas Fleischer
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-16Allow for merging data files when reloadingLukas Fleischer
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-16Add a cleanup handler for the notify main threadLukas Fleischer
Make sure we do not leave behind unusable mutexes when calling pthread_cancel(). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-16day.c: Fix typo in error messageLukas Fleischer
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-16Warn when reloading with unsaved modificationsLukas Fleischer
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-16Automatically select first item in list boxesLukas Fleischer
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-16Add a key binding to reload appointments and todosLukas Fleischer
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-16Initialize linked list for recurrent itemsLukas Fleischer
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-09Do not highlight items on inactive windowsLukas Fleischer
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-09Load todo items on startupLukas Fleischer
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-08src/Makefile.am: Add vector.h to source filesLukas Fleischer
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-08Make sure that tmppath is always NULL-terminatedLukas Fleischer
Fixes GitHub issue #5. Reported-by: dcb314 Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-08ical.c: Remove newlines from item summariesLukas Fleischer
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-08Define _DARWIN_C_SOURCE to get SIGWINCH on OS XJack Nagel
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-08Fix SHA1 calculation of long notesLukas Fleischer
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-06-25Fix segmentation faultLukas Fleischer
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-05-19Avoid blank space after the last list box itemLukas Fleischer
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-19Resize panels properlyLukas Fleischer
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-19listbox_resize(): Avoid segmentation faultLukas Fleischer
Only try to fix the visible region if an item is selected. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-19Fix calendar centeringLukas Fleischer
Adjust the positions of the weekly and monthly views inside the calendar panel. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18Use an enum for the type field of day_itemLukas Fleischer
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18Add default cases to some switch statementsLukas Fleischer
This squelches several compiler warnings. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18day_item_add_exc(): Fix unwanted fall-throughLukas Fleischer
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18Reintroduce heading and separator in appointmentsLukas Fleischer
This re-introduces the heading (showing the POM and the current date) as well as the separating line between events and appointments. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18Add support for caption rows in list boxesLukas Fleischer
This adds support for rows that cannot be selected. Such rows can be used for section headings and the like. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18Remove unused functions border_{,no}color()Lukas Fleischer
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18ui-day: Large-scale refactoringLukas Fleischer
Use the generic list box implementation for the appointments panel. This results in some major changes to how the items are printed. Note that this temporarily removes the heading showing the POM and the date as well as the separating line between events and appointments. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18Store appointments for the current day in a vectorLukas Fleischer
This allows for more efficient access to items at specific positions. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18Add a vector implementationLukas Fleischer
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18ui-calendar: Use scroll window implementationLukas Fleischer
Make use of the generic scroll window implementation for the calendar view. Note that this is useful despite the panel not needing a scroll bar, since the scroll window functions can be used to draw the panel border and take care of relative positions. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18ui-todo: Large-scale refactoringLukas Fleischer
This is a complete overhaul of the TODO list user interface. The new implementation uses the generic list box panel. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18Add support for drawing highlighted decorationLukas Fleischer
This allows for drawing selected scroll windows and list boxes with a highlighted border. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>