193 Commits

Author SHA1 Message Date
Lukas Fleischer
519107dc47 Extend date formats for filters
Allow for specifying both date and time in all dates and date ranges
used in filters.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-09 12:56:13 +02:00
Lukas Fleischer
e1af76eb8d Add --filter-{start,end}-range
These are shorthands for --filter-start-from/--filter-start-to and
--filter-end-from/--filter-end-to.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-08 23:57:52 +02:00
Lukas Fleischer
c2a9292bf4 Add a grep mode
This allows for printing a subset of the items in the data files by
using filters.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-07 16:34:48 +02:00
Lukas Fleischer
9f24adfded args.c: Reword error messages
Use the same error message if option arguments have the same data type
and always add the violating value.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-06 16:26:45 +02:00
Lukas Fleischer
f9208c0b3d Use backwards-compatible out format for queries
Print TODO items before appointments in query outputs and add an empty
line between the list of TODO items and the list of appointments. This
is how items were printed before the big parser refactoring.

Also, add a test to ensure we do not unintentionally change that format
in the future.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-06 15:48:02 +02:00
Lukas Fleischer
c2dc3109ae Do not use filters in GC or import mode
Filtering items when running garbage collection or when importing data
might result in data loss, so simply ignore filters here.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-06 12:08:14 +02:00
Lukas Fleischer
aa682f7a11 Rework command line argument handling
Add a new range query mode (--days) and refactor the command line
argument parser.

Note: This slightly changes the behavior of some command line
parameters, since date arguments no longer use the input date format
from the configuration file!

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-06 12:08:14 +02:00
Lukas Fleischer
1878b7c4b0 Allow for filtering TODO items
The item filters now apply to both appointments and TODO items. Also,
add a new type mask "todo" and the following new filter options:

* --filter-priority
* --filter-completed
* --filter-uncompleted

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-06 12:08:14 +02:00
Lukas Fleischer
86553f35fe Add a query mode
Add a new parameter -Q that can be used to print all appointments inside
a given query range, followed by all TODO items. The date range can be
specified using the --from and --to arguments. The start date defaults
to the current day, the end date defaults to the day after the start
date if not specified.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-06 12:08:14 +02:00
Lukas Fleischer
9ce5861468 Add pattern filter option
This adds a new item filter option --filter-pattern and removes the
whole -S parameter logic, while making -S an alias for --filter-pattern.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-06 12:08:14 +02:00
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
5aec540895 Allow for merging data files when reloading
This allows for merging the (unsaved) items with the items from the data
files when invoking the reload operation. To this end, an external merge
tool (defaults to vimdiff) is used.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-16 23:31:31 +02:00
Lukas Fleischer
0529b864b0 Fix segmentation fault
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>
2014-06-25 12:35:43 +02:00
Lukas Fleischer
2a62351d25 Reintroduce heading and separator in appointments
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>
2014-05-18 11:10:56 +02:00
Lukas Fleischer
35314dfdeb ui-day: Large-scale refactoring
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>
2014-05-18 11:06:43 +02:00
William Pettersson
fb61744f33 Add -l/--limit option
Adds the -l/--limit command line option. Limits the number of appointments
and/or ToDo items displayed.

Signed-off-by: William Pettersson <william.pettersson@gmail.com>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-07-16 11:44:55 +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
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
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
9a6b875b1d io_check_*()/io_file_exist(): Fix signatures
This was broken in commit 87fb8cfec0d8e8fc901746095458bd316314b6ee. Fix
function signatures and update all invocations accordingly.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-11-26 01:49:04 +01:00
Lukas Fleischer
4871ae8e65 args.c: Several minor simplifications
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-11-25 18:41:44 +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
86c465b0e5 Allow passing both "-D" and "-c"
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-30 14:34:37 +02:00
Lukas Fleischer
b97c2a09cf day_store_items(): Return the number of items found
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-30 14:34:34 +02:00
Lukas Fleischer
f3858d899c src/args.c: Revise app_arg()
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-30 14:34:34 +02:00
Lukas Fleischer
244b6c927d Make day_store_items() public
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-30 14:34:34 +02:00
Lukas Fleischer
ed55cdcb16 src/args.c: Fix bugs address in usage message
* 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>
2012-06-18 17:49:04 +02:00
Baptiste Jonglez
72995601e7 Directly use fprintf() where applicable
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>
2012-05-31 20:30:46 +02:00
Baptiste Jonglez
b5a911421f Fix incorrect i18n usage for some strings
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>
2012-05-25 13:28:26 +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
Lukas Fleischer
7c7c65d194 Document removal of the "-N" command line option
This option was removed in 6b95f7b67dc8e29072fed4e05efa450422661348.
Update the usage message, the man page and the manual accordingly.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-05-17 17:54:04 +02:00
Lukas Fleischer
6da787a5cc Declare several parameters/variables constant
Add the "const" keyword to parameters and variables that are never
modified. Most of these were spotted by "-Wwrite-strings".

We cast the second parameter to execvp() explicitly as it expects a
"char *const[]" where it should expect a "const char *const[]"
(according to the documentation, this is due to compatibility reasons).
This should be changed once we come up with a better solution.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-05-08 21:50:05 +02:00
Lukas Fleischer
a20f36c5de src/args.c: Add "void" in some function declarations
These functions don't take any parameters, "void" is the right parameter
signature to use here.

Fixes some warnings seen with "-Wstrict-prototypes".

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-05-08 21:49:59 +02:00
Baptiste Jonglez
f2c94fb19c src/args.c: Add a mention of "--read-only" in "calcurse --help"
Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-05-02 17:11:23 +02:00
Lukas Fleischer
50be1a1772 Mark some more variables/parameters constant
Fixes a couple of warnings seen with GCC 4.7.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-05 22:18:51 +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
3bc9497fc8 Add a read-only option
We don't save any configuration nor items if this is set. This should be
used with care, and hence there's no short option for this.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-02-24 22:48:26 +01:00
Lukas Fleischer
093b28ac39 Extract config file handlers into a separate file
We used custom_load_conf() to load the configuration file and
io_save_conf() to save configuration. Move these functions, including
all helpers, to a central location.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-12-09 20:54:20 +01:00
Lukas Fleischer
6b95f7b67d src/args.c: Remove obsolete "-N" flag
This is superseded by custom format strings.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-11-14 11:08:15 +01:00
Lukas Fleischer
7f0c3003ac src/args.c: Allow for specifying custom format strings
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>
2011-11-14 11:08:15 +01:00
Lukas Fleischer
f77f4647d1 print_*(): Add format specifier to print notes
* 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>
2011-11-14 11:08:15 +01:00
Lukas Fleischer
349bd3f88b Use a dynamic method to print todo items to stdout
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>
2011-11-14 11:08:14 +01:00
Lukas Fleischer
3c59faa925 Use a dynamic method to print recurrent items to stdout
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>
2011-11-14 11:08:14 +01:00
Lukas Fleischer
a9b820abbe Use a dynamic method to print events to stdout
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>
2011-11-14 11:08:14 +01:00
Lukas Fleischer
330ca4d3cb Use a dynamic method to print appointments to stdout
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>
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