97 Commits

Author SHA1 Message Date
Lukas Fleischer
bfe73d0e5d Add item filters
This adds the following filter options that allow for restricting the
set of items that are read from the appointments file:

* --filter-type
* --filter-start-from
* --filter-start-to
* --filter-start-after
* --filter-start-before
* --filter-end-from
* --filter-end-to
* --filter-end-after
* --filter-end-before

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-06 12:08:14 +02:00
Lukas Fleischer
694d28eb78 Use tabs instead of spaces for indentation
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>
2013-04-14 00:19:01 +02:00
Lukas Fleischer
9907069f44 Validate date/time when scanning items
Bail out when reading dates such as "02/30/2013" from the appointments
file. These *could* be converted into valid dates but since we never
write invalid dates to that file, these indicate a user error.

Fixes following test cases:

* appointment-009.sh
* appointment-012.sh
* appointment-016.sh
* appointment-019.sh
* event-003.sh

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-27 11:36:29 +01:00
Lukas Fleischer
a363cb9b91 Fix braces in if-else statements
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>
2013-02-17 09:19:04 +01:00
Lukas Fleischer
601709b173 apoint.c: Split out UI-related functions
* Move UI-related functions to "ui-day.c".
* Rename UI-related functions to ui_day_*().

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-14 10:43:40 +01:00
Lukas Fleischer
a7944d335e Update copyright ranges
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>
2013-02-04 20:10:14 +01:00
Lukas Fleischer
4d0c095947 Add compact panels support
Add a configuration option that allows for switching to compact panel
mode. In this mode, all window labels are hidden, so that there's more
space for actual information.

This patch doesn't add a configuration menu entry and doesn't add any
documentation.

Implements FR#7.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-11-25 18:33:29 +01:00
Lukas Fleischer
1f0f05ecc1 Merge branch 'maint'
Conflicts:
	src/day.c
	src/recur.c
2012-11-23 19:03:57 +01:00
Lukas Fleischer
e269f09438 Replace localtime() with localtime_r()
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>
2012-11-22 22:58:04 +01:00
Lukas Fleischer
8375e9a51b Use integers rather than floats everywhere
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-10 11:58:15 +02:00
Lukas Fleischer
0f20693b07 Remove the erase flag and legacy deletion code
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-07 21:40:56 +02:00
Lukas Fleischer
7fb25a84d4 Refactor note removal
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-07 21:35:02 +02:00
Lukas Fleischer
a1394e9833 Refactor *_dup()
* 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-06 01:54:09 +02:00
Lukas Fleischer
57c4f9d8ea Remove legacy cut/paste code
Note that this doesn't remove *_dup() since these might still be needed
later.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:36 +02:00
Lukas Fleischer
6907ae73e7 Revise cut/pasting
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-30 14:34:36 +02:00
Lukas Fleischer
b230e2949e Make *_free() public
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:36 +02:00
Lukas Fleischer
47d5fe2d45 Move apoint_{cut,paste}() to interaction unit
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-30 14:34:36 +02:00
Lukas Fleischer
02c90ba53a Revise *_delete{,_bynum}()
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-30 14:34:35 +02:00
Lukas Fleischer
b8b6830dfd Allow passing more complex data to list callbacks
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-30 14:34:35 +02:00
Lukas Fleischer
9ed7494f5e Move interaction functions to a separate file
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-30 14:34:35 +02:00
Lukas Fleischer
ba28426fc0 Remove unused functions
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-30 14:34:35 +02:00
Lukas Fleischer
0504875219 Simplify apoint_switch_notify()
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-30 14:34:35 +02:00
Lukas Fleischer
80e24954c2 Simplify recur_apoint_switch_notify()
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>
2012-06-30 14:34:33 +02:00
Lukas Fleischer
cfd8ede2b3 Switch to Linux kernel coding style
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>
2012-05-21 10:13:05 +02:00
Baptiste Jonglez
13d6f8703b Factorize boolean user prompting.
Introduce a new `status_ask_bool()` function, and use it where
applicable.

