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>
This commit is contained in:
parent
e5dee68dcf
commit
1355bad264
@ -916,7 +916,7 @@ parse_args (int argc, char **argv, struct conf *conf)
|
|||||||
io_check_file (path_apts, (int *)0);
|
io_check_file (path_apts, (int *)0);
|
||||||
io_check_file (path_conf, (int *)0);
|
io_check_file (path_conf, (int *)0);
|
||||||
io_load_app ();
|
io_load_app ();
|
||||||
custom_load_conf (conf, 0); /* To get output date format. */
|
custom_load_conf (conf); /* To get output date format. */
|
||||||
if (dflag)
|
if (dflag)
|
||||||
date_arg (ddate, add_line, Nflag, conf, preg);
|
date_arg (ddate, add_line, Nflag, conf, preg);
|
||||||
if (rflag || sflag)
|
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_apts, (int *)0);
|
||||||
io_check_file (path_conf, (int *)0);
|
io_check_file (path_conf, (int *)0);
|
||||||
vars_init (conf);
|
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 ();
|
io_load_app ();
|
||||||
day.dd = day.mm = day.yyyy = 0;
|
day.dd = day.mm = day.yyyy = 0;
|
||||||
(void)app_arg (add_line, &day, 0, Nflag, conf, preg);
|
(void)app_arg (add_line, &day, 0, Nflag, conf, preg);
|
||||||
|
@ -50,7 +50,6 @@ main (int argc, char **argv)
|
|||||||
{
|
{
|
||||||
struct conf conf;
|
struct conf conf;
|
||||||
struct day_items_nb inday;
|
struct day_items_nb inday;
|
||||||
int background, foreground;
|
|
||||||
int non_interactive;
|
int non_interactive;
|
||||||
int no_data_file = 1;
|
int no_data_file = 1;
|
||||||
int sav_hilt_app = 0;
|
int sav_hilt_app = 0;
|
||||||
@ -148,7 +147,7 @@ main (int argc, char **argv)
|
|||||||
* configuration (the display is then updated), and then
|
* configuration (the display is then updated), and then
|
||||||
* the todo list, appointments and events.
|
* the todo list, appointments and events.
|
||||||
*/
|
*/
|
||||||
custom_load_conf (&conf, background);
|
custom_load_conf (&conf);
|
||||||
wins_erase_status_bar ();
|
wins_erase_status_bar ();
|
||||||
io_load_keys (conf.pager);
|
io_load_keys (conf.pager);
|
||||||
io_load_todo ();
|
io_load_todo ();
|
||||||
|
@ -611,7 +611,7 @@ char *calendar_get_pom (time_t);
|
|||||||
void custom_init_attr (void);
|
void custom_init_attr (void);
|
||||||
void custom_apply_attr (WINDOW *, int);
|
void custom_apply_attr (WINDOW *, int);
|
||||||
void custom_remove_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_config_bar (void);
|
||||||
void custom_layout_config (void);
|
void custom_layout_config (void);
|
||||||
void custom_sidebar_config (void);
|
void custom_sidebar_config (void);
|
||||||
@ -892,6 +892,7 @@ void press_any_key (void);
|
|||||||
extern int col, row;
|
extern int col, row;
|
||||||
extern int resize;
|
extern int resize;
|
||||||
extern unsigned colorize;
|
extern unsigned colorize;
|
||||||
|
extern int foreground, background;
|
||||||
extern enum ui_mode ui_mode;
|
extern enum ui_mode ui_mode;
|
||||||
extern int days[12];
|
extern int days[12];
|
||||||
extern char *monthnames[12];
|
extern char *monthnames[12];
|
||||||
|
12
src/custom.c
12
src/custom.c
@ -113,7 +113,7 @@ conf_parse_int (int *dest, char *val)
|
|||||||
* differently (number between 1 and 8).
|
* differently (number between 1 and 8).
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
custom_load_color (char *color, int background)
|
custom_load_color (char *color)
|
||||||
{
|
{
|
||||||
#define AWAITED_COLORS 2
|
#define AWAITED_COLORS 2
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ custom_remove_attr (WINDOW *win, int attr_num)
|
|||||||
|
|
||||||
/* Set a configuration variable. */
|
/* Set a configuration variable. */
|
||||||
static void
|
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;
|
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);
|
calendar_set_first_day_of_week (SUNDAY);
|
||||||
break;
|
break;
|
||||||
case CUSTOM_CONF_COLORTHEME:
|
case CUSTOM_CONF_COLORTHEME:
|
||||||
custom_load_color (val, background);
|
custom_load_color (val);
|
||||||
break;
|
break;
|
||||||
case CUSTOM_CONF_LAYOUT:
|
case CUSTOM_CONF_LAYOUT:
|
||||||
wins_set_layout (atoi (val));
|
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. */
|
/* Load the user configuration. */
|
||||||
void
|
void
|
||||||
custom_load_conf (struct conf *conf, int background)
|
custom_load_conf (struct conf *conf)
|
||||||
{
|
{
|
||||||
FILE *data_file;
|
FILE *data_file;
|
||||||
char *mesg_line1 = _("Failed to open config 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)
|
if (fgets (buf, sizeof buf, data_file) == NULL)
|
||||||
break;
|
break;
|
||||||
io_extract_data (e_conf, buf, sizeof buf);
|
io_extract_data (e_conf, buf, sizeof buf);
|
||||||
custom_set_conf (conf, background, var, e_conf);
|
custom_set_conf (conf, var, e_conf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
custom_set_conf (conf, background, var, val);
|
custom_set_conf (conf, var, val);
|
||||||
}
|
}
|
||||||
file_close (data_file, __FILE_POS__);
|
file_close (data_file, __FILE_POS__);
|
||||||
pthread_mutex_unlock (&nbar.mutex);
|
pthread_mutex_unlock (&nbar.mutex);
|
||||||
|
@ -165,7 +165,7 @@ dmon_start (int parent_exit_status)
|
|||||||
if (!io_file_exist (path_conf))
|
if (!io_file_exist (path_conf))
|
||||||
DMON_ABRT (_("Could not access \"%s\": %s\n"),
|
DMON_ABRT (_("Could not access \"%s\": %s\n"),
|
||||||
path_conf, strerror (errno));
|
path_conf, strerror (errno));
|
||||||
custom_load_conf (&conf, 0);
|
custom_load_conf (&conf);
|
||||||
|
|
||||||
if (!io_file_exist (path_apts))
|
if (!io_file_exist (path_apts))
|
||||||
DMON_ABRT (_("Could not access \"%s\": %s\n"),
|
DMON_ABRT (_("Could not access \"%s\": %s\n"),
|
||||||
|
@ -48,6 +48,9 @@ int resize = 0;
|
|||||||
/* variable to tell if the terminal supports color */
|
/* variable to tell if the terminal supports color */
|
||||||
unsigned colorize = 0;
|
unsigned colorize = 0;
|
||||||
|
|
||||||
|
/* Default background and foreground colors. */
|
||||||
|
int foreground, background;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* To tell if curses interface was launched already or not (in that case
|
* To tell if curses interface was launched already or not (in that case
|
||||||
* calcurse is running in command-line mode).
|
* calcurse is running in command-line mode).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user