summaryrefslogtreecommitdiffstats
path: root/src/ui-day.c
Commit message (Collapse)AuthorAgeFilesLines
* DST fix: adjusting time in appointmentsLars Henriksen2018-11-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Calcurse saves time and date information on disk as local time in readable text file format. When loaded from disk or when entered by the user, local time is converted to Unix time (seconds since 00:00:00, 1 January 1970). When displayed, and later when saved to disk, the Unix time is converted back to readable local time. Both conversions depend on DST. Hence, if midnight for a day with DST in effect (i.e. local time) is converted, increased with an amount and converted back, the amount has changed if DST is _not_ in effect for the resulting time. In general, calculations on Unix time variables should be used with caution because of the DST-dependent conversions. Instead, the calculations should be performed on local time data with the help of mktime(). The commit fixes start time for pasted appointments (ordinary and recurrent) and the 'until'-date of recurrent appointments, pasted as well as new and edited. The latter problem is slightly different in that the adjustment is a number of days, as it is for exception dates. Update of the date in parse_datetime() has been corrected to be similar to update of the time, although no problem has been identified. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix memory leak in update_duration()Lars Henriksen2018-08-251-1/+4
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix seg fault in update_rept()Lars Henriksen2018-08-251-5/+7
| | | | | | | Memory pointers must be initialized at the start in case memory is freed (cleanup) before it is allocated. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Buffer mixupLars Henriksen2018-08-251-4/+3
| | | | | | Use one (small) buffer long enough to hold a date. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Major overhaul of appointment/event input routines.Lars Henriksen2018-08-251-194/+241
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When setting start time for a new appointment, a date is disallowed (in all other cases both time and date are still allowed). Both date and time are displayed for the user to correct when an appointment is changed or moved. Built-in help in the status bar for display of input formats. Several bug fixes that resulted in data inconsistencies (end time before start time). The routines use the enhanced parsing funtions to validate input: ui_day_item_add(void) parse_datetime() parse_duration() parse_datetime() ui_day_item_repeat(void) parse_date_duration() parse_date() ui_day_item_edit(void) update_start_time() day_edit_time() parse_datetime() update_duration() parse_duration() parse_datetime() update_rept() parse_date_duration() parse_date() Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Refactoring update_duration/day_edit_duration.Lars Henriksen2018-08-251-55/+49
| | | | | | Incorporated day_edit_duraton() into update_duration(). Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Make editing of punctual appointments more intuitiveLukas Fleischer2018-08-251-3/+6
| | | | | | | | | | When editing the start time, move the item instead of keeping the previous start time as end time. When editing the end time, start with an empty end time instead of the previous start time. Fixes GitHub issue #89. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix end-before-start inconsistencyLars Henriksen2018-06-051-7/+9
| | | | | | | | | | | | Due to deficient validation, it is possible to get an inconsistent database with an appointment that ends before it begins. Edit an existing one and specify an end time by a date that precedes the start date, or create a new one and give a date as end time that precedes the start. Then exit calcurse; on restart it will report a data error and exit. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix appointment becoming eventLars Henriksen2018-06-051-4/+4
| | | | | | | | | | | | You try to enter an appointment, but enter an invalid start time (by mistake). Calcurse rejects the input. You enter the correct start time and calcurse asks for the description, not the end time, i.e. you get an event. The check for an event must only be performed on valid input. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Scrollbar and right window border (corrected)Lars Henriksen2018-05-261-2/+2
| | | | | | | | | | | | | | | | | When a scrollbar is on display in APP or TOD windows, the right vertical border (outside the scrollbar) is not highlighted when the window is selected. The scrollbar is always highlighted: - when APP or TOD is deselected - in configuration windows where borders otherwise are not The patch moves the scrollbar parameters (except highlight) from arguments of draw_scrollbar() to the function itself. The highlight argument was 1; instead it is set higher in the call hierarchy (wins_update_panels()) and passed on down. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Add parse_date_interactive()Lukas Fleischer2017-10-261-6/+4
| | | | | | | | | Add a wrapper around parse_date() which picks the current input date format as well as the currently selected day and passes both values to parse_date(), alongside with the parameters passed to parse_date_interactive() itself. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix spelling of "frequency"Lars Henriksen2017-10-231-7/+5
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Make the day heading position configurableLars Henriksen2017-09-081-1/+4
| | | | | | | | | 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>
* Remove phase of moon featureLars Henriksen2017-09-081-1/+0
| | | | | | | | | | 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>
* Add missing string initializationLars Henriksen2017-09-041-0/+1
| | | | | | | | | | | 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>
* Add a function to wait for any key pressLukas Fleischer2017-09-031-14/+14
| | | | | | | 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>
* Make heading in appointments panel configurableLars Henriksen2017-08-281-6/+15
| | | | | | | | 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>
* Update copyright rangesLukas Fleischer2017-01-121-1/+1
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Prevent free-before-init of timstrVlad Glagolev2016-10-131-1/+1
| | | | | | | | Fixes a crash when editing the repetition of an appointment and passing an empty repetition value. Signed-off-by: Vlad Glagolev <scm@vaygr.net> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Replace parse_datetime() constants by named flagsLukas Fleischer2016-10-101-3/+3
| | | | | | | Remove the magic constants used in the return value of parse_datetime() and use named flags instead. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Refactor duration/end time parsingLukas Fleischer2016-10-101-35/+39
| | | | | | | Replace all remaining invocations of parse_time() by parse_datetime() which now indicates whether a date was supplied or not. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Support dates when specifying start/end timesLukas Fleischer2016-10-091-30/+27
| | | | | | | | | | Add support for combined date/time or date-only strings when specifying the start or end time of a new item. This is a follow-up to 1f39b5c (Add support for moving items to another day, 2016-09-30). Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Factor out parse_datetime()Lukas Fleischer2016-10-091-25/+5
| | | | | | | | Create a new function that takes a time stamp and updates the date or time components of that time stamp according to a given date/time string. Use that function for updating the start time of an item. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Add support for moving items to another dayLukas Fleischer2016-10-081-11/+27
| | | | | | | | | | | | | When moving an item (or when changing the start time of an item), allow for optionally specifying a date. If both date and time are entered, the item is updated to start on the given date and time. If only a date is entered, the item is modified to start on the given date, keeping the current start time. If only a time is entered, the item is modified to start on the current date and the new start time. Fixes GitHub issue #12. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Refactor day_edit_time()Lukas Fleischer2016-10-011-8/+7
| | | | | | | Make the function more flexible by returning the updated time instead of single hour and minute components. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Automatically select new appointments/eventsLukas Fleischer2016-09-281-8/+11
| | | | | | | | This is a follow-up to commit 65b699f (Make automatic selection of appointments/events smarter, 2016-02-16). Newly created appointments and events are now selected automatically. 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>
* Support relative dates when adding recurrencesLukas Fleischer2016-04-011-13/+31
| | | | | | | | | | | | In commit f5d8b5e (Support durations in recurrence ending dates, 2016-02-25), we added support for the `+xxwxxd` syntax when specifying recurrence end dates. However, this only worked when *editing* the recurrence, not when converting a regular item to a recurrent one. Fix this and support the new syntax in both cases. Also, mention the new syntax in the prompt. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Support durations in recurrence ending datesLukas Fleischer2016-02-261-14/+32
| | | | | | | When spending the end date of recurring items, allow date duration specifiers such as "+5d" or "+3w2d". Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Refactor UTF-8 choppingLukas Fleischer2016-02-261-4/+4
| | | | | | | 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>
* ui-day.c: Simplify code using ui_day_selitem()Lukas Fleischer2016-02-161-8/+8
| | | | | | | Use the new ui_day_selitem() utility function to retrieve the currently selected item. 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>
* Update copyright rangesLukas Fleischer2016-01-301-1/+1
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Use time_t instead of long in several placesLukas Fleischer2015-02-241-6/+5
| | | | | | | 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>
* ui-day.c: Reorganize some free() operationsLukas Fleischer2014-07-271-7/+7
| | | | | | | Fixes regressions introduced in 21fc7a4 (Replace several uses of snprintf() by asprintf(), 2014-07-21). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Replace several uses of snprintf() by asprintf()Lukas Fleischer2014-07-221-32/+35
| | | | | | | | 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>
* Warn when reloading with unsaved modificationsLukas Fleischer2014-07-161-0/+20
| | | | | | | Since the reload operation overwrites all changes, warn before reloading if there are unsaved modifications. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Do not highlight items on inactive windowsLukas Fleischer2014-07-091-0/+2
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix segmentation faultLukas Fleischer2014-06-251-10/+10
| | | | | | | | | | 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-3/+11
| | | | | | This squelches several compiler warnings. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Reintroduce heading and separator in appointmentsLukas Fleischer2014-05-181-10/+25
| | | | | | | 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>
* Add support for caption rows in list boxesLukas Fleischer2014-05-181-0/+5
| | | | | | | 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>
* ui-day: Large-scale refactoringLukas Fleischer2014-05-181-156/+78
| | | | | | | | | | 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>
* Pass date parameter to ui_day_update_panel()Lukas Fleischer2014-05-131-3/+1
| | | | | | | This allows for drawing appointment panels for days other than the current day. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add support for moving appointmentsLukas Fleischer2013-07-181-4/+14
| | | | | | | This adds an edit option to change an appointment's start time without changing its duration. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* update_start_time(): Allow for moving an itemLukas Fleischer2013-07-181-3/+7
| | | | | | | Add a parameter that specifies whether the duration should be updated when updating the start time of an item. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Allow for making an appointment punctualLukas Fleischer2013-07-181-3/+8
| | | | | | | This allows for setting an empty end time when editing an item, converting it into a punctual appointment. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix a couple of translatable stringsLukas Fleischer2013-05-141-8/+8
| | | | | | | | * 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>
* Support punctual appointments in the UILukas Fleischer2013-05-141-0/+4
| | | | | | | | | Allow for skipping the end date which means that a punctual appointment will be created. Implements FR#25. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>