80 Commits

Author SHA1 Message Date
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
edf3903ac8 Avoid core dump if window is too small
Avoid setting the maximum number of items to a negative number (which
eventually results in a core dump).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-11-25 18:30:10 +01:00
Lukas Fleischer
8fd6640caf Refactor todo_chg_priority()
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-18 22:48:31 +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
1c53c9d8c3 Revise todo_delete_note_bynum()
Pass an item instead of passing a list item index (analogous to commit
02c90ba53a658686bad5cb5f88c555d9eef06399).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-04 08:46:41 +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
954e3fd8ee Add an item parameter to various todo_*() functions
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-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
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
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
ce13b70c5a Allow passing additional parameters to shell_exec()
This allows for specifying multiple command line parameters to be passed
on to the command in a way similar to fork_exec(). This is useful if we
want to wrap editor or pager invocations in a shell.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-05-16 19:31:47 +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
Baptiste Jonglez
1d9c90bb18 Use status_ask_choice() where applicable
These cases make obvious candidates for factorisation.

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
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
315b33540a Mark several functions static
These are not needed outside of the corresponding compilation units.
Spotted with "-Wmissing-prototypes".

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-20 23:10:56 +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
a01cbe0c36 src/todo.c: Remove several unneeded variables
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-12-09 01:14:05 +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
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
2fe7a36aab Accept variable length note names
Read up to the first blank in note_read() instead of assuming a
fixed-width note file name. Accept everything up to 40 characters (which
is the length of a SHA1 hash in hexadecimal representation).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-05 12:25:47 +02:00
Lukas Fleischer
87664095cd Refactor out note functions
* Add new note_edit() and note_view() helper functions. Use these
  instead of copy-pasted code in *_note_edit().

* Move all note-related functions (note_edit(), note_view(),
  note_erase()) to a new source file "note.c".

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-21 18:13:40 +02:00
Lukas Fleischer
9e60084262 Add todo_pipe_item() function
Pipe a serialized todo item to an external process, similar to what
day_pipe_item() does (cf. c3f532d814e555abf67efb136491956428f19965).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-05 16:25:32 +02:00
Lukas Fleischer
3076670a76 Refactor out todo item serialization
Add a todo_write() function that allows one to serialize todo items and
write serialized data to an output stream in a fashion similar to
apoint_write() and event_write().

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-02 10:15:35 +02:00
Lukas Fleischer
e85501e5ef Use constant for maximum UTF-8 character size
Introduce a UTF8_MAXLEN constant instead of using the literal value "6"
at various places.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-02 10:09:13 +02:00
Lukas Fleischer
c4246779ff Make display_todo_item() UTF-8 compatible
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-02 10:08:46 +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
621b335179 Return -1 in io_file_is_empty() if file cannot be accessed.
Ensure files don't appear as empty if fopen() fails (e.g. on temporary
EACCES failures).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-04-22 02:47:38 +02:00
Lukas Fleischer
bf431d6cd9 Use generic lists for todo items.
Use the new generic list implementation instead of "next" pointers in
todo items.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-04-19 11:42:34 +02:00
Lukas Fleischer
b9c1969126 Drop empty notes after editing.
Keeping empty notes doesn't make sense here. Also, there doesn't seem to
be a simple way to erase notes yet. This will make calcurse delete any
notes that are empty (meaning that they are either 0-byte files or
contain nothing but a newline character) when returning from the editor.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-04-12 12:02:23 +02:00
Lukas Fleischer
6fb0f6f4c6 Compare pointers to "NULL" instead of "0".
"bad_zero.cocci" spatch from http://coccinelle.lip6.fr/impact_linux.php.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-04-05 09:27:04 +02:00
Lukas Fleischer
5b12c236cf Remove dead assignments spotted by clang-analyzer.
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-04-03 22:09:00 +02:00
Lukas Fleischer
9c9fd5da15 Overall indentation fixes.
Use spaces instead of tabs for source code indentation only, strip
trailing whitespaces from lines.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-03-14 19:03:53 +01:00
Lukas Fleischer
c22dcaf6be Update website links to match the new URL.
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-03-04 11:07:49 +01:00
Lukas Fleischer
73e9649387 Update mail addresses to match the new mailing lists.
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-03-04 11:07:40 +01:00
Lukas Fleischer
91c9cac898 Remove CVS "$Id" headers.
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-03-03 16:19:45 +01:00
Lukas Fleischer
56b9cbcb84 Fixed file permissions. 2011-03-03 12:21:16 +01:00
Frederic Culot
a8cb1c92ef All headers gathered into a single one. Typedefs suppressed. 2010-03-20 10:54:41 +00:00
Frederic Culot
5dcc213c16 Make use of erase_note() whenever possible. 2009-07-19 08:19:37 +00:00
Frederic Culot
5694955002 stdbool header removed, unsigned type used instead 2009-07-12 16:21:57 +00:00
Frederic Culot
27b25548a4 Switch to BSD license. 2009-07-05 20:33:13 +00:00
Frederic Culot
ea107cfd81 Ability to flag todo items as completed. 2009-06-26 21:44:11 +00:00
Frederic Culot
936b6fe373 more code cleanup 2009-01-03 21:32:10 +00:00