1
0
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:
Kalle Olavi Niemitalo 2006-12-25 11:25:06 +02:00 committed by Kalle Olavi Niemitalo
parent 2aad5c7d09
commit c56fb7d630
3 changed files with 21 additions and 4 deletions

View File

@ -301,6 +301,9 @@ set_term_color(struct screen_char *schar, struct color_pair *pair,
}
break;
default:
/* If the desired color mode was not compiled in,
* use 16 colors. */
case COLOR_MODE_16:
/* Decrease the range of the 16 palette to not include
* bright colors. */
@ -386,6 +389,9 @@ set_term_color(struct screen_char *schar, struct color_pair *pair,
case COLOR_MODE_TRUE_COLOR:
return;
#endif
default:
/* If the desired color mode was not compiled in,
* use 16 colors. */
case COLOR_MODE_MONO:
case COLOR_MODE_16:
set_term_color16(schar, flags, fg, bg);

View File

@ -612,7 +612,15 @@ add_char16(struct string *screen, struct screen_driver *driver,
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 bgcolor = TERM_COLOR_BACKGROUND_16(ch->color);
@ -956,6 +964,9 @@ redraw_screen(struct terminal *term)
if (!init_string(&image)) return;
switch (driver->color_mode) {
default:
/* If the desired color mode was not compiled in,
* use 16 colors. */
case COLOR_MODE_MONO:
case COLOR_MODE_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
case COLOR_MODES:
case COLOR_MODE_DUMP:
default:
INTERNAL("Invalid color mode (%d).", driver->color_mode);
return;
}

View File

@ -132,6 +132,9 @@ dump_formatted(int fd, struct download *download, struct cache_entry *cached)
case COLOR_MODE_MONO: /* FIXME: inversion */
dump_to_file(formatted.document, fd);
break;
default:
/* If the desired color mode was not compiled in,
* use 16 colors. */
case COLOR_MODE_16:
dump_to_file_16(formatted.document, fd);
break;
@ -150,8 +153,6 @@ dump_formatted(int fd, struct download *download, struct cache_entry *cached)
dump_to_file_true_color(formatted.document, fd);
break;
#endif
default:
break;
}
detach_formatted(&formatted);