summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Remove legacy cut/paste codeLukas Fleischer2012-06-303-50/+0
| | | | | | | Note that this doesn't remove *_dup() since these might still be needed later. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Revise cut/pastingLukas Fleischer2012-06-307-98/+102
| | | | | | | | | | | | | | | | 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>
* Make *_free() publicLukas Fleischer2012-06-305-5/+10
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Move apoint_{cut,paste}() to interaction unitLukas Fleischer2012-06-304-55/+55
| | | | | | | | These functions get the current selection, call day_*_item() and fix the current selection on the appointment panel, so move them where they belong. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Remove "appt_pos" member from day itemsLukas Fleischer2012-06-302-8/+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 todo_*() functionsLukas Fleischer2012-06-303-19/+12
| | | | | | | | 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>
* Add an item parameter to various day_*() functionsLukas Fleischer2012-06-303-19/+12
| | | | | | | | 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-307-38/+26
| | | | | | | | 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>
* src/llist.c: Compare data pointers if callback is NULLLukas Fleischer2012-06-301-9/+30
| | | | | | | | If a NULL callback is passed to llist_find_*(), fall back to comparing data pointers. The check for a NULL callback pointer is done outside the main loop with an eye towards performance. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Allow passing more complex data to list callbacksLukas Fleischer2012-06-307-42/+42
| | | | | | | | 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>
* Rename interaction functionsLukas Fleischer2012-06-303-31/+30
| | | | | | | | Rename all interaction functions for the sake of consistency and add a "interact_" prefix. Also, mark day_erase_item() static since it is not used anywhere else. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Move interaction functions to a separate fileLukas Fleischer2012-06-307-840/+888
| | | | | | | | | | | | | | | 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>
* Remove unused functionsLukas Fleischer2012-06-304-54/+0
| | | | | | | Remove apoint_get(), event_get(), recur_get_apoint() and recur_get_event(), since they are no longer used. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Simplify apoint_switch_notify()Lukas Fleischer2012-06-304-24/+19
| | | | | | | | | Pull out code from apoint_switch_notify() -- especially the fallback routine that calls recur_apoint_switch_notify() if the currently selected item is a recurrent item -- and move it to a wrapper function day_item_switch_notify(). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* day_store_items(): Return the number of items foundLukas Fleischer2012-06-302-14/+9
| | | | | | | | | Return the total number of items found instead of the pad length, since this is used to store items in non-interactive mode as well now. The pad length can still be calculated by using the appointment and event count parameters. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/args.c: Revise app_arg()Lukas Fleischer2012-06-301-110/+8
| | | | | | | | | | | | | | | | | | | | | | This kills the hackish code we used to filter and display appointments and events in non-interactive mode. From now on, the same algorithm that is used in interactive mode (read day_store_items() for details) is called, resulting in code that is much easier to maintain. The resulting performance loss is rather small. Here are the run times of `calcurse -s01/01/1902 -r18250 -D ../test/data >/dev/null` before and after the patch was applied: 0.30user 0.26system 0:01.22elapsed 46%CPU (0avgtext+0avgdata 1340maxresident)k 0inputs+0outputs (0major+398minor)pagefaults 0swaps 0.33user 0.21system 0:01.18elapsed 46%CPU (0avgtext+0avgdata 1360maxresident)k 0inputs+0outputs (0major+395minor)pagefaults 0swaps Note that this also fixes a few bugs that were encountered in non-interactive mode, most notably BUG#2. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/day.c: Add day_write_stdout()Lukas Fleischer2012-06-302-0/+31
| | | | | | | | | This function allows for writing stored items to stdout in a fashion similar to day_write_pad(). This will be used as a convenience wrapper when switching to day_store_items() in non-interactive mode and also allows for easily implementing a "pipe-day" feature. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Make day_store_items() publicLukas Fleischer2012-06-303-7/+11
| | | | | | | | | Remove the "static" keyword from day_store_items(), so that it is accessible from other compilation units. Also, allow for discarding the event/appointment counters by passing NULL pointers and move the "regex.h" header inclusion to "calcurse.h". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* day_store_*(): Add regular expression filter parameterLukas Fleischer2012-06-301-10/+29
| | | | | | | | | Allows to filter stored items using a regular expression. This is currently unused but can be used to implement a filter in interactive mode and will also be needed when we switch to using day_store_items() in non-interactive mode. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Do not re-fetch items in day_*_{item,note}()Lukas Fleischer2012-06-301-43/+15
| | | | | | | We can access these using the pointer field of the generic item structure now -- there's no need to search for these twice any more. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Remove the need for the "day_saved_item" structLukas Fleischer2012-06-302-34/+24
| | | | | | | Do not store the currently selected item in day_write_pad() -- use day_get_item() and apoint_hilt() in day_popup_item() instead. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Simplify display_item*()Lukas Fleischer2012-06-301-35/+27
| | | | | | | | Pass the generic item container instead of individual fields to display_item() and display_item_date(). This reduces some code duplication and cleans up day_write_pad() a bit. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Simplify recur_apoint_switch_notify()Lukas Fleischer2012-06-303-11/+3
| | | | | | | | | Pass the recurrent appointment itself instead of passing a date and an item number. This is quite simple as we can just pass the pointer that is contained in the generic item structure and don't have to LLIST_TS_FIND_*() the item first any more. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Rework generic item containerLukas Fleischer2012-06-303-90/+134
| | | | | | | | | Instead of copying all members of the individual item structures to a generic structure containing all fields, create compulsory fields only and set up a pointer to the actual item. This results in lower memory footprint and lets us clean up some code. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/config.c: Fix parsing an unset color themeLukas Fleischer2012-06-301-1/+5
| | | | | | | | | If color support is disabled, the color theme configuration value is set to "0" or "none", which is a value we no longer accepted since commit a5486605696f92a749277d49c77bb5b194dc67a5. Re-introduce the branch that checks for an unset color theme before actually parsing it. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix compilation with NLS disabledLukas Fleischer2012-06-302-0/+5
| | | | | | | * src/utils.c: Only call setlocale() if NLS is enabled. * src/calcurse.h: Define a fallback macro ngettext() if NLS is disabled. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/args.c: Fix bugs address in usage messageLukas Fleischer2012-06-181-12/+11
| | | | | | | | | | | * Point out that bug reports should be sent to the bugs mailing list, not to misc in help and usage messages. * Call more_info() when displaying the help message instead of copy-pasting strings to avoid double translation. Reported-by: rafael ff1 <rafael.f.f1@gmail.com> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/help.c: Add missing _()Lukas Fleischer2012-06-181-1/+1
| | | | | | | Add a missing gettext wrapper. This string should be translated. Reported-by: rafael ff1 <rafael.f.f1@gmail.com> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/keys.c: Fix help strings for generic-{cut,paste}Lukas Fleischer2012-06-181-2/+2
| | | | | Reported-by: rafael ff1 <rafael.f.f1@gmail.com> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/keys.c: Add vim-style default bindings for generic-*Lukas Fleischer2012-06-131-4/+4
| | | | | | | | | | Add vim-style key bindings for generic-prev-day, generic-next-day, generic-prev-week and generic-next-week in a fashion similar to what we use for generic-*-month and generic-*-year. The key "t"/"T" for generic-prev-day/generic-next-day is somewhat less than perfect but this is okay given that we're running out of keys... Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add key bindings to go to the previous/next month/yearLukas Fleischer2012-06-136-4/+88
| | | | | | | | | | In addition to generic key bindings for moving one day (week) forward/backward, define similar bindings for moving a month or a year. Of course, count prefixes are allowed here as well. Also add status bar hints and help texts. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Rename displacement enumeration elementsLukas Fleischer2012-06-136-45/+44
| | | | | | | | | | * Rename "LEFT" to "DAY_PREV", "RIGHT" to "DAY_NEXT", "UP" to "WEEK_PREV" and "DOWN" to "WEEK_NEXT" to reflect the semantics of these operations. Remove the unneeded "MOVES" element. * Reorder code to improve consistency. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/sigs.c: Define "_BSD_SOURCE" and "__BSD_VISIBLE"Lukas Fleischer2012-06-011-0/+10
| | | | | | | | | | | | | | | | | | | SIGWINCH isn't POSIX-compatible and causes a compile error on several platforms, such as OpenBSD: sigs.c: In function 'generic_hdlr': sigs.c:63: error: 'SIGWINCH' undeclared (first use in this function) sigs.c:63: error: (Each undeclared identifier is reported only once sigs.c:63: error: for each function it appears in.) sigs.c: In function 'sigs_init': sigs.c:97: error: 'SIGWINCH' undeclared (first use in this function) *** Error code 1 Define "_BSD_SOURCE" explicitly in this compilation unit to enforce definition of the "SIGWINCH" constant. Also, set "__BSD_VISIBLE" to 1 since FreeBSD doesn't honor "_BSD_SOURCE". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/custom.c: Mark sidebar help string "no-c-format"Lukas Fleischer2012-06-011-0/+1
| | | | | | | | This one was incorrectly detected as C format string due to the literal percent sign ("%") contained in the message. Add a comment that explicitly marks it as non-format string to avoid translation issues. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Make appearance.calendarview more explicit in config fileBaptiste Jonglez2012-05-313-9/+20
| | | | | | | | | | Instead of using 0 or 1 as a value for `appearance.calendarview`, introduce the more explicit "monthly" and "weekly". Also update `scripts/calcurse-upgrade.sh` to reflect the change. Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use our array of available date input formatsBaptiste Jonglez2012-05-311-10/+3
| | | | | Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Provide an array of available date input formatsBaptiste Jonglez2012-05-312-0/+9
| | | | | | | | This will allow to fix the current hardcoding of strings describing date input formats in multiple places. Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Give a meaning to DATE_FORMATSBaptiste Jonglez2012-05-313-3/+6
| | | | | | | | | | | It's a bit weird to consider DATE_FORMATS as part of the date input format enum, all the more so as it does not even represent the number of available formats (since those are numbered from 1). Turn DATE_FORMATS into the number of available date input formats. Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/custom.c: Use status_ask_simplechoice()Baptiste Jonglez2012-05-311-11/+14
| | | | | | | | | | | | | This eases up i18n somewhat, since the various date format available are used on other places as well, and thus need to be translated only once. Note that this commit incidentally fixes a small bug introduced by 38912b36: the user was able to set the date input format to a number between 1 and 5, while there are only 4 such formats available. Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Directly use fprintf() where applicableBaptiste Jonglez2012-05-311-12/+4
| | | | | | | | | | For some reasons, we were using snprintf() to format a string into a buffer, and then displaying this buffer to stdout using fputs(). That's exactly what fprintf() is here for, so use it. Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/day.c: Fix typoBaptiste Jonglez2012-05-311-1/+1
| | | | | Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use mvwaddstr() instead of mvwprintw()Baptiste Jonglez2012-05-317-80/+75
| | | | | | | | | | | | | When we only want to display a string at a specific place of the screen, there's no need to use the more complex mvwprintw(), use mvwaddstr() instead. This should be slightly more efficient, and, above all, it prevents weird things to happen if our string contains a '%', being interpreted as an unwanted format string. Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/config.c: Bail out on incomplete directiveLukas Fleischer2012-05-291-0/+3
| | | | | | | | | | Fixes a segmentation fault that arose if a line in the configuration file didn't contain a value/key separator ("="). Instead of operating on a NULL pointer, throw an error message containing the erroneous directive and bail out. Reported-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix incorrect i18n usage for some stringsBaptiste Jonglez2012-05-256-22/+22
| | | | | | | | | | | Some strings are initialized without wrapping them in _(); instead, _() is applied on the variable when it is used. This is incorrect, since these strings don't get added to the catalog. Fix that by applying _() only once, when the string is declared. Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Do not localize configuration optionsLukas Fleischer2012-05-232-18/+18
| | | | | | | | | The configuration options shown in the configuration menu are meant to reflect the keys used in the configuration file. The descriptions displayed alongside each option should be sufficient for non-English speakers. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Merge branch 'maint'Lukas Fleischer2012-05-233-3/+10
|\ | | | | | | | | | | | | Conflicts: src/io.c src/notify.c src/utils.c
| * Do not localize dates in pcal exportsLukas Fleischer2012-05-192-1/+8
| | | | | | | | | | | | | | | | | | * Do not localize the word "week" in pcal export headers. * Reset current locale before formatting dates in pcal export data. Addresses BUG#1. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
| * src/notify.c: Fix printf() misuseLukas Fleischer2012-05-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Make sure we actually copy the notification warning interval to the correct buffer instead of printing it to stdout (using an arbitrary format string). This makes sure the current warning interval is shown when editing the field and also eliminates a potential format string vulnerability. Spotted with "-Wformat-nonliteral". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Fix default time format for multi-day appointmentsLukas Fleischer2012-05-211-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As of commit 0791eaabca0fb1ef8a8675e47d701bbcde4d4a3f, we use strftime() instead of apoint_sec2str() to format start and end dates of appointments. "%H:%M" is the default strftime() format string used to simulate apoint_sec2str(). However, apoint_sec2str() additionally checks for intersection with the current day and displays "..:.." instead of the actual time if the item doesn't start (end) at the current day. Add an additional check to the new default time format and recreate the old behavior for items starting before or ending after the current day. Fixes BUG#3. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Switch to Linux kernel coding styleLukas Fleischer2012-05-2132-10660/+9174
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Convert our code base to adhere to Linux kernel coding style using Lindent, with the following exceptions: * Use spaces, instead of tabs, for indentation. * Use 2-character indentations (instead of 8 characters). Rationale: We currently have too much levels of indentation. Using 8-character tabs would make huge code parts unreadable. These need to be cleaned up before we can switch to 8 characters. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>