1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-17 06:24:12 -04:00

[bfu] Added get_bfu_color_node

This commit is contained in:
Witold Filipczyk 2022-03-10 18:27:37 +01:00
parent 095aac5753
commit aab01cfae1
2 changed files with 32 additions and 3 deletions

View File

@ -28,10 +28,12 @@ struct bfu_color_entry {
unsigned int node_number; unsigned int node_number;
}; };
struct bfu_color_entry *node_entries[1024];
static struct hash *bfu_colors = NULL; static struct hash *bfu_colors = NULL;
struct color_pair * static struct bfu_color_entry *
get_bfu_color(struct terminal *term, const char *stylename) get_bfu_color_common(struct terminal *term, const char *stylename)
{ {
static color_mode_T last_color_mode; static color_mode_T last_color_mode;
struct bfu_color_entry *entry; struct bfu_color_entry *entry;
@ -93,16 +95,40 @@ get_bfu_color(struct terminal *term, const char *stylename)
entry->background = &get_opt_color_tree(opt, "background", NULL); entry->background = &get_opt_color_tree(opt, "background", NULL);
entry->node_number = ++node_number_counter; entry->node_number = ++node_number_counter;
node_entries[node_number_counter] = entry;
} }
/* 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;
return entry;
}
struct color_pair *
get_bfu_color(struct terminal *term, const char *stylename)
{
struct bfu_color_entry *entry = get_bfu_color_common(term, stylename);
if (!entry) {
return NULL;
}
return &entry->colors; return &entry->colors;
} }
unsigned int
get_bfu_color_node(struct terminal *term, const char *stylename)
{
struct bfu_color_entry *entry = get_bfu_color_common(term, stylename);
if (!entry) {
return 0;
}
return entry->node_number;
}
void void
done_bfu_colors(void) done_bfu_colors(void)
{ {

View File

@ -25,6 +25,9 @@ struct terminal;
struct color_pair * struct color_pair *
get_bfu_color(struct terminal *term, const char *stylename); get_bfu_color(struct terminal *term, const char *stylename);
unsigned int get_bfu_color_node(struct terminal *term, const char *stylename);
/** Cleanup after the BFU style cache /** Cleanup after the BFU style cache
* *
* Free all resources used by the BFU style cache. * Free all resources used by the BFU style cache.