summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* src/utils.c: Support printing '%' in format stringsLukas Fleischer2011-11-141-0/+9
| | | | | | This allows using "%%" to print the '%' character. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/args.c: Remove obsolete "-N" flagLukas Fleischer2011-11-141-4/+0
| | | | | | This is superseded by custom format strings. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/args.c: Allow for specifying custom format stringsLukas Fleischer2011-11-141-23/+66
| | | | | | | | | | | | | Following long command line options can be used to override the default format strings: * --format-apt * --format-recur-apt * --format-event * --format-recur-event * --format-todo Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* print_*(): Add format specifier to print notesLukas Fleischer2011-11-142-70/+70
| | | | | | | | | | | | * Move print_notefile() from "src/args.c" to "src/utils.c". * Add a "%N" format specifier to print_*(). This invokes print_notefile() and prints the content of an item's note file. * src/args.c: Use the new format specifier instead of print_notefile() everywhere. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use a dynamic method to print todo items to stdoutLukas Fleischer2011-11-143-13/+42
| | | | | | | | | | | | This goes in line with the other commits adding print_*() support. Following format specifiers are allowed: * p: Print the priority of the item * m: Print the description of the item * n: Print the name of the note file belonging to the item Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/apoint.c: Remove apoint_recur_s2apoint_s()Lukas Fleischer2011-11-142-17/+0
| | | | | | | This one is hackish, obsolete and no longer used by any other function. Drop it! Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use a dynamic method to print recurrent items to stdoutLukas Fleischer2011-11-143-7/+33
| | | | | | | | | Add print_recur_apoint() and print_recur_event() helper functions to print recurrent items to stdout and use them everywhere. Currently, these are only wrapper functions to print_apoint() and print_event() that create temporary, non-recurrent items. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use a dynamic method to print events to stdoutLukas Fleischer2011-11-143-3/+33
| | | | | | | | | | | | | Add a flexible helper function print_event() and use it whenever we print events to stdout. This reduces the number of copy-pasted code and eventually allows for specifying custom format strings. Following format specifiers are supported: * m: Print the description of the item * n: Print the name of the note file belonging to the item Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use a dynamic method to print appointments to stdoutLukas Fleischer2011-11-143-18/+52
| | | | | | | | | | | | | | | | | | Add a flexible helper function print_apoint() and use it whenever we print appointments to stdout. This reduces the number of copy-pasted code and eventually allows for specifying custom format strings. Following format specifiers are supported: * s: Print the start time of the appointment as UNIX time stamp * S: Print the start time of the appointment using the "hh:mm" format * d: Print the duration of the appointment in seconds * e: Print the end time of the appointment as UNIX time stamp * E: Print the end time of the appointment using the "hh:mm" format * m: Print the description of the item * n: Print the name of the note file belonging to the item Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Removed unused parameter from apoint_sec2str()Lukas Fleischer2011-11-144-8/+7
| | | | | | This is no longer needed as of commit 2d89d336. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use a global configuration variableLukas Fleischer2011-11-1411-162/+159
| | | | | | | This is one of the few valid use cases for a global variable. No need to make it pseudo-local and pass it from one function to another. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Merge branch 'maint'Lukas Fleischer2011-11-115-7/+20
|\ | | | | | | | | | | Conflicts: src/calcurse.h src/io.c
| * Cleanup joinable threads on terminationLukas Fleischer2011-10-043-3/+12
| | | | | | | | | | | | | | Always invoke pthread_join() when we blow up a thread via pthread_cancel() (avoid zombie threads). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
| * src/io.c: Update todo item count on iCal importLukas Fleischer2011-10-041-0/+3
| | | | | | | | | | | | | | Update the number of todo items when importing an iCal file to prevent some items from being inaccessible. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
| * Do not hardcode paths to the default editor/pagerLukas Fleischer2011-10-042-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use "vi" instead of "/usr/bin/vi" and "less" instead of "/usr/bin/less". Hardcoding absolute paths is a bad idea: $ uname -rsv Linux 3.0-ARCH #1 SMP PREEMPT Tue Aug 30 07:32:23 UTC 2011 $ which less /bin/less The "$PATH" environment variable will almost always have a better idea of where these binaries are located. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Remove parentheses from return statementsLukas Fleischer2011-11-0214-80/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | No reason to use "return (x);" here. Refer to the GNU coding guidelines for details. Created using following semantic patch: @@ expression expr; @@ - return (expr); + return expr; Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Make use of the NULL macroLukas Fleischer2011-11-028-39/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use this constant everywhere when referring to a null pointer instead of casting 0 to various types of pointers. Created using following semantic patch: @@ type type; @@ - (type *)0 + NULL Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Do not cast unused return values to voidLukas Fleischer2011-11-0220-511/+489
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A small style fix that removes all remaining "(void)" casts. Using these isn't encouraged in GNU coding guidelines and doesn't serve a certain purpose, except for satisfying a few static code analysis tools. We already nuked some of these in previous patches, but this semantic patch should fix what's left: @@ identifier func; @@ - (void)func ( + func ( ...); Long lines were re-formatted manually. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Avoid use of printf()/fprintf()Lukas Fleischer2011-11-0213-143/+138
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use one of the following functions where appropriate: * puts() (whenever we print hard coded strings to stdout) * fputs() (whenever we print hard coded strings to a stream) * putchar() (whenever we print a single character to stdout) * fputc() (whenever we print a single character to a stream) * strncpy() (whenever we copy hard coded strings to a buffer) This removes the overhead introduced by the format string parser and reduces the number of false positive C-format strings spotted by xgettext(1)'s heuristics. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/recur.c: Speed up recur_item_find_occurrence()Lukas Fleischer2011-11-021-0/+3
| | | | | | | | | | | | | | Bail out early if we check for a date beyond the item's repetition end date. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Avoid unnecessary start time calculationsLukas Fleischer2011-10-215-23/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Rename recur_*_inday() to recur_*_find_occurrence() and use the new functions whenever we actually care about the start time of an occurrence. Reintroduce recur_*_inday() as wrappers to recur_*_find_occurrence() and pass NULL as start time buffer (which means "skip start time calculation"). Keep using these when we only want to know if a recurrent item belongs to a specific day but do not care about the actual start time. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/day.c: Allow editing an item's durationLukas Fleischer2011-10-211-5/+47
| | | | | | | | | | | | | | | | We have the option to enter either an end time or a duration when creating an item - the same choice should be available when editing an item. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/day.c: Allow cancelling an editLukas Fleischer2011-10-211-22/+23
| | | | | | | | | | | | | | | | Once the user picked any property to edit, we didn't give him any chance to cancel editing. Abort if the user presses the escape key or enters an empty string. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/recur.c: Remove diff_weeks()Lukas Fleischer2011-10-211-10/+3
| | | | | | | | | | | | After our recur_item_inday() rewrite, this function is no longer used. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/recur.c: Support recurrent multi-day appointmentsLukas Fleischer2011-10-211-45/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | Completely rewrite our inday algorithm in recur_item_inday() and be more fine-grained. This version can deal with recurrent multi-day appointments unless they overlap. In case of overlapping appointments, only the last appointment that starts before the current day is shown. We will need to rewrite the whole recur_item_inday() interface in order to fix this - this relatively trivial patch is only the first step. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/apoint.c: Format recurrent multi-day items properlyLukas Fleischer2011-10-211-2/+2
| | | | | | | | | | | | | | | | | | Enable "..:.." formatting for recurrent appointments that last beyond midnight. Apart from our recurrent item handler being a tad broken, there is no reason not to do the same thing we already do with regular appointments here. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Pass item durations to recur_item_inday()Lukas Fleischer2011-10-214-12/+13
| | | | | | | | | | | | | | | | Having item's durations eventually allows for better parsing of recurrent appointments as we might be interested in how many days are covered by a multi-day appointment. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Make events start on 00:00 (12:00 a.m.)Lukas Fleischer2011-10-213-6/+6
| | | | | | | | | | | | | | | | There is absolutely no reason to make events start on noon, 12:00. Switching to 00:00 seems totally reasonable here, and makes event handling a bit easier, also. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/event.c: Fix event_inday()Lukas Fleischer2011-10-211-1/+1
| | | | | | | | | | | | | | | | Nasty off-by-one error here. An event should be associated with a day if it starts at 12:00 a.m. and shouldn't be associated if it enters the next day. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/help.c: Update messages referring to durationsLukas Fleischer2011-10-061-3/+3
| | | | | | | | | | | | Fix help texts to vaguely match the new duration string formats. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/apoint.c: Resize duration input fieldLukas Fleischer2011-10-061-1/+2
| | | | | | | | | | | | | | | | Now that we support more powerful duration strings, we should also resize the input field for duration strings. Twelve characters is enough space for "+999d23h59m". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/utils.c: Support more powerful duration stringsLukas Fleischer2011-10-061-23/+100
| | | | | | | | | | | | | | | | | | Add support for "1d23h42m"-like duration strings to parse_duration(). Also, switch to using a deterministic finite automaton to parse duration strings, as things tend to get unclear. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/utils.c: Remove check_time()Lukas Fleischer2011-10-062-32/+0
| | | | | | | | | | | | | | Now that parse_time() and parse_duration() do all the validation work, this isn't used (nor needed) any longer. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Use parse_{time,duration}() where appropriateLukas Fleischer2011-10-062-43/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Make use of these new helpers at various places. Note that this patch implies a few behavioural changes: * Short forms such as "23:" and ":45" are allowed when entering times. * Durations always need to be prefixed with a plus sign ("+"), with the nice side effect that you can now use "+3:30" to declare an appointment that lasts three hours and thirty minutes (that's much more convenient than "+210"). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/utils.c: Introduce parse_{time,duration}()Lukas Fleischer2011-10-062-0/+87
| | | | | | | | | | | | | | | | | | These helpers can be used in a fashion similar to parse_date(). In addition to check_time(), parse_time() and parse_duration() support short forms such as "23:" (instead of "23:00") and ":45" (instead of "00:45"). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/calcurse.h: Rework date manipulation constantsLukas Fleischer2011-10-061-5/+13
| | | | | | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/utils.c: Mark input string of parse_date() constLukas Fleischer2011-10-062-5/+5
| | | | | | | | | | | | | | We don't mess about with the date string here, so it should be declared const. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/calcurse.c: Support count prefixes for motionsLukas Fleischer2011-10-061-19/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | Add a global count buffer to our main loop and pass it to keys_getch() as well as to all motion commands. This enables some fancy shortcuts: * Type "2l" to jump to the day after tomorrow. * Type "4k" (or "28l") to move forward four weeks. * Type "2$" to go to the end of next week. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add count buffer to keys_getch()Lukas Fleischer2011-10-065-12/+27
| | | | | | | | | | | | | | | | Key commands can be prefixed with a natural number - keys_getch() will store this number in the buffer pointed to by the second parameter. Set this parameter to NULL to disable count prefixes. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add count parameter to *_{in,de}crease()Lukas Fleischer2011-10-064-26/+26
| | | | | | | | | | | | | | | | | | This allows for moving more than one item up/down. This currently isn't used anywhere but will be bound to a key with one of the following patches. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/calendar.c: Add a count parameter to calendar_move()Lukas Fleischer2011-10-063-13/+15
| | | | | | | | | | | | | | | | | | Allows for moving more than one step forward/backward. This is not used anywhere yet but a key binding will likely be added in one of the following patches. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Avoid unnecessary window updatesLukas Fleischer2011-10-064-63/+111
| | | | | | | | | | | | | | | | Add a window bitmask to wins_update() and only update windows that might actually require an update in our main loop. This improves response times of the user interface a bit. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Refactor out storage updatesLukas Fleischer2011-10-061-45/+48
| | | | | | | | | | | | | | Instead of using a hacky flag, simply move the storage update code to a separate function and call it when needed. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Remove temporary highlight pointersLukas Fleischer2011-10-063-29/+6
| | | | | | | | | | | | | | | | | | Add an additional check to apoint_update_panel() and todo_update_panel() and only highlight currently selected items if the corresponding panel is active. This allows us to remove all the highlight pointer juggling that we used whenever the panel selection changed. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Use LLIST_{,TS}_FIND_FOREACH_CONT where appropriateLukas Fleischer2011-10-062-4/+4
| | | | | | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/llist.h: Add LLIST_{,TS}_FIND_FOREACH_CONTLukas Fleischer2011-10-052-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | In contrast to LLIST_{,TS}_FIND_FOREACH, these convenience macros search for the first match and return successors until there is an item that isn't matched by the filter callback. Any items beyond the first cut-off are discarded. Should be used when results are known to be continuous, such as appointments and events belonging to a specific day etc. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/llist.c: Add llist_next_filter()Lukas Fleischer2011-10-053-0/+18
| | | | | | | | | | | | | | | | | | | | This convenience function can be used to return the successor of a list item if it is matched by a filter callback and return NULL otherwise. We will use this for an improved version of the LLIST_FIND_FOREACH macro that can be used whenever results are known to be continuous. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/llist.c: Add a tail pointerLukas Fleischer2011-10-053-6/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adding a tail pointer to each list increases memory footprint by four bytes, while reducing the runtime of llist_add() from O(n) to O(1). In testing, the time required to append 100000 elements to a linked list was reduced from 29.245s to 0.009s. Our second main concern is to reduce the runtime of llist_add_sorted() when inserting elements from a presorted list (this is reduced from O(n) to O(1) as well), since the data files contain appointments in sorted order and are always processed front to back. Some local numbers show how this speeds up calcurse startup (test set with 50000 appointments): 0.22user 0.12system 0:00.35elapsed 99%CPU (0avgtext+0avgdata 5396maxresident)k 0inputs+8outputs (0major+1398minor)pagefaults 0swaps As opposed to the unpatched binary: 21.97user 0.25system 0:22.23elapsed 99%CPU (0avgtext+0avgdata 5388maxresident)k 0inputs+48outputs (0major+1396minor)pagefaults 0swaps This is a ~10000% increase in speed. Timings for reading random input files generated by a script stay the same (32.391s vs. 31.776s). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add command line argument to run the GC manuallyLukas Fleischer2011-10-051-2/+21
| | | | | | | | | | | | | | | | Adds a "-g" option that allows for running the garbage collector for note files manually. This is useful for users that do not use note files at all or rarely edit/remove them. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add configuration option to run the GC on exitLukas Fleischer2011-10-055-15/+40
| | | | | | | | | | | | | | | | If "auto_gc" is enabled, the garbage collector for note files will be run on every exit. As this is an experimental feature and may cause data loss, this is disabled by default. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>