1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-27 01:25:34 +00:00

[colors] Fix issue with mono colors and menu

This commit is contained in:
Witold Filipczyk 2022-03-24 16:05:33 +01:00
parent 17915976f5
commit ac0241f479
2 changed files with 24 additions and 4 deletions

View File

@ -21,9 +21,12 @@ struct bfu_color_entry {
/* Pointers to the options tree values. */ /* Pointers to the options tree values. */
color_T *background; color_T *background;
color_T *foreground; color_T *foreground;
color_T *background_mono;
color_T *foreground_mono;
/* The copy of "text" and "background" colors. */ /* The copy of "text" and "background" colors. */
struct color_pair colors; struct color_pair colors;
struct color_pair colors_mono;
unsigned int node_number; unsigned int node_number;
@ -43,6 +46,7 @@ struct bfu_color_entry {
struct bfu_color_entry *node_entries[1024]; struct bfu_color_entry *node_entries[1024];
static struct hash *bfu_colors = NULL; static struct hash *bfu_colors = NULL;
static int mode_changed = 0;
struct screen_char * struct screen_char *
get_bfu_mono_node(unsigned int node_number) get_bfu_mono_node(unsigned int node_number)
@ -50,7 +54,7 @@ get_bfu_mono_node(unsigned int node_number)
struct bfu_color_entry *entry = node_entries[node_number]; struct bfu_color_entry *entry = node_entries[node_number];
if (!entry->was_mono) { if (!entry->was_mono) {
set_term_color(&entry->mono, &entry->colors, 0, COLOR_MODE_MONO); set_term_color(&entry->mono, &entry->colors_mono, 0, COLOR_MODE_MONO);
entry->was_mono = 1; entry->was_mono = 1;
} }
@ -155,6 +159,7 @@ get_bfu_color_common(struct terminal *term, const char *stylename)
del_hash_item(bfu_colors, item->next); del_hash_item(bfu_colors, item->next);
} }
#endif #endif
mode_changed = 1;
last_color_mode = color_mode; last_color_mode = color_mode;
} }
@ -166,9 +171,7 @@ get_bfu_color_common(struct terminal *term, const char *stylename)
struct option *opt; struct option *opt;
/* Construct the color entry. */ /* Construct the color entry. */
opt = get_opt_rec_real(config_options, opt = get_opt_rec_real(config_options, "ui.colors.color");
color_mode != COLOR_MODE_MONO
? "ui.colors.color" : "ui.colors.mono");
if (!opt) return NULL; if (!opt) return NULL;
opt = get_opt_rec_real(opt, stylename); opt = get_opt_rec_real(opt, stylename);
@ -189,11 +192,22 @@ get_bfu_color_common(struct terminal *term, const char *stylename)
entry->node_number = ++node_number_counter; entry->node_number = ++node_number_counter;
node_entries[node_number_counter] = entry; node_entries[node_number_counter] = entry;
opt->node_number = node_number_counter; opt->node_number = node_number_counter;
opt = get_opt_rec_real(config_options, "ui.colors.mono");
if (opt) {
opt = get_opt_rec_real(opt, stylename);
if (opt) {
entry->foreground_mono = &get_opt_color_tree(opt, "text", NULL);
entry->background_mono = &get_opt_color_tree(opt, "background", NULL);
}
}
} }
/* Always update the color pair. */ /* Always update the color pair. */
entry->colors.background = *entry->background; entry->colors.background = *entry->background;
entry->colors.foreground = *entry->foreground; entry->colors.foreground = *entry->foreground;
entry->colors_mono.background = *entry->background_mono;
entry->colors_mono.foreground = *entry->foreground_mono;
return entry; return entry;
} }
@ -219,6 +233,11 @@ get_bfu_color_node(struct terminal *term, const char *stylename)
return 0; return 0;
} }
if (mode_changed) {
mode_changed = 0;
cls_redraw_all_terminals();
}
return entry->node_number; return entry->node_number;
} }

View File

@ -922,6 +922,7 @@ add_char16(struct string *screen, struct screen_driver *driver,
struct screen_char *ch2 = get_mono_from_node(ch); struct screen_char *ch2 = get_mono_from_node(ch);
copy.attr |= ch2->attr; copy.attr |= ch2->attr;
copy.c.color[0] = ch2->c.color[0];
} else { } else {
struct screen_char *ch2 = get_color16_from_node(ch); struct screen_char *ch2 = get_color16_from_node(ch);
copy.c.color[0] = ch2->c.color[0]; copy.c.color[0] = ch2->c.color[0];