mirror of
https://github.com/rkd77/elinks.git
synced 2025-02-02 15:09:23 -05:00
[bfu] Added get_bfu_color_node
This commit is contained in:
parent
095aac5753
commit
aab01cfae1
@ -28,10 +28,12 @@ struct bfu_color_entry {
|
||||
unsigned int node_number;
|
||||
};
|
||||
|
||||
struct bfu_color_entry *node_entries[1024];
|
||||
|
||||
static struct hash *bfu_colors = NULL;
|
||||
|
||||
struct color_pair *
|
||||
get_bfu_color(struct terminal *term, const char *stylename)
|
||||
static struct bfu_color_entry *
|
||||
get_bfu_color_common(struct terminal *term, const char *stylename)
|
||||
{
|
||||
static color_mode_T last_color_mode;
|
||||
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->node_number = ++node_number_counter;
|
||||
|
||||
node_entries[node_number_counter] = entry;
|
||||
}
|
||||
|
||||
/* Always update the color pair. */
|
||||
entry->colors.background = *entry->background;
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
done_bfu_colors(void)
|
||||
{
|
||||
|
@ -25,6 +25,9 @@ struct terminal;
|
||||
struct color_pair *
|
||||
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
|
||||
*
|
||||
* Free all resources used by the BFU style cache.
|
||||
|
Loading…
x
Reference in New Issue
Block a user