From 1355bad2644230b9760e62333dc4a7b72c5fb1a9 Mon Sep 17 00:00:00 2001
From: Lukas Fleischer <calcurse@cryptocrack.de>
Date: Tue, 19 Jul 2011 15:19:13 +0200
Subject: 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>
---
 src/args.c     |  4 ++--
 src/calcurse.c |  3 +--
 src/calcurse.h |  3 ++-
 src/custom.c   | 12 ++++++------
 src/dmon.c     |  2 +-
 src/vars.c     |  3 +++
 6 files changed, 15 insertions(+), 12 deletions(-)

(limited to 'src')

diff --git a/src/args.c b/src/args.c
index cfa25cc..bea3a17 100644
--- a/src/args.c
+++ b/src/args.c
@@ -916,7 +916,7 @@ parse_args (int argc, char **argv, struct conf *conf)
               io_check_file (path_apts, (int *)0);
               io_check_file (path_conf, (int *)0);
               io_load_app ();
-              custom_load_conf (conf, 0); /* To get output date format. */
+              custom_load_conf (conf); /* To get output date format. */
               if (dflag)
                 date_arg (ddate, add_line, Nflag, conf, preg);
               if (rflag || sflag)
@@ -931,7 +931,7 @@ parse_args (int argc, char **argv, struct conf *conf)
               io_check_file (path_apts, (int *)0);
               io_check_file (path_conf, (int *)0);
               vars_init (conf);
-              custom_load_conf (conf, 0); /* To get output date format. */
+              custom_load_conf (conf); /* To get output date format. */
               io_load_app ();
               day.dd = day.mm = day.yyyy = 0;
               (void)app_arg (add_line, &day, 0, Nflag, conf, preg);
diff --git a/src/calcurse.c b/src/calcurse.c
index 4a16cdb..ab55254 100644
--- a/src/calcurse.c
+++ b/src/calcurse.c
@@ -50,7 +50,6 @@ main (int argc, char **argv)
 {
   struct conf conf;
   struct day_items_nb inday;
-  int background, foreground;
   int non_interactive;
   int no_data_file = 1;
   int sav_hilt_app = 0;
@@ -148,7 +147,7 @@ main (int argc, char **argv)
    * configuration (the display is then updated), and then
    * the todo list, appointments and events.
    */
-  custom_load_conf (&conf, background);
+  custom_load_conf (&conf);
   wins_erase_status_bar ();
   io_load_keys (conf.pager);
   io_load_todo ();
diff --git a/src/calcurse.h b/src/calcurse.h
index 7ba4a9b..a0af508 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -611,7 +611,7 @@ char         *calendar_get_pom (time_t);
 void custom_init_attr (void);
 void custom_apply_attr (WINDOW *, int);
 void custom_remove_attr (WINDOW *, int);
-void custom_load_conf (struct conf *, int);
+void custom_load_conf (struct conf *);
 void custom_config_bar (void);
 void custom_layout_config (void);
 void custom_sidebar_config (void);
@@ -892,6 +892,7 @@ void         press_any_key (void);
 extern int               col, row;
 extern int               resize;
 extern unsigned          colorize;
+extern int               foreground, background;
 extern enum ui_mode      ui_mode;
 extern int               days[12];
 extern char             *monthnames[12];
diff --git a/src/custom.c b/src/custom.c
index 94286b1..3a97462 100644
--- a/src/custom.c
+++ b/src/custom.c
@@ -113,7 +113,7 @@ conf_parse_int (int *dest, char *val)
  * differently (number between 1 and 8).
  */
 static void
-custom_load_color (char *color, int background)
+custom_load_color (char *color)
 {
 #define AWAITED_COLORS	2
 
@@ -255,7 +255,7 @@ custom_remove_attr (WINDOW *win, int attr_num)
 
 /* Set a configuration variable. */
 static void
-custom_set_conf (struct conf *conf, int background, enum conf_var var, char *val)
+custom_set_conf (struct conf *conf, enum conf_var var, char *val)
 {
   unsigned tmp;
 
@@ -290,7 +290,7 @@ custom_set_conf (struct conf *conf, int background, enum conf_var var, char *val
         calendar_set_first_day_of_week (SUNDAY);
       break;
     case CUSTOM_CONF_COLORTHEME:
-      custom_load_color (val, background);
+      custom_load_color (val);
       break;
     case CUSTOM_CONF_LAYOUT:
       wins_set_layout (atoi (val));
@@ -333,7 +333,7 @@ custom_set_conf (struct conf *conf, int background, enum conf_var var, char *val
 
 /* Load the user configuration. */
 void
-custom_load_conf (struct conf *conf, int background)
+custom_load_conf (struct conf *conf)
 {
   FILE *data_file;
   char *mesg_line1 = _("Failed to open config file");
@@ -413,10 +413,10 @@ custom_load_conf (struct conf *conf, int background)
           if (fgets (buf, sizeof buf, data_file) == NULL)
             break;
           io_extract_data (e_conf, buf, sizeof buf);
-          custom_set_conf (conf, background, var, e_conf);
+          custom_set_conf (conf, var, e_conf);
         }
       else
-        custom_set_conf (conf, background, var, val);
+        custom_set_conf (conf, var, val);
     }
   file_close (data_file, __FILE_POS__);
   pthread_mutex_unlock (&nbar.mutex);
diff --git a/src/dmon.c b/src/dmon.c
index 6a24739..995db1a 100644
--- a/src/dmon.c
+++ b/src/dmon.c
@@ -165,7 +165,7 @@ dmon_start (int parent_exit_status)
   if (!io_file_exist (path_conf))
     DMON_ABRT (_("Could not access \"%s\": %s\n"),
                path_conf, strerror (errno));
-  custom_load_conf (&conf, 0);
+  custom_load_conf (&conf);
 
   if (!io_file_exist (path_apts))
     DMON_ABRT (_("Could not access \"%s\": %s\n"),
diff --git a/src/vars.c b/src/vars.c
index 4b1d7cd..ef2cd73 100644
--- a/src/vars.c
+++ b/src/vars.c
@@ -48,6 +48,9 @@ int resize = 0;
 /* variable to tell if the terminal supports color */
 unsigned colorize = 0;
 
+/* Default background and foreground colors. */
+int foreground, background;
+
 /*
  * To tell if curses interface was launched already or not (in that case
  * calcurse is running in command-line mode).
-- 
cgit v1.2.3-70-g09d2