135 Commits

Author SHA1 Message Date
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
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
ce3f0ce76f Make use of the NULL macro
Use this constant everywhere when referring to a null pointer instead of
casting 0 to various types of pointers. Created using following semantic
patch:

    @@
    type type;
    @@

    - (type *)0
    + NULL

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-11-02 19:33:23 +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
98651a549f Add count buffer to keys_getch()
Key commands can be prefixed with a natural number - keys_getch() will
store this number in the buffer pointed to by the second parameter. Set
this parameter to NULL to disable count prefixes.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-06 12:37:06 +02:00
Lukas Fleischer
6bdc36b15a Avoid unnecessary window updates
Add a window bitmask to wins_update() and only update windows that might
actually require an update in our main loop. This improves response
times of the user interface a bit.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-06 12:37:05 +02:00
Lukas Fleischer
711d5dea20 Add configuration option to run the GC on exit
If "auto_gc" is enabled, the garbage collector for note files will be
run on every exit. As this is an experimental feature and may cause data
loss, this is disabled by default.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-05 12:25:48 +02:00
Lukas Fleischer
45417bc6f0 Add configuration option to notify all appointments
If "notify-all" is enabled, all non-flagged appointments will be
notified (instead of flagged ones). This is useful for users that want
to be notified of everything.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-31 03:23:32 +02:00
Lukas Fleischer
6256183e1e Fix configuration file backward compatibility
We kinda broke this in 6377582841118688aee13aff98c9216403582e45.

All hail strsep()!

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-29 23:35:17 +02:00
Lukas Fleischer
40772daaf4 Add hint to error messages in custom_load_conf()
Include the name of the configuration variable that issued the error in
error messages that are thrown while parsing the configuration file.
This makes it a lot easier to locate syntactic and semantic errors.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-21 17:58:19 +02:00
Lukas Fleischer
6377582841 Use map for configuration variable names
Use a map instead of dozens of hardcoded conditionals. This makes
configuration variable parsing more dynamic and extensible.

Also, reintroduce formatting error messages that we dropped earlier.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-21 17:58:04 +02:00
Lukas Fleischer
32f22fdcc5 Return error status in custom_set_conf()
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-21 17:57:59 +02:00
Lukas Fleischer
8e4238c242 Rename custom_load_color() to conf_parse_color()
Also, temporarily remove all error messages and return an error status
instead.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-21 17:57:50 +02:00
Lukas Fleischer
1355bad264 Declare foreground and background variables global
Removes the need to pass the terminal's default background color round.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-21 17:56:39 +02:00
Lukas Fleischer
e5dee68dcf Refactor out integer variable parsing
Introduce conf_parse_unsigned() and conf_parse_int() similar to
conf_parse_bool().

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-21 17:56:25 +02:00
Lukas Fleischer
7e4f995692 Refactor conf_parse_bool()
* Increase size argument for strncmp() comparisons by one to include the
  terminating null-character (otherwise "yesfoo" would be parsed as
  "yes", "nobar" as "no").

* Pass destination address as an additional argument and return
  success/failure status to allow for better error handling.

* Temporarily remove error handling (will be fixed later).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-21 17:55:55 +02:00
Lukas Fleischer
c875ab4195 Rename fill_config_var() to conf_parse_bool()
This is a much better name as it implicitly describes that this function
parses boolean configuration values only.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-21 17:54:59 +02:00
Lukas Fleischer
f69d1a1572 Refactor out configuration variable setting
Move configuration variable assignments to a new function,
custom_set_conf(). This improves code readability and allows for setting
configuration variables outside the configuration file loading function.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-21 17:53:46 +02:00
Lukas Fleischer
3b4a21e79c Parse single-line configuration variables
Include a fallback branch that accepts multi-line comments as well
(backward compatibility).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-15 18:25:17 +02:00
Lukas Fleischer
1f658881de Be stricter when parsing the configuration file
Throw an error message if there is a line that contains an invalid
configuration line (e.g. a non-empty line that neither contains a key
nor a value).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-15 18:13:47 +02:00
Lukas Fleischer
5f24132d18 Refactor custom_load_conf()
Read key and value of each configuration setting in one loop cycle to
facilitate adjustments of the configuration setting format. Also, this
allows us to get rid of all the redundant variable resetting.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-15 17:47:28 +02:00
Lukas Fleischer
0827e00247 Handle resize properly in the sidebar config menu
There used to be no resize handler in custom_sidebar_config() which
resulted in a messed up screen if the terminal was resized during
sidebar configuration. Doing a simple wins_reset() if the terminal was
resized works around this problem.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-06-29 15:21:05 +02:00
Lukas Fleischer
6c6c7d5ec0 Always work with new window dimensions on resize
This one came up after improving resizing behaviour in commit
fec37db06bbbdff79bc9816046a76e0b29e173b4. We used to use outdated width
and height values at various places without noticing it due to the
resize algorithm being called several times on every resize.

This patch ensures we retrieve the new window dimensions *before* doing
any layout calculations.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-06-28 18:27:52 +02:00
Lukas Fleischer
fec37db06b Avoid redundant redraws on resize
Use a global flag to record whether the terminal was resized instead of
redrawing everything each time a KEY_RESIZE is read.

Add some additional checks to help_write_pad() as invalid actions may be
passed now due to using signals instead of virtual key presses.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-06-28 18:22:43 +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
a5a9ee60d6 Fix bad use of unsigned integers.
Unsigned values should never be compared to values less than zero.
Detected with "find_unsigned.cocci" spatch from
http://coccinelle.lip6.fr/impact_linux.php.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-04-05 09:37:20 +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
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
b4dcd1c38f Exit menu item added to sidebar configuration screen (thanks Doug for reporting this). 2010-03-29 07:37:16 +00:00
Frederic Culot
b6f84b3ef9 Online help added for side bar configuration screen. 2010-03-21 12:21:11 +00:00
Frederic Culot
6892b59622 Avoid concurrent screen refreshes. 2010-03-21 10:17:03 +00:00
Frederic Culot
cc77e839d8 More work on sidebar customization. 2010-03-21 09:21:06 +00:00
Frederic Culot
ec36b96848 Work on sidebar width user-customization. 2010-03-20 13:29:47 +00:00
Frederic Culot
a8cb1c92ef All headers gathered into a single one. Typedefs suppressed. 2010-03-20 10:54:41 +00:00
Frederic Culot
758d5ff035 Code to save the calendar default view in the configuration file. 2009-10-28 15:15:43 +00:00
Frederic Culot
d6b7f83e58 conf_set_scrsize not static any more (moved to custom_set_swsiz) 2009-08-02 09:29:24 +00:00
Frederic Culot
989b6c885f Save and restore daemon configuration options. 2009-08-01 17:44:51 +00:00
Frederic Culot
35e4aa61c7 bugfixes 2009-07-29 18:20:54 +00:00
Frederic Culot
976159fa56 calcurse version removed from menu titles 2009-07-12 17:55:13 +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
78c0495587 Bugfix: avoid a possible freeze under OpenBSD when changing color from within the configuration screen. 2009-06-20 10:41:11 +00:00
Frederic Culot
c8a1b72027 make it possible to use KEY_HOME and KEY_END to define new key bindings, and prevent user from assigning a non-recgnized key 2009-01-24 14:44:09 +00:00
Frederic Culot
38912b36da iso date format added 2009-01-05 20:12:08 +00:00