mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Fixed issue with CONFIG_TRUE_COLOR and 16 colors mode. inline functions used
instead of macros. Still problems with transparency in true color mode.
This commit is contained in:
parent
00a5b88371
commit
60544f748e
@ -269,7 +269,7 @@ set_term_color16(struct screen_char *schar, enum color_flags flags,
|
|||||||
if (use_inverse(bg, fg)) {
|
if (use_inverse(bg, fg)) {
|
||||||
schar->attr |= SCREEN_ATTR_STANDOUT;
|
schar->attr |= SCREEN_ATTR_STANDOUT;
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
|
#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
|
||||||
/* With 256 color support we use memcmp() when comparing color in
|
/* With 256 color support we use memcmp() when comparing color in
|
||||||
* terminal/screen.c:add_char*() so we need to clear this byte. */
|
* terminal/screen.c:add_char*() so we need to clear this byte. */
|
||||||
@ -278,6 +278,8 @@ set_term_color16(struct screen_char *schar, enum color_flags flags,
|
|||||||
#else
|
#else
|
||||||
schar->color[0] = (bg << 4 | fg);
|
schar->color[0] = (bg << 4 | fg);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
schar->color[0] = (bg << 4 | fg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -17,10 +17,9 @@ struct screen_char;
|
|||||||
#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
|
#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
|
||||||
#define TERM_COLOR_FOREGROUND(color) ((color)[0])
|
#define TERM_COLOR_FOREGROUND(color) ((color)[0])
|
||||||
#define TERM_COLOR_BACKGROUND(color) ((color)[1])
|
#define TERM_COLOR_BACKGROUND(color) ((color)[1])
|
||||||
#else
|
|
||||||
#define TERM_COLOR_FOREGROUND(color) ((color)[0] & TERM_COLOR_MASK)
|
|
||||||
#define TERM_COLOR_BACKGROUND(color) (((color)[0] >> 4) & TERM_COLOR_MASK)
|
|
||||||
#endif
|
#endif
|
||||||
|
#define TERM_COLOR_FOREGROUND_16(color) ((color)[0] & TERM_COLOR_MASK)
|
||||||
|
#define TERM_COLOR_BACKGROUND_16(color) (((color)[0] >> 4) & TERM_COLOR_MASK)
|
||||||
|
|
||||||
/* Bit flags to control how the colors are handled. */
|
/* Bit flags to control how the colors are handled. */
|
||||||
enum color_flags {
|
enum color_flags {
|
||||||
|
@ -431,34 +431,91 @@ struct screen_state {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/* FIXME: This is inefficient. When CONFIG_TRUE_COLOR is defined even in 16 color mode
|
|
||||||
* all 6 bytes are copied or compared. */
|
|
||||||
|
|
||||||
#if defined(CONFIG_TRUE_COLOR)
|
#if defined(CONFIG_TRUE_COLOR)
|
||||||
#define compare_color(a, b) ((a)[0] == (b)[0] && (a)[1] == (b)[1] && (a)[2] == (b)[2] \
|
|
||||||
&& (a)[3] == (b)[3] && (a)[4] == (b)[4] && (a)[5] == (b)[5])
|
|
||||||
#define copy_color(a, b) do { (a)[0] = (b)[0]; (a)[1] = (b)[1]; (a)[2] = (b)[2]; \
|
|
||||||
(a)[3] = (b)[3]; (a)[4] = (b)[4]; (a)[5] = (b)[5];} while (0)
|
|
||||||
#define INIT_SCREEN_STATE { 0xFF, 0xFF, 0xFF, 0, { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} }
|
#define INIT_SCREEN_STATE { 0xFF, 0xFF, 0xFF, 0, { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} }
|
||||||
|
|
||||||
#elif defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
|
#elif defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
|
||||||
#define compare_color(a, b) ((a)[0] == (b)[0] && (a)[1] == (b)[1])
|
|
||||||
#define copy_color(a, b) do { (a)[0] = (b)[0]; (a)[1] = (b)[1]; } while (0)
|
|
||||||
#define INIT_SCREEN_STATE { 0xFF, 0xFF, 0xFF, 0, { 0xFF, 0xFF } }
|
#define INIT_SCREEN_STATE { 0xFF, 0xFF, 0xFF, 0, { 0xFF, 0xFF } }
|
||||||
#else
|
#else
|
||||||
#define compare_color(a, b) ((a)[0] == (b)[0])
|
|
||||||
#define copy_color(a, b) do { (a)[0] = (b)[0]; } while (0)
|
|
||||||
#define INIT_SCREEN_STATE { 0xFF, 0xFF, 0xFF, 0, { 0xFF } }
|
#define INIT_SCREEN_STATE { 0xFF, 0xFF, 0xFF, 0, { 0xFF } }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_TRUE_COLOR)
|
#ifdef CONFIG_TRUE_COLOR
|
||||||
#define compare_bg_color(a, b) ((a)[3] == (b[3]) && (a)[4] == (b)[4] && (a)[5] == (b)[5])
|
static inline int
|
||||||
#define compare_fg_color(a, b) ((a)[0] == (b[0]) && (a)[1] == (b)[1] && (a)[2] == (b)[2])
|
compare_color_true(unsigned char *a, unsigned char *b)
|
||||||
#else
|
{
|
||||||
#define compare_bg_color(a, b) (TERM_COLOR_BACKGROUND(a) == TERM_COLOR_BACKGROUND(b))
|
return !memcmp(a, b, 6);
|
||||||
#define compare_fg_color(a, b) (TERM_COLOR_FOREGROUND(a) == TERM_COLOR_FOREGROUND(b))
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
compare_bg_color_true(unsigned char *a, unsigned char *b)
|
||||||
|
{
|
||||||
|
return (a[3] == b[3] && a[4] == b[4] && a[5] == b[5]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
compare_fg_color_true(unsigned char *a, unsigned char *b)
|
||||||
|
{
|
||||||
|
return (a[0] == b[0] && a[1] == b[1] && a[2] == b[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
copy_color_true(unsigned char *a, unsigned char *b)
|
||||||
|
{
|
||||||
|
memcpy(a, b, 6);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
|
||||||
|
static inline int
|
||||||
|
compare_color_256(unsigned char *a, unsigned char *b)
|
||||||
|
{
|
||||||
|
return (a[0] == b[0] && a[1] == b[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
compare_bg_color_256(unsigned char *a, unsigned char *b)
|
||||||
|
{
|
||||||
|
return (a[1] == b[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
compare_fg_color_256(unsigned char *a, unsigned char *b)
|
||||||
|
{
|
||||||
|
return (a[0] == b[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
copy_color_256(unsigned char *a, unsigned char *b)
|
||||||
|
{
|
||||||
|
a[0] = b[0];
|
||||||
|
a[1] = b[1];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
compare_color_16(unsigned char *a, unsigned char *b)
|
||||||
|
{
|
||||||
|
return (a[0] == b[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
compare_bg_color_16(unsigned char *a, unsigned char *b)
|
||||||
|
{
|
||||||
|
return (TERM_COLOR_BACKGROUND_16(a) == TERM_COLOR_BACKGROUND_16(b));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
compare_fg_color_16(unsigned char *a, unsigned char *b)
|
||||||
|
{
|
||||||
|
return (TERM_COLOR_FOREGROUND_16(a) == TERM_COLOR_FOREGROUND_16(b));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
copy_color_16(unsigned char *a, unsigned char *b)
|
||||||
|
{
|
||||||
|
a[0] = b[0];
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_UTF_8
|
#ifdef CONFIG_UTF_8
|
||||||
static inline void
|
static inline void
|
||||||
add_char_data(struct string *screen, struct screen_driver *driver,
|
add_char_data(struct string *screen, struct screen_driver *driver,
|
||||||
@ -543,17 +600,17 @@ add_char16(struct string *screen, struct screen_driver *driver,
|
|||||||
#ifdef CONFIG_UTF_8
|
#ifdef CONFIG_UTF_8
|
||||||
(!use_utf8_io(driver) || ch->data != UCS_NO_CHAR) &&
|
(!use_utf8_io(driver) || ch->data != UCS_NO_CHAR) &&
|
||||||
#endif /* CONFIG_UTF_8 */
|
#endif /* CONFIG_UTF_8 */
|
||||||
!compare_color(ch->color, state->color)
|
!compare_color_16(ch->color, state->color)
|
||||||
) {
|
) {
|
||||||
copy_color(state->color, ch->color);
|
copy_color_16(state->color, ch->color);
|
||||||
|
|
||||||
add_bytes_to_string(screen, "\033[0", 3);
|
add_bytes_to_string(screen, "\033[0", 3);
|
||||||
|
|
||||||
if (driver->color_mode == COLOR_MODE_16) {
|
if (driver->color_mode == COLOR_MODE_16) {
|
||||||
unsigned char code[6] = ";30;40";
|
unsigned char code[6] = ";30;40";
|
||||||
unsigned char bgcolor = TERM_COLOR_BACKGROUND(ch->color);
|
unsigned char bgcolor = TERM_COLOR_BACKGROUND_16(ch->color);
|
||||||
|
|
||||||
code[2] += TERM_COLOR_FOREGROUND(ch->color);
|
code[2] += TERM_COLOR_FOREGROUND_16(ch->color);
|
||||||
|
|
||||||
if (!driver->transparent || bgcolor != 0) {
|
if (!driver->transparent || bgcolor != 0) {
|
||||||
code[5] += bgcolor;
|
code[5] += bgcolor;
|
||||||
@ -678,9 +735,9 @@ add_char256(struct string *screen, struct screen_driver *driver,
|
|||||||
#ifdef CONFIG_UTF_8
|
#ifdef CONFIG_UTF_8
|
||||||
(!use_utf8_io(driver) || ch->data != UCS_NO_CHAR) &&
|
(!use_utf8_io(driver) || ch->data != UCS_NO_CHAR) &&
|
||||||
#endif /* CONFIG_UTF_8 */
|
#endif /* CONFIG_UTF_8 */
|
||||||
!compare_color(ch->color, state->color)
|
!compare_color_256(ch->color, state->color)
|
||||||
) {
|
) {
|
||||||
copy_color(state->color, ch->color);
|
copy_color_256(state->color, ch->color);
|
||||||
|
|
||||||
add_foreground_color(screen, color256_seqs, ch);
|
add_foreground_color(screen, color256_seqs, ch);
|
||||||
if (!driver->transparent || ch->color[1] != 0) {
|
if (!driver->transparent || ch->color[1] != 0) {
|
||||||
@ -793,9 +850,9 @@ add_char_true(struct string *screen, struct screen_driver *driver,
|
|||||||
#ifdef CONFIG_UTF_8
|
#ifdef CONFIG_UTF_8
|
||||||
(!use_utf8_io(driver) || ch->data != UCS_NO_CHAR) &&
|
(!use_utf8_io(driver) || ch->data != UCS_NO_CHAR) &&
|
||||||
#endif /* CONFIG_UTF_8 */
|
#endif /* CONFIG_UTF_8 */
|
||||||
!compare_color(ch->color, state->color)
|
!compare_color_true(ch->color, state->color)
|
||||||
) {
|
) {
|
||||||
copy_color(state->color, ch->color);
|
copy_color_true(state->color, ch->color);
|
||||||
|
|
||||||
add_true_foreground_color(screen, color_true_seqs, ch);
|
add_true_foreground_color(screen, color_true_seqs, ch);
|
||||||
if (!driver->transparent || ch->color[1] != 0) {
|
if (!driver->transparent || ch->color[1] != 0) {
|
||||||
@ -815,7 +872,7 @@ add_char_true(struct string *screen, struct screen_driver *driver,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define add_chars(image_, term_, driver_, state_, ADD_CHAR) \
|
#define add_chars(image_, term_, driver_, state_, ADD_CHAR, compare_bg_color, compare_fg_color) \
|
||||||
{ \
|
{ \
|
||||||
struct terminal_screen *screen = (term_)->screen; \
|
struct terminal_screen *screen = (term_)->screen; \
|
||||||
int y = screen->dirty_from; \
|
int y = screen->dirty_from; \
|
||||||
@ -895,21 +952,21 @@ redraw_screen(struct terminal *term)
|
|||||||
switch (driver->color_mode) {
|
switch (driver->color_mode) {
|
||||||
case COLOR_MODE_MONO:
|
case COLOR_MODE_MONO:
|
||||||
case COLOR_MODE_16:
|
case COLOR_MODE_16:
|
||||||
add_chars(&image, term, driver, &state, add_char16);
|
add_chars(&image, term, driver, &state, add_char16, compare_bg_color_16, compare_fg_color_16);
|
||||||
break;
|
break;
|
||||||
#ifdef CONFIG_88_COLORS
|
#ifdef CONFIG_88_COLORS
|
||||||
case COLOR_MODE_88:
|
case COLOR_MODE_88:
|
||||||
add_chars(&image, term, driver, &state, add_char256);
|
add_chars(&image, term, driver, &state, add_char256, compare_bg_color_256, compare_fg_color_256);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_256_COLORS
|
#ifdef CONFIG_256_COLORS
|
||||||
case COLOR_MODE_256:
|
case COLOR_MODE_256:
|
||||||
add_chars(&image, term, driver, &state, add_char256);
|
add_chars(&image, term, driver, &state, add_char256, compare_bg_color_256, compare_fg_color_256);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_TRUE_COLOR
|
#ifdef CONFIG_TRUE_COLOR
|
||||||
case COLOR_MODE_TRUE_COLOR:
|
case COLOR_MODE_TRUE_COLOR:
|
||||||
add_chars(&image, term, driver, &state, add_char_true);
|
add_chars(&image, term, driver, &state, add_char_true, compare_bg_color_true, compare_fg_color_true);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case COLOR_MODES:
|
case COLOR_MODES:
|
||||||
|
Loading…
Reference in New Issue
Block a user