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:
parent
c56fb7d630
commit
b586bd99bc
@ -641,80 +641,20 @@ static struct option_info config_options_info[] = {
|
|||||||
N_("Codepage used in dump output. 'System' stands for\n"
|
N_("Codepage used in dump output. 'System' stands for\n"
|
||||||
"a codepage determined by a selected locale.")),
|
"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"),
|
INIT_OPT_INT("document.dump", N_("Color mode"),
|
||||||
"color_mode", 0, -1, 3, -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")),
|
|
||||||
#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,
|
|
||||||
N_("Color mode for dumps:\n"
|
N_("Color mode for dumps:\n"
|
||||||
"-1 is standard dump mode\n"
|
"-1 is standard dump mode\n"
|
||||||
"0 is mono mode\n"
|
"0 is mono mode\n"
|
||||||
"1 is 16 color mode\n"
|
"1 is 16 color mode\n"
|
||||||
"2 is 88 color mode\n"
|
"2 is 88 color mode\n"
|
||||||
"3 is 256 color mode\n"
|
"3 is 256 color mode\n"
|
||||||
"4 is true color mode")),
|
"4 is true color mode\n"
|
||||||
#elif defined(CONFIG_88_COLORS) && !defined(CONFIG_256_COLORS) && defined(CONFIG_TRUE_COLOR)
|
"Some of these may have been disabled at compile time. "
|
||||||
INIT_OPT_INT("document.dump", N_("Color mode"),
|
"The Setup -> Terminal options dialog lists the modes "
|
||||||
"color_mode", 0, -1, 3, -1,
|
"supported by this executable. If you select an "
|
||||||
N_("Color mode for dumps:\n"
|
"unsupported mode, ELinks uses 16 colors.")),
|
||||||
"-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) */
|
|
||||||
INIT_OPT_STRING("document.dump", N_("Footer"),
|
INIT_OPT_STRING("document.dump", N_("Footer"),
|
||||||
"footer", 0, "",
|
"footer", 0, "",
|
||||||
N_("Footer string used in dumps. %u is substituted by URL.")),
|
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"),
|
INIT_OPT_INT("terminal._template_", N_("Color mode"),
|
||||||
"colors", 0, 0, COLOR_MODES - 1, 0,
|
"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"
|
"output to the terminal. The color modes are:\n"
|
||||||
"0 is mono mode, only 2 colors are used\n"
|
"0 is mono mode, only 2 colors are used\n"
|
||||||
"1 is 16 color mode, uses the common ANSI colors\n"
|
"1 is 16 color mode, uses the common ANSI colors\n"
|
||||||
"2 is 256 color mode, uses XTerm RGB codes\n"
|
"2 is 88 color mode, uses XTerm RGB codes\n"
|
||||||
"3 is true color mode, uses konsole RGB codes.")),
|
"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"),
|
INIT_OPT_BOOL("terminal._template_", N_("Transparency"),
|
||||||
"transparency", 0, 0,
|
"transparency", 0, 0,
|
||||||
|
@ -161,11 +161,22 @@ static const struct color_mode_info *const color_modes[] = {
|
|||||||
/* COLOR_MODE_16 */ &color_mode_16,
|
/* COLOR_MODE_16 */ &color_mode_16,
|
||||||
#ifdef CONFIG_88_COLORS
|
#ifdef CONFIG_88_COLORS
|
||||||
/* COLOR_MODE_88 */ &color_mode_88,
|
/* COLOR_MODE_88 */ &color_mode_88,
|
||||||
|
#else
|
||||||
|
/* COLOR_MODE_88 */ &color_mode_16,
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_256_COLORS
|
#ifdef CONFIG_256_COLORS
|
||||||
/* COLOR_MODE_256 */ &color_mode_256,
|
/* COLOR_MODE_256 */ &color_mode_256,
|
||||||
|
#else
|
||||||
|
/* COLOR_MODE_256 */ &color_mode_16,
|
||||||
#endif
|
#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:
|
/* Colors values used in the foreground color table:
|
||||||
*
|
*
|
||||||
|
@ -40,20 +40,26 @@ enum color_flags {
|
|||||||
COLOR_ENSURE_INVERTED_CONTRAST = 16,
|
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 {
|
enum color_mode {
|
||||||
COLOR_MODE_DUMP = -1,
|
COLOR_MODE_DUMP = -1,
|
||||||
COLOR_MODE_MONO,
|
COLOR_MODE_MONO = 0,
|
||||||
COLOR_MODE_16,
|
COLOR_MODE_16 = 1,
|
||||||
#ifdef CONFIG_88_COLORS
|
#ifdef CONFIG_88_COLORS
|
||||||
COLOR_MODE_88,
|
COLOR_MODE_88 = 2,
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_256_COLORS
|
#ifdef CONFIG_256_COLORS
|
||||||
COLOR_MODE_256,
|
COLOR_MODE_256 = 3,
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_TRUE_COLOR
|
#ifdef CONFIG_TRUE_COLOR
|
||||||
COLOR_MODE_TRUE_COLOR,
|
COLOR_MODE_TRUE_COLOR = 4,
|
||||||
#endif
|
#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,
|
inline void set_term_color16(struct screen_char *schar, enum color_flags flags,
|
||||||
|
Loading…
Reference in New Issue
Block a user