aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKalle Wallin <kaw@linux.se>2004-03-27 12:03:40 +0000
committerKalle Wallin <kaw@linux.se>2004-03-27 12:03:40 +0000
commitdfdd6d63a8503b305de36ef8733f9734da9b78f7 (patch)
tree8089d91ae8014804be1088f3d1357efd07e33100
parent19d591bb4a00e19baf6d31c263f695792548b587 (diff)
downloadmpd-dfdd6d63a8503b305de36ef8733f9734da9b78f7.tar.gz
mpd-dfdd6d63a8503b305de36ef8733f9734da9b78f7.tar.xz
mpd-dfdd6d63a8503b305de36ef8733f9734da9b78f7.zip
Only use colors if the terminal supports colors.
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@508 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r--screen.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/screen.c b/screen.c
index a63af20f6..37f514622 100644
--- a/screen.c
+++ b/screen.c
@@ -266,18 +266,26 @@ screen_init(void)
{
/* initialize the curses library */
initscr();
- start_color();
- if( options.enable_colors )
+ if( has_colors() )
+ {
+ start_color();
+ if( options.enable_colors )
+ {
+ init_pair(1, options.title_color, options.bg_color);
+ init_pair(2, options.line_color, options.bg_color);
+ init_pair(3, options.list_color, options.bg_color);
+ init_pair(4, options.progress_color, options.bg_color);
+ init_pair(5, options.status_color, options.bg_color);
+ init_pair(6, options.alert_color, options.bg_color);
+ }
+ else
+ use_default_colors();
+ }
+ else if( options.enable_colors )
{
- init_pair(1, options.title_color, options.bg_color);
- init_pair(2, options.line_color, options.bg_color);
- init_pair(3, options.list_color, options.bg_color);
- init_pair(4, options.progress_color, options.bg_color);
- init_pair(5, options.status_color, options.bg_color);
- init_pair(6, options.alert_color, options.bg_color);
+ fprintf(stderr, "Terminal lacks color capabilities.\n");
+ options.enable_colors = 0;
}
- else
- use_default_colors();
/* tell curses not to do NL->CR/NL on output */
nonl();
@@ -333,6 +341,7 @@ screen_init(void)
screen->helplist = list_window_init( screen->main_window.w,
screen->main_window.cols,
screen->main_window.rows );
+
leaveok(screen->main_window.w, TRUE);
keypad(screen->main_window.w, TRUE);
@@ -361,9 +370,6 @@ screen_init(void)
/* set background attributes */
wbkgd(screen->main_window.w, LIST_COLORS);
wbkgd(screen->top_window.w, TITLE_COLORS);
- wbkgd(screen->playlist->w, LIST_COLORS);
- wbkgd(screen->filelist->w, LIST_COLORS);
- wbkgd(screen->helplist->w, LIST_COLORS);
wbkgd(screen->progress_window.w, PROGRESS_COLORS);
wbkgd(screen->status_window.w, STATUS_COLORS);
}