1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-12 23:10:51 +00:00

[colors] Implemented displaying for 256 color mode

This commit is contained in:
Witold Filipczyk 2022-03-18 16:24:48 +01:00
parent 4b93f841a8
commit 407ca7d114
3 changed files with 46 additions and 2 deletions

View File

@ -26,12 +26,43 @@ struct bfu_color_entry {
struct color_pair colors;
unsigned int node_number;
unsigned int was_color256_set:1;
struct screen_char c256;
struct screen_char c24;
};
struct bfu_color_entry *node_entries[1024];
static struct hash *bfu_colors = NULL;
unsigned char
get_bfu_background_color256_node(unsigned int node_number)
{
struct bfu_color_entry *entry = node_entries[node_number];
if (!entry->was_color256_set) {
set_term_color(&entry->c256, &entry->colors, 0, COLOR_MODE_256);
entry->was_color256_set = 1;
}
return TERM_COLOR_BACKGROUND_256(entry->c256.c.color);
}
unsigned char
get_bfu_foreground_color256_node(unsigned int node_number)
{
struct bfu_color_entry *entry = node_entries[node_number];
if (!entry->was_color256_set) {
set_term_color(&entry->c256, &entry->colors, 0, COLOR_MODE_256);
entry->was_color256_set = 1;
}
return TERM_COLOR_FOREGROUND_256(entry->c256.c.color);
}
static struct bfu_color_entry *
get_bfu_color_common(struct terminal *term, const char *stylename)
{

View File

@ -27,6 +27,8 @@ get_bfu_color(struct terminal *term, const char *stylename);
unsigned int get_bfu_color_node(struct terminal *term, const char *stylename);
unsigned char get_bfu_background_color256_node(unsigned int node_number);
unsigned char get_bfu_foreground_color256_node(unsigned int node_number);
/** Cleanup after the BFU style cache
*

View File

@ -10,6 +10,7 @@
#include "elinks.h"
#include "bfu/style.h"
#include "config/options.h"
#include "intl/charsets.h"
#include "main/module.h"
@ -1067,14 +1068,24 @@ add_char_color(struct string *screen, const struct string *seq, unsigned char co
static unsigned char
get_background_color_from_node(struct screen_char *ch)
{
/* TODO */
unsigned int node_number = ch->c.node_number;
if (node_number < 1024) {
return get_bfu_background_color256_node(node_number);
}
return ch->c.color[1];
}
static unsigned char
get_foreground_color_from_node(struct screen_char *ch)
{
/* TODO */
unsigned int node_number = ch->c.node_number;
if (node_number < 1024) {
return get_bfu_foreground_color256_node(node_number);
}
return ch->c.color[0];
}