aboutsummaryrefslogtreecommitdiffstats
path: root/src/day.c
Commit message (Collapse)AuthorAgeFilesLines
* Simplify day storageLars Henriksen2019-05-221-24/+1
| | | | | | | | | | | The function day_process_storage() is a wrapper for day_store_items(). It has an unused second argument, and is only used twice to load the selected day. It has been removed. A new function, get_slctd_day(), is the equivalant of get_today() and replaces the very awkwardly named ui_calendar_get_slctd_day_sec(). Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix initialization of the day_items vectorLars Henriksen2019-05-221-0/+1
| | | | | | | | | | | | | | | | This patch fixes all failings tests, but one, in PR #193. Until now the missing initialization of day_items_nb has caused no problems, because the variable was assigned to (=) before being used. In the Multiple days implementation it is repeatedly increased (+=) in a loop without being initialized first. Indeed, this may considered an easily fixed bug. But the initialization really belongs in day_init_vector() so that the call day_item_count(0) returns 0 if done right after the call day_init_vector(). The bug only shows up in command line mode because day_items_nb is not used in interactive mode. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Overflow check for 32-bit types onlyLars Henriksen2019-01-181-2/+29
| | | | | | | Included is a check of the 'until' date for pasted recurrent items. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Use time_t for system time valuesLukas Fleischer2019-01-141-14/+14
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* DST fix: daylength v. DAYINSECLars Henriksen2018-11-101-1/+1
| | | | | | | | | | | | | | | The number of seconds in a day and daylength in seconds differ when Daylight Saving Time is in effect on two days of the year. The day when DST takes effect is 23 hours long, and the day when DST ends is 25 hours long. In the latter case the date changing thread wóuld enter a loop in the last hour before midnight (in the former it would set the date an hour too late). The next midnight is calculated through mktime(), invoked by date2sec(). Wrong daylength prevented appointments from being stored in the day vector and caused them to be displayed wrongly in the appts panel. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Remove extra star from recurrent appointmentsLars Henriksen2017-08-281-2/+1
| | | | | | | | | | | 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>
* Update copyright rangesLukas Fleischer2017-01-121-1/+1
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix out-of-bounds memory accessLukas Fleischer2016-09-281-2/+7
| | | | | | | Do not try to access freed day items. This also fixes unexpected selection changes after modifying appointments or events. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Highlight days with non-recurrent itemsLukas Fleischer2016-06-271-12/+15
| | | | | | | | Use a different color for days with non-recurrent items in the calendar panel. This makes it possible to easily spot days that actually contain appointments. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Refactor UTF-8 choppingLukas Fleischer2016-02-261-17/+8
| | | | | | | Add a function that makes sure a string does not exceed a given display size. If the string is too long, dots ("...") are appended. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Make automatic selection of appointments/events smarterLukas Fleischer2016-02-161-0/+15
| | | | | | | Keep item selection when an item is moved (e.g. by changing the start time or description). Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Improve ordering of appointments/eventsLukas Fleischer2016-02-151-3/+19
| | | | | | | | * Order by start time first. * Order items with the same start time by priority. * Order items with the same start and priority by description. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Update copyright rangesLukas Fleischer2016-01-301-1/+1
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Do not mark slice of end time busyLukas Fleischer2015-04-111-4/+18
| | | | | | | | In weekly view, when computing busy slices, do not fill a slot that is only hit by the end time of an appointment. Suggested-by: Håkan Jerning <jerning@home.se> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix range checks in day_chk_busy_slices()Lukas Fleischer2015-04-101-5/+8
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix slice computation of recurring appointmentsLukas Fleischer2015-04-101-2/+7
| | | | | Reported-by: Håkan Jerning <jerning@home.se> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use time_t instead of long in several placesLukas Fleischer2015-02-241-20/+16
| | | | | | | Start converting some variables and return values to store times from long to time_t. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Update copyright rangesLukas Fleischer2015-02-071-1/+1
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add pattern filter optionLukas Fleischer2014-08-061-22/+10
| | | | | | | 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>
* day.c: Fix typo in error messageLukas Fleischer2014-07-161-2/+2
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix segmentation faultLukas Fleischer2014-06-251-2/+4
| | | | | | | | | | 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>
* Add default cases to some switch statementsLukas Fleischer2014-05-181-2/+13
| | | | | | This squelches several compiler warnings. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* day_item_add_exc(): Fix unwanted fall-throughLukas Fleischer2014-05-181-0/+2
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Reintroduce heading and separator in appointmentsLukas Fleischer2014-05-181-16/+20
| | | | | | | 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>
* ui-day: Large-scale refactoringLukas Fleischer2014-05-181-82/+24
| | | | | | | | | | 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>
* Store appointments for the current day in a vectorLukas Fleischer2014-05-181-17/+19
| | | | | | This allows for more efficient access to items at specific positions. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add -l/--limit optionWilliam Pettersson2013-07-161-1/+4
| | | | | | | | Adds the -l/--limit command line option. Limits the number of appointments and/or ToDo items displayed. Signed-off-by: William Pettersson <william.pettersson@gmail.com> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix a couple of translatable stringsLukas Fleischer2013-05-141-2/+2
| | | | | | | | * Remove space before punctuation. * Use "TODO" instead of "ToDo". * Strip some formats to make sure lines are <=80 characters wide. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* display_item_date(): Support punctual appointmentsLukas Fleischer2013-05-141-2/+3
| | | | | | | | Display appointments having the same starting date as ending date using a specific format that hides the end time ("12:00" instead of "12:00 -> 12:00"). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Refactor display_item_date()Lukas Fleischer2013-05-141-12/+6
| | | | | | | | | | Replace nested case differentiations by initializing every single character for each flag separately and joining all characters afterwards. This makes it much easier to extend the function later. Note that the same approach is already used in display_item(). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use tabs instead of spaces for indentationLukas Fleischer2013-04-141-461/+476
| | | | | | | | | | | This completes our switch to the Linux kernel coding style. Note that we still use deeply nested constructs at some places which need to be fixed up later. Converted using the `Lindent` script from the Linux kernel code base, along with some manual fixes. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix braces in if-else statementsLukas Fleischer2013-02-171-4/+5
| | | | | | | | | | From the Linux kernel coding guidelines: Do not unnecessarily use braces where a single statement will do. [...] This does not apply if one branch of a conditional statement is a single statement. Use braces in both branches. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* calendar.c: Rename to "ui-calendar.c"Lukas Fleischer2013-02-141-2/+2
| | | | | | | | | This unit belongs to the presentation layer -- rename the file accordingly. Also, rename calendar_*() to ui_calendar_*(). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Merge branch 'maint'Lukas Fleischer2013-02-041-1/+1
|\
| * Update copyright rangesLukas Fleischer2013-02-041-1/+1
| | | | | | | | | | | | | | Add 2013 to the copyright range for all source and documentation files. Reported-by: Frederic Culot <frederic@culot.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | day_process_storage(): Remove redundant parameterLukas Fleischer2013-02-011-5/+5
|/ | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Merge branch 'maint'Lukas Fleischer2012-11-261-0/+9
|\
| * day.c: Fix weekly viewLukas Fleischer2012-11-261-0/+9
| | | | | | | | | | | | | | Calculate busy slices correctly if (recurrent) appointments with a duration of more than 24 hours are used. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
| * Replace localtime() with localtime_r()Lukas Fleischer2012-11-221-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Since the result of localtime() is stored in a statically allocated structure, data was overwritten when a context switch occurred during (or shortly after) the execution of localtime(), potentially resulting in critical data corruption. BUG#7 and BUG#8 are likely related. This patch converts all usages of localtime() with localtime_r(), which is thread-safe. Reported-by: Baptiste Jonglez <baptiste@jonglez.org> Reported-by: Erik Saule <esaule@bmi.osu.edu> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Remove the erase flag and legacy deletion codeLukas Fleischer2012-07-071-4/+4
| | | | | | | | | | | | | | | | This is no longer needed. Note removal, as well as exception handling, have been moved to separate functions and the cut feature has been merged into the deletion function. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Refactor exception handlingLukas Fleischer2012-07-071-2/+13
| | | | | | | | | | | | | | | | | | Remove the exception handling code from recur_*_erase() and move it to separate functions recur_*_add_exc(). Create a wrapper function day_item_add_exc() that can be used to add an exception to generic items. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Refactor note removalLukas Fleischer2012-07-071-0/+19
| | | | | | | | | | | | | | | | Remove the note removal code from *_delete()/*_erase() and create a new wrapper function called day_item_erase_note() that is be used to drop the note being associated to an item. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add day_item_fork()Lukas Fleischer2012-07-061-0/+25
| | | | | | | | | | | | | | Add a new function that can be used to copy one day item into another, cloning the actual item that is linked. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Remove unused function day_item_nb()Lukas Fleischer2012-07-041-19/+0
| | | | | | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Revise cut/pastingLukas Fleischer2012-06-301-17/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of calling type-specific duplication handlers and inserting clones of the original items when pasting, save the generic day item and remove the actual item from the linked list, so that it can be inserted anywhere else later. The cut/paste buffer is moved to the interaction unit, item-specific cut operations are changed to remove the item from the linked list only instead of copying and freeing it. An item is only freed if another item is cut before the current cut/paste buffer is pasted. All paste operations are changed and reinsert the actual item instead of creating a clone. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Remove "appt_pos" member from day itemsLukas Fleischer2012-06-301-7/+5
| | | | | | | | | | | | This is no longer used and removing it saves a few bytes per item. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add an item parameter to various day_*() functionsLukas Fleischer2012-06-301-11/+4
| | | | | | | | | | | | | | | | These functions operate on arbitrary items. Pull out the code that gets the currently selected item, get the current selection when one of the functions is called and pass it as a parameter. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Revise *_delete{,_bynum}()Lukas Fleischer2012-06-301-5/+4
| | | | | | | | | | | | | | | | Always pass an item instead of passing a date and a index. This makes use of the NULL callback that was added with one of the previous patches. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Allow passing more complex data to list callbacksLukas Fleischer2012-06-301-10/+10
| | | | | | | | | | | | | | | | Change the data type of the "data" parameter from "long" to "void *" in llist_find_*() signatures to allow for passing more complex objects. Change all llist_find_*() invocations and callbacks accordingly. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Move interaction functions to a separate fileLukas Fleischer2012-06-301-445/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a first step to clean up several compilation units and separate the front end from back-end operations. All functions that require user interaction are moved to a new compilation unit "interaction.c". Also, following things are adjusted to the new layout: * Make day_item_get_*() and a few other functions public, so that it can be accessed from the new compilation unit. * Use apoint_hilt(), todo_hilt(), etc. instead of directly accessing static variables. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>