mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Bug 871: Fall back to 16 colors if color_mode is unsupported.
There may currently be no way to select an unsupported mode, but the next commit will change that.
This commit is contained in:
parent
2aad5c7d09
commit
c56fb7d630
@ -301,6 +301,9 @@ set_term_color(struct screen_char *schar, struct color_pair *pair,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* If the desired color mode was not compiled in,
|
||||||
|
* use 16 colors. */
|
||||||
case COLOR_MODE_16:
|
case COLOR_MODE_16:
|
||||||
/* Decrease the range of the 16 palette to not include
|
/* Decrease the range of the 16 palette to not include
|
||||||
* bright colors. */
|
* bright colors. */
|
||||||
@ -386,6 +389,9 @@ set_term_color(struct screen_char *schar, struct color_pair *pair,
|
|||||||
case COLOR_MODE_TRUE_COLOR:
|
case COLOR_MODE_TRUE_COLOR:
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
default:
|
||||||
|
/* If the desired color mode was not compiled in,
|
||||||
|
* use 16 colors. */
|
||||||
case COLOR_MODE_MONO:
|
case COLOR_MODE_MONO:
|
||||||
case COLOR_MODE_16:
|
case COLOR_MODE_16:
|
||||||
set_term_color16(schar, flags, fg, bg);
|
set_term_color16(schar, flags, fg, bg);
|
||||||
|
@ -612,7 +612,15 @@ add_char16(struct string *screen, struct screen_driver *driver,
|
|||||||
|
|
||||||
add_bytes_to_string(screen, "\033[0", 3);
|
add_bytes_to_string(screen, "\033[0", 3);
|
||||||
|
|
||||||
if (driver->color_mode == COLOR_MODE_16) {
|
/* @update_screen_driver has set @driver->color_mode
|
||||||
|
* according to terminal-type-specific options.
|
||||||
|
* The caller of @add_char16 has already partially
|
||||||
|
* checked it, but there are still these possibilities:
|
||||||
|
* - COLOR_MODE_MONO. Then don't show colors, but
|
||||||
|
* perhaps use the standout attribute.
|
||||||
|
* - COLOR_MODE_16. Use 16 colors.
|
||||||
|
* - An unsupported color mode. Use 16 colors. */
|
||||||
|
if (driver->color_mode != COLOR_MODE_MONO) {
|
||||||
unsigned char code[6] = ";30;40";
|
unsigned char code[6] = ";30;40";
|
||||||
unsigned char bgcolor = TERM_COLOR_BACKGROUND_16(ch->color);
|
unsigned char bgcolor = TERM_COLOR_BACKGROUND_16(ch->color);
|
||||||
|
|
||||||
@ -956,6 +964,9 @@ redraw_screen(struct terminal *term)
|
|||||||
if (!init_string(&image)) return;
|
if (!init_string(&image)) return;
|
||||||
|
|
||||||
switch (driver->color_mode) {
|
switch (driver->color_mode) {
|
||||||
|
default:
|
||||||
|
/* If the desired color mode was not compiled in,
|
||||||
|
* use 16 colors. */
|
||||||
case COLOR_MODE_MONO:
|
case COLOR_MODE_MONO:
|
||||||
case COLOR_MODE_16:
|
case COLOR_MODE_16:
|
||||||
add_chars(&image, term, driver, &state, add_char16, compare_bg_color_16, compare_fg_color_16);
|
add_chars(&image, term, driver, &state, add_char16, compare_bg_color_16, compare_fg_color_16);
|
||||||
@ -977,7 +988,6 @@ redraw_screen(struct terminal *term)
|
|||||||
#endif
|
#endif
|
||||||
case COLOR_MODES:
|
case COLOR_MODES:
|
||||||
case COLOR_MODE_DUMP:
|
case COLOR_MODE_DUMP:
|
||||||
default:
|
|
||||||
INTERNAL("Invalid color mode (%d).", driver->color_mode);
|
INTERNAL("Invalid color mode (%d).", driver->color_mode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -132,6 +132,9 @@ dump_formatted(int fd, struct download *download, struct cache_entry *cached)
|
|||||||
case COLOR_MODE_MONO: /* FIXME: inversion */
|
case COLOR_MODE_MONO: /* FIXME: inversion */
|
||||||
dump_to_file(formatted.document, fd);
|
dump_to_file(formatted.document, fd);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
/* If the desired color mode was not compiled in,
|
||||||
|
* use 16 colors. */
|
||||||
case COLOR_MODE_16:
|
case COLOR_MODE_16:
|
||||||
dump_to_file_16(formatted.document, fd);
|
dump_to_file_16(formatted.document, fd);
|
||||||
break;
|
break;
|
||||||
@ -150,8 +153,6 @@ dump_formatted(int fd, struct download *download, struct cache_entry *cached)
|
|||||||
dump_to_file_true_color(formatted.document, fd);
|
dump_to_file_true_color(formatted.document, fd);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
detach_formatted(&formatted);
|
detach_formatted(&formatted);
|
||||||
|
Loading…
Reference in New Issue
Block a user