コード例 #1
0
ファイル: terminal_ncurses.c プロジェクト: karlstav/cava
static void parse_color(char* color_string, struct colors* color) {
	if (color_string[0] == '#') {
		if (!can_change_color()) {
			cleanup_terminal_ncurses();
			fprintf(stderr, "Your terminal can not change color definitions, "
					"please use one of the predefined colors.\n");
			exit(EXIT_FAILURE);
		}
		color->color = COLOR_REDEFINITION;
		sscanf(++color_string, "%02hx%02hx%02hx", &color->R, &color->G, &color->B);
	}
}
コード例 #2
0
struct cols parse_color(char *col) {
	struct cols ret;

	if (col[0] == '#') {
		if (can_change_color() != TRUE) {
			cleanup_terminal_ncurses();
			fprintf(stderr,
				"Your terminal can not change color definitions, please use one of the predefined colors.\n");
			exit(EXIT_FAILURE);
		}

		// Set to -2 to indicate color_redefinition
		ret.col = -2;
		++col;
		sscanf(col, "%02x%02x%02x", &ret.R, &ret.G, &ret.B);
		return ret;
	} else {

	//using predefined colors
	ret.col = 0;

	return ret;
	}
}