summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2012-11-18calcurse.c: Pull out key_move_*()Lukas Fleischer
Supersedes the "key" parameter from following functions: * key_generic_prev_day() * key_generic_next_day() * key_generic_prev_week() * key_generic_next_week() Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-11-18calcurse.c: Break up key_change_priority()Lukas Fleischer
Split up key_change_priority() into key_raise_priority(), key_lower_priority() which are wrappers around a new convenience function change_priority(). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-11-18calcurse.c: Pull out key_generic_goto_today()Lukas Fleischer
Split out key_generic_goto_today() into a separate function. This simplifies the control flow and supersedes the "key" parameter in key_generic_goto(). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-11-18Refactor todo_chg_priority()Lukas Fleischer
Instead of passing a key, pass the number of steps to increase the priority by. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-11-18calcurse.c: Refactor the main loopLukas Fleischer
Break up the big switch statement into several functions. The functions are declared inline to avoid unnecessary function calls. Also: * Add a "KEY_HANDLER" macro can be used as a short version of a "case" statement, followed by a function call. * Declare several state variables global to avoid having to pass them to each of the new handlers. * Pass the pressed key to each of the handler functions in order not to break handlers that handled more than one key before the handlers were pulled out. These three changes were introduced to keep this patch as atomic as possible and are intended to be removed in following patches. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-11-18Add support for entering times in 24 hour formatWilliam Pettersson
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-11-18Simplify autogen.shLukas Fleischer
Replace the whole autogen.sh magic by four simple lines that execute the commands that are actually needed. This enables verbose error output and allows advanced users to figure out what went wrong in case of errors. We expect users building calcurse from Git to be smart enough to fix "command not found" errors by themselves. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-10Use integers rather than floats everywhereLukas Fleischer
We don't need floating point precision if results are casted back to integer. Instead, rearrange operations and do the integer division after the multiplication. Version numbers are terminating decimals anyway and can be stored using two integers without losing any information. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-07Add new default key binding for generic-pasteLukas Fleischer
Use "p" as an additional (vim-style) default binding for generic-paste. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-07Remove the erase flag and legacy deletion codeLukas Fleischer
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>
2012-07-07Merge cut/deleteLukas Fleischer
Remove the cut function and merge it into the del-item command. This allows for vim-style cutting/pasting. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-07Refactor exception handlingLukas Fleischer
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>
2012-07-07Refactor note removalLukas Fleischer
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>
2012-07-07Add support for copy/paste registersLukas Fleischer
This adds support for vim-style copy/paste registers which allows cutting and copying multiple items without having to overwrite the copy/paste buffer. Registers can be specified using the quote key ('"'). To access a register, type '"x' before a command where "x" is the name of a register. If you want to copy the currently selected item into register 1, type '"1c'. Valid registers are 0-9, a-z, "-" and "_". Note that the latter is the so-called black hole register, which works similar to the black hole register in vim. The register prefix key is currently hardcoded and cannot be configured. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-06Add a key binding for generic-copyLukas Fleischer
This finally adds full copy-paste support. Implements FR#15. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-06Add interact_day_item_copy()Lukas Fleischer
This can be used to copy an item, so that it can be pasted somewhere else later. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-06Do not bind "c" to "generic-config-menu" by defaultLukas Fleischer
The "c" key will be used for the generic-copy command in the future. The configuration menu isn't needed a lot, so binding it to "C" only seems legit. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-06Duplicate items when pastingLukas Fleischer
This allows pasting items more than once. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-06Add day_item_fork()Lukas Fleischer
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>
2012-07-06Refactor *_dup()Lukas Fleischer
* Actually duplicate an item instead of copying data only. * Properly clone an item without a note. * Mark *_dup() public. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-04Revise todo_delete_note_bynum()Lukas Fleischer
Pass an item instead of passing a list item index (analogous to commit 02c90ba53a658686bad5cb5f88c555d9eef06399). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-04Remove unused function day_item_nb()Lukas Fleischer
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-04Summarize all contributions to translationsStéphane Aulery
Signed-off-by: Stéphane Aulery <lkppo@free.fr> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30Add a test case to reproduce BUG#2Lukas Fleischer
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30Allow passing both "-D" and "-c"Lukas Fleischer
This is particularly useful if one wants to use configuration and key bindings from a specific directory, while using an appointment file from somewhere else. "-c" has precedence over "-D". Also update the usage message, man page and documentation. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30Implement a cache for the monthly viewLukas Fleischer
Add a very simple cache, which is used to store the days that contain an event or an appointment. This makes redrawing and browsing the calendar panel much faster. The cache has a size of 31 integers (which is equivalent to 124 bytes on a 32 bit system and 248 bytes on a 64 bit system) and invalidates itself if the current month has changed. If an item is added/changed/removed, the cache needs to be invalidated manually by calling calendar_monthly_view_cache_set_invalid(). Note that this will always invalidate the whole cache, even if only one item at the last day of the month was removed. This is a trade-off between simplicity and efficiency. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30Remove unneeded parameter/return valueLukas Fleischer
The item type parameter/return value no longer needs to be passed/returned to interact_day_item_{paste,cut}(), since the type descriptor is saved when cutting an item now. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30Remove legacy cut/paste codeLukas Fleischer
Note that this doesn't remove *_dup() since these might still be needed later. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30Revise cut/pastingLukas Fleischer
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>
2012-06-30Make *_free() publicLukas Fleischer
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30Move apoint_{cut,paste}() to interaction unitLukas Fleischer
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>
2012-06-30Remove "appt_pos" member from day itemsLukas Fleischer
This is no longer used and removing it saves a few bytes per item. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30Add an item parameter to various todo_*() functionsLukas Fleischer
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>
2012-06-30Add an item parameter to various day_*() functionsLukas Fleischer
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>
2012-06-30Revise *_delete{,_bynum}()Lukas Fleischer
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>
2012-06-30src/llist.c: Compare data pointers if callback is NULLLukas Fleischer
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>
2012-06-30Allow passing more complex data to list callbacksLukas Fleischer
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>
2012-06-30Rename interaction functionsLukas Fleischer
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>
2012-06-30Move interaction functions to a separate fileLukas Fleischer
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>
2012-06-30Remove unused functionsLukas Fleischer
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>
2012-06-30Simplify apoint_switch_notify()Lukas Fleischer
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>
2012-06-30day_store_items(): Return the number of items foundLukas Fleischer
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>
2012-06-30src/args.c: Revise app_arg()Lukas Fleischer
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>
2012-06-30src/day.c: Add day_write_stdout()Lukas Fleischer
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>
2012-06-30Make day_store_items() publicLukas Fleischer
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>
2012-06-30day_store_*(): Add regular expression filter parameterLukas Fleischer
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>
2012-06-30Do not re-fetch items in day_*_{item,note}()Lukas Fleischer
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>
2012-06-30Remove the need for the "day_saved_item" structLukas Fleischer
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>
2012-06-30Simplify display_item*()Lukas Fleischer
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>
2012-06-30Simplify recur_apoint_switch_notify()Lukas Fleischer
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>