This greatly reduces code duplication, and will allow handling special
events (resize, user escape) much more uniformely.

Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-05-14 19:31:13 +02:00
Lukas Fleischer
1c442e6aef Miscellaneous small code cleanups
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-06 23:23:58 +02:00
Lukas Fleischer
80f7e8ead5 Mark localized string literals constant
Translated strings returned by gettext() are statically allocated and
shouldn't be modified.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-05 22:18:46 +02:00
Lukas Fleischer
c9aff6d213 Update copyright ranges
Add 2012 to the copyright range for all source and documentation files.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-03-26 14:38:16 +02:00
Lukas Fleischer
894ac2d70d Trap fgets() failure in *_scan()
Ensure we don't read arbitrary data when fgets() returns a NULL string
(meaning that either the EOF is encountered or an error occurred). This
also fixes a couple of compiler warnings seen with "-Wunused-result".

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-02-18 13:04:21 +01:00
Baptiste Jonglez
7850f6ddf1 src/apoint.c: Update in-notify-bar help for new duration syntax
Signed-off-by: Baptiste Jonglez <baptiste@jonglez.org>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-01-07 12:30:56 +01:00
Baptiste Jonglez
71e05b1dcf src/apoint.c: Fix a length bug introduced by new duration format
Commit 4ff3bb9d introduced a new format for parsing durations, thus
allowing a larger string to be retrieved from user input.

However, the string used is still declared with the old length,
leading to crashes when compiling with stack-smashing protection
features (the default on Archlinux). Inputting a duration string of
more than 8 characters (such as "+1d11h11m") would crash calcurse with
a *** stack smashing detected *** message.

Using a larger string from the start fixes the bug.

Signed-off-by: Baptiste Jonglez <baptiste@jonglez.org>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-01-07 12:30:56 +01:00
Lukas Fleischer
dfe835190f src/apoint.c: Remove several unneeded variables
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-12-05 00:48:47 +01:00
Lukas Fleischer
d32d811623 src/apoint.c: Remove apoint_recur_s2apoint_s()
This one is hackish, obsolete and no longer used by any other function.
Drop it!

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-11-14 11:08:14 +01:00
Lukas Fleischer
edad2f39db Removed unused parameter from apoint_sec2str()
This is no longer needed as of commit 2d89d336.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-11-14 11:08:14 +01:00
Lukas Fleischer
41c33eeb44 Use a global configuration variable
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>
2011-11-14 11:08:14 +01:00
Lukas Fleischer
6f01c7af97 Remove parentheses from return statements
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>
2011-11-02 19:38:38 +01:00
Lukas Fleischer
7cc6305588 Do not cast unused return values to void
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>
2011-11-02 18:32:17 +01:00
Lukas Fleischer
44bc9605d6 Avoid use of printf()/fprintf()
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>
2011-11-02 18:31:10 +01:00
Lukas Fleischer
2d89d33668 src/apoint.c: Format recurrent multi-day items properly
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>
2011-10-21 08:58:53 +02:00
Lukas Fleischer
3e84074ae5 Make events start on 00:00 (12:00 a.m.)
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>
2011-10-21 08:58:53 +02:00
Lukas Fleischer
6e5ae6562d src/apoint.c: Resize duration input field
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>
2011-10-06 12:37:07 +02:00
Lukas Fleischer
39dd3c251d Use parse_{time,duration}() where appropriate
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>
2011-10-06 12:37:06 +02:00
Lukas Fleischer
ba2aa5167b Add count parameter to *_{in,de}crease()
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>
2011-10-06 12:37:06 +02:00
Lukas Fleischer
70a488a64e Remove temporary highlight pointers
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>
2011-10-06 12:37:05 +02:00
Lukas Fleischer
6c7edfbb86 Do not unlink() note files on note removal
Now that we use hash-based note file names, note files should never be
unlinked as a note file might be shared.

Also, remove the ERASE_FORCE_KEEP_NOTE flag that no longer makes any
sense.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-05 12:25:47 +02:00
Lukas Fleischer
709525cf8d Fix apoint_get() call in apoint_switch_notify()
We passed the function arguments the wrong way round. This regression
was introduced in commit 77ef3fe76e4ce4c9a990e8a5904ad2d83420ca02.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-29 20:38:59 +02:00
Lukas Fleischer
0126cbd1b3 Update the notification item in *_paste_item()
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-29 20:38:59 +02:00
Lukas Fleischer
5a5c6d2604 Add "force" parameter to notify_check_next_app()
This allows to force notify_check_next_app() to update the notification
appointment, even if start times are equal (e.g. if the item description
was changed).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-29 20:28:30 +02:00
Lukas Fleischer
38865b8e48 Update copyright notices in source files, documentation and "COPYING".
* Update copyright dates (use 2004-2011 as date range everywhere).

* Change copyright holder from "Frederic Culot" to "calcurse Development
  Team".

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-04-22 07:26:05 +02:00
Lukas Fleischer
77ef3fe76e Use generic lists for appointments.
Use the new generic list implementation instead of "apoint_list"
everywhere. Simplify stuff and drop unused variables as well.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-04-19 11:42:33 +02:00