added check to see if terminal suports manipulaing color definitions

master
karlstav 9 years ago
parent 2eca8b82a2
commit 8ad2a4cd80
  1. 22
      output/terminal_ncurses.c

@ -17,27 +17,27 @@ struct cols {
struct cols parse_color(char *col) { struct cols parse_color(char *col) {
struct cols ret; struct cols ret;
int has_colors = 0;
//if (has_colors() == TRUE) { if (col[0] == '#') {
has_colors = 1; if (has_colors() != TRUE) {
//} cleanup_terminal_ncurses();
// Only use the hexvalues if we are certain that the terminal fprintf(stderr,
// supports color redefinition, otherwise use default colours. "Your terminal can not manipulate colors, please use one of the predefined ones.\n");
if (col[0] == '#' && has_colors == 1) { exit(EXIT_FAILURE);
}
// Set to -2 to indicate color_redefinition // Set to -2 to indicate color_redefinition
ret.col = -2; ret.col = -2;
++col; ++col;
sscanf(col, "%02x%02x%02x", &ret.R, &ret.G, &ret.B); sscanf(col, "%02x%02x%02x", &ret.R, &ret.G, &ret.B);
return ret; return ret;
} else if (col[0] == '#' && has_colors == 0) { } else {
ret.col = -1;
return ret;
}
//using predefined colors //using predefined colors
ret.col = 0; ret.col = 0;
return ret; return ret;
}
} }
int init_terminal_ncurses(char *color, char *bcolor, int predefcol, int predefbgcol) { int init_terminal_ncurses(char *color, char *bcolor, int predefcol, int predefbgcol) {

Loading…
Cancel
Save