mirror of
https://github.com/rkd77/elinks.git
synced 2025-02-02 15:09:23 -05:00
[colors] Simplifications
This commit is contained in:
parent
411b25cecc
commit
085c2ebd95
@ -70,8 +70,8 @@ get_bfu_color16_node(unsigned int node_number)
|
||||
return &entry->c16;
|
||||
}
|
||||
|
||||
unsigned char
|
||||
get_bfu_background_color88_node(unsigned int node_number)
|
||||
struct screen_char *
|
||||
get_bfu_color88_node(unsigned int node_number)
|
||||
{
|
||||
struct bfu_color_entry *entry = node_entries[node_number];
|
||||
|
||||
@ -80,24 +80,11 @@ get_bfu_background_color88_node(unsigned int node_number)
|
||||
entry->was_color88 = 1;
|
||||
}
|
||||
|
||||
return TERM_COLOR_BACKGROUND_256(entry->c88.c.color);
|
||||
return &entry->c88;
|
||||
}
|
||||
|
||||
unsigned char
|
||||
get_bfu_foreground_color88_node(unsigned int node_number)
|
||||
{
|
||||
struct bfu_color_entry *entry = node_entries[node_number];
|
||||
|
||||
if (!entry->was_color88) {
|
||||
set_term_color(&entry->c88, &entry->colors, 0, COLOR_MODE_88);
|
||||
entry->was_color88 = 1;
|
||||
}
|
||||
|
||||
return TERM_COLOR_FOREGROUND_256(entry->c88.c.color);
|
||||
}
|
||||
|
||||
unsigned char
|
||||
get_bfu_background_color256_node(unsigned int node_number)
|
||||
struct screen_char *
|
||||
get_bfu_color256_node(unsigned int node_number)
|
||||
{
|
||||
struct bfu_color_entry *entry = node_entries[node_number];
|
||||
|
||||
@ -106,20 +93,7 @@ get_bfu_background_color256_node(unsigned int node_number)
|
||||
entry->was_color256 = 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_term_color(&entry->c256, &entry->colors, 0, COLOR_MODE_256);
|
||||
entry->was_color256 = 1;
|
||||
}
|
||||
|
||||
return TERM_COLOR_FOREGROUND_256(entry->c256.c.color);
|
||||
return &entry->c256;
|
||||
}
|
||||
|
||||
unsigned char *
|
||||
|
@ -30,10 +30,8 @@ unsigned int get_bfu_color_node(struct terminal *term, const char *stylename);
|
||||
|
||||
struct screen_char *get_bfu_mono_node(unsigned int node_number);
|
||||
struct screen_char *get_bfu_color16_node(unsigned int node_number);
|
||||
unsigned char get_bfu_background_color88_node(unsigned int node_number);
|
||||
unsigned char get_bfu_foreground_color88_node(unsigned int node_number);
|
||||
unsigned char get_bfu_background_color256_node(unsigned int node_number);
|
||||
unsigned char get_bfu_foreground_color256_node(unsigned int node_number);
|
||||
struct screen_char *get_bfu_color88_node(unsigned int node_number);
|
||||
struct screen_char *get_bfu_color256_node(unsigned int node_number);
|
||||
unsigned char *get_bfu_background_color_true_node(unsigned int node_number);
|
||||
unsigned char *get_bfu_foreground_color_true_node(unsigned int node_number);
|
||||
|
||||
|
@ -1084,52 +1084,28 @@ add_char_color(struct string *screen, const struct string *seq, unsigned char co
|
||||
add_bytes_to_string(screen, &seq->source[seq_pos], seq->length - seq_pos);
|
||||
}
|
||||
|
||||
static unsigned char
|
||||
get_background_color_from_node(struct screen_char *ch)
|
||||
static struct screen_char *
|
||||
get_color256_from_node(struct screen_char *ch)
|
||||
{
|
||||
unsigned int node_number = ch->c.node_number;
|
||||
|
||||
if (node_number < 1024) {
|
||||
return get_bfu_background_color256_node(node_number);
|
||||
return get_bfu_color256_node(node_number);
|
||||
}
|
||||
|
||||
return ch->c.color[1];
|
||||
return ch;
|
||||
}
|
||||
|
||||
static unsigned char
|
||||
get_foreground_color_from_node(struct screen_char *ch)
|
||||
static struct screen_char *
|
||||
get_color88_from_node(struct screen_char *ch)
|
||||
{
|
||||
unsigned int node_number = ch->c.node_number;
|
||||
|
||||
if (node_number < 1024) {
|
||||
return get_bfu_foreground_color256_node(node_number);
|
||||
return get_bfu_color88_node(node_number);
|
||||
}
|
||||
|
||||
return ch->c.color[0];
|
||||
}
|
||||
|
||||
static unsigned char
|
||||
get_background_color88_from_node(struct screen_char *ch)
|
||||
{
|
||||
unsigned int node_number = ch->c.node_number;
|
||||
|
||||
if (node_number < 1024) {
|
||||
return get_bfu_background_color88_node(node_number);
|
||||
}
|
||||
|
||||
return ch->c.color[1];
|
||||
}
|
||||
|
||||
static unsigned char
|
||||
get_foreground_color88_from_node(struct screen_char *ch)
|
||||
{
|
||||
unsigned int node_number = ch->c.node_number;
|
||||
|
||||
if (node_number < 1024) {
|
||||
return get_bfu_foreground_color88_node(node_number);
|
||||
}
|
||||
|
||||
return ch->c.color[0];
|
||||
return ch;
|
||||
}
|
||||
|
||||
|
||||
@ -1161,57 +1137,31 @@ get_color16_from_node(struct screen_char *ch)
|
||||
return ch;
|
||||
}
|
||||
|
||||
static inline void
|
||||
add_background_color(struct string *str, const struct string *seq, struct screen_char *ch)
|
||||
{
|
||||
if (ch->is_node) {
|
||||
add_char_color(str, &(seq)[1], get_background_color_from_node(ch));
|
||||
} else {
|
||||
add_char_color(str, &(seq)[1], ch->c.color[1]);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
add_foreground_color(struct string *str, const struct string *seq, struct screen_char *ch)
|
||||
{
|
||||
if (ch->is_node) {
|
||||
add_char_color(str, (&seq)[0], get_foreground_color_from_node(ch));
|
||||
} else {
|
||||
add_char_color(str, &(seq)[0], ch->c.color[0]);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
add_background_color88(struct string *str, const struct string *seq, struct screen_char *ch)
|
||||
{
|
||||
if (ch->is_node) {
|
||||
add_char_color(str, &(seq)[1], get_background_color88_from_node(ch));
|
||||
} else {
|
||||
add_char_color(str, &(seq)[1], ch->c.color[1]);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
add_foreground_color88(struct string *str, const struct string *seq, struct screen_char *ch)
|
||||
{
|
||||
if (ch->is_node) {
|
||||
add_char_color(str, (&seq)[0], get_foreground_color88_from_node(ch));
|
||||
} else {
|
||||
add_char_color(str, &(seq)[0], ch->c.color[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
#define add_background_color(str, seq, chr) add_char_color(str, &(seq)[1], (chr)->c.color[1])
|
||||
#define add_foreground_color(str, seq, chr) add_char_color(str, &(seq)[0], (chr)->c.color[0])
|
||||
#endif
|
||||
|
||||
/** Time critical section. */
|
||||
static inline void
|
||||
add_char256(struct string *screen, struct screen_driver *driver,
|
||||
struct screen_char *ch, struct screen_state *state)
|
||||
{
|
||||
struct screen_char copy;
|
||||
|
||||
if (ch->is_node) {
|
||||
struct screen_char *ch2;
|
||||
copy = *ch;
|
||||
copy.is_node = 0;
|
||||
|
||||
if (driver->opt.color_mode == COLOR_MODE_88) {
|
||||
ch2 = get_color88_from_node(ch);
|
||||
} else {
|
||||
ch2 = get_color256_from_node(ch);
|
||||
}
|
||||
copy.c.color[0] = ch2->c.color[0];
|
||||
copy.c.color[1] = ch2->c.color[1];
|
||||
ch = ©
|
||||
}
|
||||
|
||||
unsigned char attr_delta = (ch->attr ^ state->attr);
|
||||
|
||||
if (
|
||||
@ -1293,17 +1243,9 @@ add_char256(struct string *screen, struct screen_driver *driver,
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (driver->opt.color_mode == COLOR_MODE_88) {
|
||||
add_foreground_color88(screen, driver->opt.color256_seqs, ch);
|
||||
} else {
|
||||
add_foreground_color(screen, driver->opt.color256_seqs, ch);
|
||||
}
|
||||
add_foreground_color(screen, driver->opt.color256_seqs, ch);
|
||||
if (!driver->opt.transparent || ch->c.color[1] != 0) {
|
||||
if (driver->opt.color_mode == COLOR_MODE_88) {
|
||||
add_background_color88(screen, driver->opt.color256_seqs, ch);
|
||||
} else {
|
||||
add_background_color(screen, driver->opt.color256_seqs, ch);
|
||||
}
|
||||
add_background_color(screen, driver->opt.color256_seqs, ch);
|
||||
}
|
||||
|
||||
if (ch->attr & SCREEN_ATTR_BOLD)
|
||||
|
Loading…
x
Reference in New Issue
Block a user