1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Bug 871, 752: Lock down enum color_mode and change option help to match.

The numbering of document.dump.color_mode and terminal._template_.colors
is now the same regardless of compile-time options, unlike in previous
versions.  Therefore this version of ELinks may interpret a configuration
file differently from previous versions even if compiled with the same
options.  This is unfortunate but the alternatives (keeping the numbering
dependent on configuration options; defining separate options that use
the new numbering; starting the numbers from 10 or so and recognizing the
previous ones only for compatibility) seem even worse.
This commit is contained in:
Kalle Olavi Niemitalo 2006-12-25 11:51:24 +02:00 committed by Kalle Olavi Niemitalo
parent c56fb7d630
commit b586bd99bc
3 changed files with 38 additions and 76 deletions

View File

@ -641,80 +641,20 @@ static struct option_info config_options_info[] = {
N_("Codepage used in dump output. 'System' stands for\n"
"a codepage determined by a selected locale.")),
/* The #if directives cannot be inside the argument list of
* the INIT_OPT_INT macro; that wouldn't be standard C.
* And they especially cannot be inside the argument list of N_;
* xgettext (GNU gettext-tools) 0.14.3 wouldn't support that. */
/* FIXME: It's totally brainless --witekfl */
#if defined(CONFIG_88_COLORS) && defined(CONFIG_256_COLORS) && !defined(CONFIG_TRUE_COLOR)
INIT_OPT_INT("document.dump", N_("Color mode"),
"color_mode", 0, -1, 3, -1,
N_("Color mode for dumps:\n"
"-1 is standard dump mode\n"
"0 is mono mode\n"
"1 is 16 color mode\n"
"2 is 88 color mode\n"
"3 is 256 color mode")),
#elif defined(CONFIG_88_COLORS) && !defined(CONFIG_256_COLORS) && !defined(CONFIG_TRUE_COLOR)
INIT_OPT_INT("document.dump", N_("Color mode"),
"color_mode", 0, -1, 2, -1,
N_("Color mode for dumps:\n"
"-1 is standard dump mode\n"
"0 is mono mode\n"
"1 is 16 color mode\n"
"2 is 88 color mode")),
#elif defined(CONFIG_256_COLORS) && !defined(CONFIG_88_COLORS) && !defined(CONFIG_TRUE_COLOR)
INIT_OPT_INT("document.dump", N_("Color mode"),
"color_mode", 0, -1, 2, -1,
N_("Color mode for dumps:\n"
"-1 is standard dump mode\n"
"0 is mono mode\n"
"1 is 16 color mode\n"
"2 is 256 color mode")),
#elif !defined(CONFIG_88_COLORS) && !defined(CONFIG_256_COLORS) && !defined(CONFIG_TRUE_COLOR)
INIT_OPT_INT("document.dump", N_("Color mode"),
"color_mode", 0, -1, 1, -1,
N_("Color mode for dumps:\n"
"-1 is standard dump mode\n"
"0 is mono mode\n"
"1 is 16 color mode")),
#elif defined(CONFIG_88_COLORS) && defined(CONFIG_256_COLORS) && defined(CONFIG_TRUE_COLOR)
INIT_OPT_INT("document.dump", N_("Color mode"),
"color_mode", 0, -1, 4, -1,
"color_mode", 0, -1, COLOR_MODES - 1, -1,
N_("Color mode for dumps:\n"
"-1 is standard dump mode\n"
"0 is mono mode\n"
"1 is 16 color mode\n"
"2 is 88 color mode\n"
"3 is 256 color mode\n"
"4 is true color mode")),
#elif defined(CONFIG_88_COLORS) && !defined(CONFIG_256_COLORS) && defined(CONFIG_TRUE_COLOR)
INIT_OPT_INT("document.dump", N_("Color mode"),
"color_mode", 0, -1, 3, -1,
N_("Color mode for dumps:\n"
"-1 is standard dump mode\n"
"0 is mono mode\n"
"1 is 16 color mode\n"
"2 is 88 color mode\n"
"3 is true color mode")),
#elif defined(CONFIG_256_COLORS) && !defined(CONFIG_88_COLORS) && defined(CONFIG_TRUE_COLOR)
INIT_OPT_INT("document.dump", N_("Color mode"),
"color_mode", 0, -1, 3, -1,
N_("Color mode for dumps:\n"
"-1 is standard dump mode\n"
"0 is mono mode\n"
"1 is 16 color mode\n"
"2 is 256 color mode\n"
"3 is true color mode")),
#elif !defined(CONFIG_88_COLORS) && !defined(CONFIG_256_COLORS) && defined(CONFIG_TRUE_COLOR)
INIT_OPT_INT("document.dump", N_("Color mode"),
"color_mode", 0, -1, 2, -1,
N_("Color mode for dumps:\n"
"-1 is standard dump mode\n"
"0 is mono mode\n"
"1 is 16 color mode\n"
"2 is true color mode")),
#endif /* !defined(CONFIG_88_COLORS) && !defined(CONFIG_256_COLORS) */
"4 is true color mode\n"
"Some of these may have been disabled at compile time. "
"The Setup -> Terminal options dialog lists the modes "
"supported by this executable. If you select an "
"unsupported mode, ELinks uses 16 colors.")),
INIT_OPT_STRING("document.dump", N_("Footer"),
"footer", 0, "",
N_("Footer string used in dumps. %u is substituted by URL.")),
@ -909,12 +849,17 @@ static struct option_info config_options_info[] = {
INIT_OPT_INT("terminal._template_", N_("Color mode"),
"colors", 0, 0, COLOR_MODES - 1, 0,
N_("The color mode controls what colors are used and how they are\n"
N_("The color mode controls what colors are used and how they are "
"output to the terminal. The color modes are:\n"
"0 is mono mode, only 2 colors are used\n"
"1 is 16 color mode, uses the common ANSI colors\n"
"2 is 256 color mode, uses XTerm RGB codes\n"
"3 is true color mode, uses konsole RGB codes.")),
"2 is 88 color mode, uses XTerm RGB codes\n"
"3 is 256 color mode, uses XTerm RGB codes\n"
"4 is true color mode, uses konsole RGB codes.\n"
"Some of these may have been disabled at compile time. "
"The Setup -> Terminal options dialog lists the modes "
"supported by this executable. If you select an "
"unsupported mode, ELinks uses 16 colors.")),
INIT_OPT_BOOL("terminal._template_", N_("Transparency"),
"transparency", 0, 0,

View File

@ -161,11 +161,22 @@ static const struct color_mode_info *const color_modes[] = {
/* COLOR_MODE_16 */ &color_mode_16,
#ifdef CONFIG_88_COLORS
/* COLOR_MODE_88 */ &color_mode_88,
#else
/* COLOR_MODE_88 */ &color_mode_16,
#endif
#ifdef CONFIG_256_COLORS
/* COLOR_MODE_256 */ &color_mode_256,
#else
/* COLOR_MODE_256 */ &color_mode_16,
#endif
/* @set_term_color reads @color_modes[COLOR_MODE_TRUE_COLOR]
* only if CONFIG_TRUE_COLOR is not defined. */
/* COLOR_MODE_TRUE_COLOR */ &color_mode_16,
};
/* Get a compile-time error if the array has the wrong size. */
typedef int assert_enough_color_modes[
(sizeof(color_modes) / sizeof(color_modes[0]) == COLOR_MODES)
? 1 : -1];
/* Colors values used in the foreground color table:
*

View File

@ -40,20 +40,26 @@ enum color_flags {
COLOR_ENSURE_INVERTED_CONTRAST = 16,
};
/* These numbers are used in the terminal._template_.colors and
* document.dump.color_mode options. They should be kept stable so
* that configuration files are portable between ELinks versions.
* Any unsupported modes should be treated as COLOR_MODE_16.
* (Can't fall back to COLOR_MODE_88 from COLOR_MODE_256 because
* the palettes are incompatible.) */
enum color_mode {
COLOR_MODE_DUMP = -1,
COLOR_MODE_MONO,
COLOR_MODE_16,
COLOR_MODE_MONO = 0,
COLOR_MODE_16 = 1,
#ifdef CONFIG_88_COLORS
COLOR_MODE_88,
COLOR_MODE_88 = 2,
#endif
#ifdef CONFIG_256_COLORS
COLOR_MODE_256,
COLOR_MODE_256 = 3,
#endif
#ifdef CONFIG_TRUE_COLOR
COLOR_MODE_TRUE_COLOR,
COLOR_MODE_TRUE_COLOR = 4,
#endif
COLOR_MODES, /* XXX: Keep last */
COLOR_MODES = 5, /* XXX: Keep last */
};
inline void set_term_color16(struct screen_char *schar, enum color_flags flags,