aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/colors.c12
-rw-r--r--src/colors.h5
-rw-r--r--src/conf.c14
-rw-r--r--src/ncu.c11
-rw-r--r--src/options.c9
-rw-r--r--src/options.h4
-rw-r--r--src/screen.c2
7 files changed, 57 insertions, 0 deletions
diff --git a/src/colors.c b/src/colors.c
index 68c5b6007..0bcf2782c 100644
--- a/src/colors.c
+++ b/src/colors.c
@@ -18,7 +18,9 @@
#include "colors.h"
#include "i18n.h"
+#ifdef ENABLE_COLORS
#include "options.h"
+#endif
#include <assert.h>
#include <stdio.h>
@@ -53,10 +55,12 @@
#define NAME_ALERT "alert"
#define NAME_BGCOLOR "background"
+#ifdef ENABLE_COLORS
typedef struct {
short color;
short r,g,b;
} color_definition_entry_t;
+#endif
typedef struct {
const char *name;
@@ -79,6 +83,8 @@ static color_entry_t colors[COLOR_END] = {
[COLOR_STATUS_ALERT] = { NAME_ALERT, COLOR_BRIGHT_RED, A_BOLD },
};
+#ifdef ENABLE_COLORS
+
/* background color */
static short bg = COLOR_BLACK;
@@ -208,6 +214,7 @@ colors_assign(const char *name, const char *value)
return 0;
}
+
int
colors_start(void)
{
@@ -257,6 +264,7 @@ colors_start(void)
return 0;
}
+#endif
int
colors_use(WINDOW *w, enum color id)
@@ -269,15 +277,19 @@ colors_use(WINDOW *w, enum color id)
wattr_get(w, &attrs, &pair, NULL);
+#ifdef ENABLE_COLORS
if (options.enable_colors) {
/* color mode */
if (attrs != entry->attrs || (short)id != pair)
wattr_set(w, entry->attrs, id, NULL);
} else {
+#endif
/* mono mode */
if (attrs != entry->attrs)
wattrset(w, entry->attrs);
+#ifdef ENABLE_COLORS
}
+#endif
return 0;
}
diff --git a/src/colors.h b/src/colors.h
index b612a33ce..051aa9e26 100644
--- a/src/colors.h
+++ b/src/colors.h
@@ -1,6 +1,8 @@
#ifndef COLORS_H
#define COLORS_H
+#include "config.h"
+
#include <ncurses.h>
enum color {
@@ -20,9 +22,12 @@ enum color {
short colors_str2color(const char *str);
+#ifdef ENABLE_COLORS
int colors_assign(const char *name, const char *value);
int colors_define(const char *name, short r, short g, short b);
int colors_start(void);
+#endif
+
int colors_use(WINDOW *w, enum color id);
#endif /* COLORS_H */
diff --git a/src/conf.c b/src/conf.c
index 5dff1ccdf..4485cda59 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -225,6 +225,7 @@ parse_timedisplay_type(const char *str)
}
}
+#ifdef ENABLE_COLORS
static int
parse_color(char *str)
{
@@ -312,6 +313,7 @@ parse_color_definition(char *str)
g_free(name);
return value;
}
+#endif
static char *
get_format(char *str)
@@ -438,13 +440,21 @@ read_rc_file(char *filename, options_t *options)
parse_key_definition(value);
/* enable colors */
else if(!strcasecmp(CONF_ENABLE_COLORS, name))
+#ifdef ENABLE_COLORS
options->enable_colors = str2bool(value);
+#else
+ {}
+#endif
/* auto center */
else if (!strcasecmp(CONF_AUTO_CENTER, name))
options->auto_center = str2bool(value);
/* color assignment */
else if (!strcasecmp(CONF_COLOR, name))
+#ifdef ENABLE_COLORS
parse_color(value);
+#else
+ {}
+#endif
/* wide cursor */
else if (!strcasecmp(CONF_WIDE_CURSOR, name))
options->wide_cursor = str2bool(value);
@@ -460,7 +470,11 @@ read_rc_file(char *filename, options_t *options)
options->timedisplay_type=g_strdup(parse_timedisplay_type(value));
/* color definition */
} else if (!strcasecmp(CONF_COLOR_DEFINITION, name))
+#ifdef ENABLE_COLORS
parse_color_definition(value);
+#else
+ {}
+#endif
/* list format string */
else if (!strcasecmp(CONF_LIST_FORMAT, name)) {
g_free(options->list_format);
diff --git a/src/ncu.c b/src/ncu.c
index ed3c2273b..936e78aa5 100644
--- a/src/ncu.c
+++ b/src/ncu.c
@@ -17,7 +17,16 @@
*/
#include "ncu.h"
+
+#ifdef ENABLE_COLORS
#include "colors.h"
+#endif
+
+#ifdef HAVE_GETMOUSE
+#include "options.h"
+#endif
+
+#include <ncurses.h>
void
ncu_init(void)
@@ -26,7 +35,9 @@ ncu_init(void)
initscr();
/* initialize color support */
+#ifdef ENABLE_COLORS
colors_start();
+#endif
/* tell curses not to do NL->CR/NL on output */
nonl();
diff --git a/src/options.c b/src/options.c
index 75f074a63..1b592a567 100644
--- a/src/options.c
+++ b/src/options.c
@@ -151,6 +151,11 @@ handle_option(int c, const char *arg)
#ifdef ENABLE_NLS
" nls"
#endif
+#ifdef ENABLE_COLORS
+ " colors"
+#else
+ " no-colors"
+#endif
#ifdef HAVE_GETMOUSE
" getmouse"
#endif
@@ -166,10 +171,14 @@ handle_option(int c, const char *arg)
"\n");
exit(EXIT_SUCCESS);
case 'c': /* --colors */
+#ifdef ENABLE_COLORS
options.enable_colors = true;
+#endif
break;
case 'C': /* --no-colors */
+#ifdef ENABLE_COLORS
options.enable_colors = false;
+#endif
break;
case 'm': /* --mouse */
options.enable_mouse = true;
diff --git a/src/options.h b/src/options.h
index 70853f4ff..e7e9e8f4c 100644
--- a/src/options.h
+++ b/src/options.h
@@ -1,6 +1,8 @@
#ifndef OPTIONS_H
#define OPTIONS_H
+#include "config.h"
+
#include <stdbool.h>
#define MPD_HOST_ENV "MPD_HOST"
@@ -31,7 +33,9 @@ typedef struct {
bool list_wrap;
bool auto_center;
bool wide_cursor;
+#ifdef ENABLE_COLORS
bool enable_colors;
+#endif
bool audible_bell;
bool visible_bell;
bool enable_xterm_title;
diff --git a/src/screen.c b/src/screen.c
index 231d84ada..2fd4b571f 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -503,6 +503,7 @@ screen_init(mpdclient_t *c)
leaveok(screen.status_window.w, FALSE);
keypad(screen.status_window.w, TRUE);
+#ifdef ENABLE_COLORS
if (options.enable_colors) {
/* set background attributes */
wbkgd(stdscr, COLOR_PAIR(COLOR_LIST));
@@ -512,6 +513,7 @@ screen_init(mpdclient_t *c)
wbkgd(screen.status_window.w, COLOR_PAIR(COLOR_STATUS));
colors_use(screen.progress_window.w, COLOR_PROGRESSBAR);
}
+#endif
refresh();