mirror of
https://github.com/rkd77/elinks.git
synced 2025-02-02 15:09:23 -05:00
[mono] _node colors
This commit is contained in:
parent
9782c7e761
commit
ed4175a4a7
@ -27,10 +27,12 @@ struct bfu_color_entry {
|
||||
|
||||
unsigned int node_number;
|
||||
|
||||
unsigned int was_color16_set:1;
|
||||
unsigned int was_color256_set:1;
|
||||
unsigned int was_color24_set:1;
|
||||
unsigned int was_mono:1;
|
||||
unsigned int was_color16:1;
|
||||
unsigned int was_color256:1;
|
||||
unsigned int was_color24:1;
|
||||
|
||||
struct screen_char mono;
|
||||
struct screen_char c16;
|
||||
struct screen_char c256;
|
||||
struct screen_char c24;
|
||||
@ -40,14 +42,27 @@ struct bfu_color_entry *node_entries[1024];
|
||||
|
||||
static struct hash *bfu_colors = NULL;
|
||||
|
||||
struct screen_char *
|
||||
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);
|
||||
entry->was_mono = 1;
|
||||
}
|
||||
|
||||
return &entry->mono;
|
||||
}
|
||||
|
||||
unsigned char *
|
||||
get_bfu_background_color16_node(unsigned int node_number)
|
||||
{
|
||||
struct bfu_color_entry *entry = node_entries[node_number];
|
||||
|
||||
if (!entry->was_color16_set) {
|
||||
if (!entry->was_color16) {
|
||||
set_term_color(&entry->c16, &entry->colors, 0, COLOR_MODE_16);
|
||||
entry->was_color16_set = 1;
|
||||
entry->was_color16 = 1;
|
||||
}
|
||||
|
||||
return &entry->c16.c.color[0];
|
||||
@ -58,9 +73,9 @@ get_bfu_foreground_color16_node(unsigned int node_number)
|
||||
{
|
||||
struct bfu_color_entry *entry = node_entries[node_number];
|
||||
|
||||
if (!entry->was_color16_set) {
|
||||
if (!entry->was_color16) {
|
||||
set_term_color(&entry->c16, &entry->colors, 0, COLOR_MODE_16);
|
||||
entry->was_color16_set = 1;
|
||||
entry->was_color16 = 1;
|
||||
}
|
||||
|
||||
return &entry->c16.c.color[0];
|
||||
@ -71,9 +86,9 @@ get_bfu_background_color256_node(unsigned int node_number)
|
||||
{
|
||||
struct bfu_color_entry *entry = node_entries[node_number];
|
||||
|
||||
if (!entry->was_color256_set) {
|
||||
if (!entry->was_color256) {
|
||||
set_term_color(&entry->c256, &entry->colors, 0, COLOR_MODE_256);
|
||||
entry->was_color256_set = 1;
|
||||
entry->was_color256 = 1;
|
||||
}
|
||||
|
||||
return TERM_COLOR_BACKGROUND_256(entry->c256.c.color);
|
||||
@ -84,9 +99,9 @@ get_bfu_foreground_color256_node(unsigned int node_number)
|
||||
{
|
||||
struct bfu_color_entry *entry = node_entries[node_number];
|
||||
|
||||
if (!entry->was_color256_set) {
|
||||
if (!entry->was_color256) {
|
||||
set_term_color(&entry->c256, &entry->colors, 0, COLOR_MODE_256);
|
||||
entry->was_color256_set = 1;
|
||||
entry->was_color256 = 1;
|
||||
}
|
||||
|
||||
return TERM_COLOR_FOREGROUND_256(entry->c256.c.color);
|
||||
@ -98,9 +113,9 @@ get_bfu_background_color_true_node(unsigned int node_number)
|
||||
{
|
||||
struct bfu_color_entry *entry = node_entries[node_number];
|
||||
|
||||
if (!entry->was_color24_set) {
|
||||
if (!entry->was_color24) {
|
||||
set_term_color(&entry->c24, &entry->colors, 0, COLOR_MODE_TRUE_COLOR);
|
||||
entry->was_color24_set = 1;
|
||||
entry->was_color24 = 1;
|
||||
}
|
||||
|
||||
return &entry->c24.c.color[3];
|
||||
@ -111,9 +126,9 @@ get_bfu_foreground_color_true_node(unsigned int node_number)
|
||||
{
|
||||
struct bfu_color_entry *entry = node_entries[node_number];
|
||||
|
||||
if (!entry->was_color24_set) {
|
||||
if (!entry->was_color24) {
|
||||
set_term_color(&entry->c24, &entry->colors, 0, COLOR_MODE_TRUE_COLOR);
|
||||
entry->was_color24_set = 1;
|
||||
entry->was_color24 = 1;
|
||||
}
|
||||
|
||||
return &entry->c24.c.color[0];
|
||||
|
@ -6,6 +6,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
struct color_pair;
|
||||
struct screen_char;
|
||||
struct terminal;
|
||||
|
||||
/** Get suitable BFU color for the specific terminal
|
||||
@ -27,6 +28,7 @@ get_bfu_color(struct terminal *term, const char *stylename);
|
||||
|
||||
unsigned int get_bfu_color_node(struct terminal *term, const char *stylename);
|
||||
|
||||
struct screen_char *get_bfu_mono_node(unsigned int node_number);
|
||||
unsigned char *get_bfu_background_color16_node(unsigned int node_number);
|
||||
unsigned char *get_bfu_foreground_color16_node(unsigned int node_number);
|
||||
unsigned char get_bfu_background_color256_node(unsigned int node_number);
|
||||
|
@ -443,6 +443,7 @@ static const struct screen_driver_opt *const screen_driver_opts[] = {
|
||||
|
||||
static INIT_LIST_OF(struct screen_driver, active_screen_drivers);
|
||||
|
||||
static struct screen_char *get_mono_from_node(struct screen_char *ch);
|
||||
|
||||
static unsigned char *get_foreground_color16_from_node(struct screen_char *ch);
|
||||
static unsigned char *get_background_color16_from_node(struct screen_char *ch);
|
||||
@ -878,6 +879,12 @@ static inline void
|
||||
add_char16(struct string *screen, struct screen_driver *driver,
|
||||
struct screen_char *ch, struct screen_state *state)
|
||||
{
|
||||
if ((driver->opt.color_mode == COLOR_MODE_MONO) && ch->is_node) {
|
||||
struct screen_char *ch2 = get_mono_from_node(ch);
|
||||
|
||||
ch->attr |= ch2->attr;
|
||||
}
|
||||
|
||||
unsigned char border = (ch->attr & SCREEN_ATTR_FRAME);
|
||||
unsigned char italic = (ch->attr & SCREEN_ATTR_ITALIC);
|
||||
unsigned char underline = (ch->attr & SCREEN_ATTR_UNDERLINE);
|
||||
@ -1093,6 +1100,20 @@ get_foreground_color_from_node(struct screen_char *ch)
|
||||
return ch->c.color[0];
|
||||
}
|
||||
|
||||
static struct screen_char *
|
||||
get_mono_from_node(struct screen_char *ch)
|
||||
{
|
||||
if (ch->is_node) {
|
||||
unsigned int node_number = ch->c.node_number;
|
||||
|
||||
if (node_number < 1024) {
|
||||
return get_bfu_mono_node(node_number);
|
||||
}
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
static unsigned char *
|
||||
get_background_color16_from_node(struct screen_char *ch)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user