1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-20 00:15:31 +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. */
color_T *background;
color_T *foreground;
color_T *background_mono;
color_T *foreground_mono;
/* The copy of "text" and "background" colors. */
struct color_pair colors;
struct color_pair colors_mono;
unsigned int node_number;
@ -43,6 +46,7 @@ struct bfu_color_entry {
struct bfu_color_entry *node_entries[1024];
static struct hash *bfu_colors = NULL;
static int mode_changed = 0;
struct screen_char *
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];
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;
}
@ -155,6 +159,7 @@ get_bfu_color_common(struct terminal *term, const char *stylename)
del_hash_item(bfu_colors, item->next);
}
#endif
mode_changed = 1;
last_color_mode = color_mode;
}
@ -166,9 +171,7 @@ get_bfu_color_common(struct terminal *term, const char *stylename)
struct option *opt;
/* Construct the color entry. */
opt = get_opt_rec_real(config_options,
color_mode != COLOR_MODE_MONO
? "ui.colors.color" : "ui.colors.mono");
opt = get_opt_rec_real(config_options, "ui.colors.color");
if (!opt) return NULL;
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;
node_entries[node_number_counter] = entry;
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. */
entry->colors.background = *entry->background;
entry->colors.foreground = *entry->foreground;
entry->colors_mono.background = *entry->background_mono;
entry->colors_mono.foreground = *entry->foreground_mono;
return entry;
}
@ -219,6 +233,11 @@ get_bfu_color_node(struct terminal *term, const char *stylename)
return 0;
}
if (mode_changed) {
mode_changed = 0;
cls_redraw_all_terminals();
}
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);
copy.attr |= ch2->attr;
copy.c.color[0] = ch2->c.color[0];
} else {
struct screen_char *ch2 = get_color16_from_node(ch);
copy.c.color[0] = ch2->c.color[0];