summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3e70743)
raw | patch | inline | side by side (parent: 3e70743)
author | Max Kellermann <max@duempel.org> | |
Fri, 3 Oct 2008 12:25:00 +0000 (14:25 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Fri, 3 Oct 2008 12:25:00 +0000 (14:25 +0200) |
Default is colors disabled. Those who love colorful terminals have
the option to enable it with --enable-colors.
the option to enable it with --enable-colors.
configure.ac | patch | blob | history | |
src/colors.c | patch | blob | history | |
src/colors.h | patch | blob | history | |
src/conf.c | patch | blob | history | |
src/ncu.c | patch | blob | history | |
src/options.c | patch | blob | history | |
src/options.h | patch | blob | history | |
src/screen.c | patch | blob | history |
diff --git a/configure.ac b/configure.ac
index 732b36f1e93647e1e9aa710b86611e17f0d10be4..83a47a7d11311d22917fa71630afb61bbd66df11 100644 (file)
--- a/configure.ac
+++ b/configure.ac
AC_DEFINE([ENABLE_RAW_MODE], [1], [Place the terminal into raw mode])
fi
+dnl enable colors
+AC_MSG_CHECKING([color support])
+AC_ARG_ENABLE([colors],
+ AC_HELP_STRING([--enable-colors],
+ [Enable color support]),
+ [use_colors=$enableval],
+ [use_colors=no])
+AC_MSG_RESULT([$use_colors])
+if test "x$use_colors" = "xyes" ; then
+ AC_DEFINE([ENABLE_COLORS], [1], [Enable color support])
+fi
+
dnl Debugging
AC_MSG_CHECKING([whether to build with debug support])
AC_ARG_ENABLE([debug],
diff --git a/src/colors.c b/src/colors.c
index 68c5b600753998d821a4209683cb1f0e08e2d1c9..0bcf2782c8a76677122d32f3d6cfdd3af2bb426c 100644 (file)
--- a/src/colors.c
+++ b/src/colors.c
#include "colors.h"
#include "i18n.h"
+#ifdef ENABLE_COLORS
#include "options.h"
+#endif
#include <assert.h>
#include <stdio.h>
#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;
[COLOR_STATUS_ALERT] = { NAME_ALERT, COLOR_BRIGHT_RED, A_BOLD },
};
+#ifdef ENABLE_COLORS
+
/* background color */
static short bg = COLOR_BLACK;
return 0;
}
+
int
colors_start(void)
{
return 0;
}
+#endif
int
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 b612a33ce0ba93a8b5a8ee4573a574ab899a5dd9..051aa9e26b76b6e050aabaf270d1f2ba690b534d 100644 (file)
--- a/src/colors.h
+++ b/src/colors.h
#ifndef COLORS_H
#define COLORS_H
+#include "config.h"
+
#include <ncurses.h>
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 5dff1ccdfd798e8555aca5abc672086ccef29307..4485cda5981660676f4de691d81bdf7a9cde96ff 100644 (file)
--- a/src/conf.c
+++ b/src/conf.c
}
}
+#ifdef ENABLE_COLORS
static int
parse_color(char *str)
{
g_free(name);
return value;
}
+#endif
static char *
get_format(char *str)
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);
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 ed3c2273b021b7f76a7b9b9e610b87c24ba3ff66..936e78aa5b52e351be499add2a9015c9fb16afc5 100644 (file)
--- a/src/ncu.c
+++ b/src/ncu.c
*/
#include "ncu.h"
+
+#ifdef ENABLE_COLORS
#include "colors.h"
+#endif
+
+#ifdef HAVE_GETMOUSE
+#include "options.h"
+#endif
+
+#include <ncurses.h>
void
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 75f074a63a5e46c763774bd203c3a2caa89da9ba..1b592a567fa39e0035144255b081a7e96371ae2b 100644 (file)
--- a/src/options.c
+++ b/src/options.c
#ifdef ENABLE_NLS
" nls"
#endif
+#ifdef ENABLE_COLORS
+ " colors"
+#else
+ " no-colors"
+#endif
#ifdef HAVE_GETMOUSE
" getmouse"
#endif
"\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 70853f4ff1f3180edc028710e02b9bff8d18f6e3..e7e9e8f4c358b03598d32a009d2500f24b6b41cb 100644 (file)
--- a/src/options.h
+++ b/src/options.h
#ifndef OPTIONS_H
#define OPTIONS_H
+#include "config.h"
+
#include <stdbool.h>
#define MPD_HOST_ENV "MPD_HOST"
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 231d84adad1aab40a86884c312aaf3924de4cbf9..2fd4b571f3123324f410d27e0504399e0ff4a710 100644 (file)
--- a/src/screen.c
+++ b/src/screen.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));
wbkgd(screen.status_window.w, COLOR_PAIR(COLOR_STATUS));
colors_use(screen.progress_window.w, COLOR_PROGRESSBAR);
}
+#endif
refresh();