Blame alsamixer/colors.c

Packit Service a9274b
/*
Packit Service a9274b
 * colors.c - color and attribute definitions
Packit Service a9274b
 * Copyright (c) 1998,1999 Tim Janik
Packit Service a9274b
 *                         Jaroslav Kysela <perex@perex.cz>
Packit Service a9274b
 * Copyright (c) 2009      Clemens Ladisch <clemens@ladisch.de>
Packit Service a9274b
 *
Packit Service a9274b
 * This program is free software: you can redistribute it and/or modify
Packit Service a9274b
 * it under the terms of the GNU General Public License as published by
Packit Service a9274b
 * the Free Software Foundation, either version 2 of the License, or
Packit Service a9274b
 * (at your option) any later version.
Packit Service a9274b
 *
Packit Service a9274b
 * This program is distributed in the hope that it will be useful,
Packit Service a9274b
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service a9274b
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service a9274b
 * GNU General Public License for more details.
Packit Service a9274b
 *
Packit Service a9274b
 * You should have received a copy of the GNU General Public License
Packit Service a9274b
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit Service a9274b
 */
Packit Service a9274b
Packit Service a9274b
#include "aconfig.h"
Packit Service a9274b
#include CURSESINC
Packit Service a9274b
#include "colors.h"
Packit Service a9274b
Packit Service a9274b
struct attributes attrs;
Packit Service a9274b
Packit Service a9274b
int get_color_pair(short fg, short bg)
Packit Service a9274b
{
Packit Service a9274b
	static int color_pairs_defined = 0;
Packit Service a9274b
	short i, pair_fg, pair_bg;
Packit Service a9274b
Packit Service a9274b
	for (i = 1; i <= color_pairs_defined; ++i) {
Packit Service a9274b
		if (OK == pair_content(i, &pair_fg, &pair_bg))
Packit Service a9274b
			if (pair_fg == fg && pair_bg == bg)
Packit Service a9274b
				return COLOR_PAIR(i);
Packit Service a9274b
	}
Packit Service a9274b
Packit Service a9274b
	if (color_pairs_defined + 1 < COLOR_PAIRS) {
Packit Service a9274b
		++color_pairs_defined;
Packit Service a9274b
		init_pair(color_pairs_defined, fg, bg);
Packit Service a9274b
		return COLOR_PAIR(color_pairs_defined);
Packit Service a9274b
	}
Packit Service a9274b
Packit Service a9274b
	return 0;
Packit Service a9274b
}
Packit Service a9274b
Packit Service a9274b
void init_colors(int use_color)
Packit Service a9274b
{
Packit Service a9274b
	if (!!has_colors() == !!use_color) {
Packit Service a9274b
		start_color();
Packit Service a9274b
		use_default_colors();
Packit Service a9274b
Packit Service a9274b
		get_color_pair(COLOR_CYAN, COLOR_BLACK); // COLOR_PAIR(1)
Packit Service a9274b
		get_color_pair(COLOR_YELLOW, COLOR_BLACK);
Packit Service a9274b
		get_color_pair(COLOR_WHITE, COLOR_GREEN);
Packit Service a9274b
		get_color_pair(COLOR_RED, COLOR_BLACK);
Packit Service a9274b
		get_color_pair(COLOR_WHITE, COLOR_BLACK);
Packit Service a9274b
		get_color_pair(COLOR_WHITE, COLOR_BLUE);
Packit Service a9274b
		get_color_pair(COLOR_RED, COLOR_BLUE);
Packit Service a9274b
		get_color_pair(COLOR_GREEN, COLOR_GREEN);
Packit Service a9274b
		get_color_pair(COLOR_WHITE, COLOR_RED); // COLOR_PAIR(9)
Packit Service a9274b
#ifdef TRICOLOR_VOLUME_BAR
Packit Service a9274b
		get_color_pair(COLOR_WHITE, COLOR_WHITE);
Packit Service a9274b
		get_color_pair(COLOR_RED, COLOR_RED);
Packit Service a9274b
#endif
Packit Service a9274b
Packit Service a9274b
		attrs = (struct attributes) {
Packit Service a9274b
			.mixer_frame = COLOR_PAIR(1),
Packit Service a9274b
			.mixer_text = COLOR_PAIR(1),
Packit Service a9274b
			.mixer_active = A_BOLD | COLOR_PAIR(2),
Packit Service a9274b
			.ctl_frame = A_BOLD | COLOR_PAIR(1),
Packit Service a9274b
			.ctl_mute = COLOR_PAIR(1),
Packit Service a9274b
			.ctl_nomute = A_BOLD | COLOR_PAIR(3),
Packit Service a9274b
			.ctl_capture = A_BOLD | COLOR_PAIR(4),
Packit Service a9274b
			.ctl_nocapture = COLOR_PAIR(5),
Packit Service a9274b
			.ctl_label = A_BOLD | COLOR_PAIR(6),
Packit Service a9274b
			.ctl_label_focus = A_BOLD | COLOR_PAIR(7),
Packit Service a9274b
			.ctl_mark_focus = A_BOLD | COLOR_PAIR(4),
Packit Service a9274b
			.ctl_bar_lo = A_BOLD | COLOR_PAIR(8),
Packit Service a9274b
#ifdef TRICOLOR_VOLUME_BAR
Packit Service a9274b
			.ctl_bar_mi = A_BOLD | COLOR_PAIR(10),
Packit Service a9274b
			.ctl_bar_hi = A_BOLD | COLOR_PAIR(11),
Packit Service a9274b
#endif
Packit Service a9274b
			.ctl_inactive = COLOR_PAIR(5),
Packit Service a9274b
			.ctl_label_inactive = A_REVERSE | COLOR_PAIR(5),
Packit Service a9274b
			.errormsg = A_BOLD | COLOR_PAIR(9),
Packit Service a9274b
			.infomsg = A_BOLD | COLOR_PAIR(6),
Packit Service a9274b
			.textbox = A_BOLD | COLOR_PAIR(6),
Packit Service a9274b
			.textfield = A_REVERSE | COLOR_PAIR(5),
Packit Service a9274b
			.menu = A_BOLD | COLOR_PAIR(6),
Packit Service a9274b
			.menu_selected = A_REVERSE | COLOR_PAIR(6)
Packit Service a9274b
		};
Packit Service a9274b
	} else {
Packit Service a9274b
		attrs = (struct attributes) {
Packit Service a9274b
			.mixer_frame = A_NORMAL,
Packit Service a9274b
			.mixer_text = A_NORMAL,
Packit Service a9274b
			.mixer_active = A_BOLD,
Packit Service a9274b
			.ctl_frame = A_BOLD,
Packit Service a9274b
			.ctl_mute = A_NORMAL,
Packit Service a9274b
			.ctl_nomute = A_BOLD,
Packit Service a9274b
			.ctl_capture = A_BOLD,
Packit Service a9274b
			.ctl_nocapture = A_NORMAL,
Packit Service a9274b
			.ctl_label = A_REVERSE,
Packit Service a9274b
			.ctl_label_focus = A_REVERSE | A_BOLD,
Packit Service a9274b
			.ctl_mark_focus = A_BOLD,
Packit Service a9274b
			.ctl_bar_lo = A_BOLD,
Packit Service a9274b
#ifdef TRICOLOR_VOLUME_BAR
Packit Service a9274b
			.ctl_bar_mi = A_BOLD,
Packit Service a9274b
			.ctl_bar_hi = A_BOLD,
Packit Service a9274b
#endif
Packit Service a9274b
			.ctl_inactive = A_NORMAL,
Packit Service a9274b
			.ctl_label_inactive = A_REVERSE,
Packit Service a9274b
			.errormsg = A_STANDOUT,
Packit Service a9274b
			.infomsg = A_NORMAL,
Packit Service a9274b
			.textbox = A_NORMAL,
Packit Service a9274b
			.textfield = A_REVERSE,
Packit Service a9274b
			.menu = A_NORMAL,
Packit Service a9274b
			.menu_selected = A_REVERSE,
Packit Service a9274b
		};
Packit Service a9274b
	}
Packit Service a9274b
}