diff --git a/src/bin/col.c b/src/bin/col.c index 57b2a564..8b1da89a 100644 --- a/src/bin/col.c +++ b/src/bin/col.c @@ -515,3 +515,16 @@ colors_standard_get(int set, int col, *b = 0; *a = 0; } + +void +colors_256_get(int col, + unsigned char *r, + unsigned char *g, + unsigned char *b, + unsigned char *a) +{ + *r = default_colors256[col].r; + *g = default_colors256[col].g; + *b = default_colors256[col].b; + *a = default_colors256[col].a; +} diff --git a/src/bin/col.h b/src/bin/col.h index 2fe8dfe5..d2cf605c 100644 --- a/src/bin/col.h +++ b/src/bin/col.h @@ -6,5 +6,6 @@ void colors_term_init(Evas_Object *textgrid, const Evas_Object *bg, const Config *config); void colors_standard_get(int set, int col, unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a); +void colors_256_get(int col, unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a); #endif diff --git a/src/bin/meson.build b/src/bin/meson.build index eb75b69d..44ea008e 100644 --- a/src/bin/meson.build +++ b/src/bin/meson.build @@ -69,7 +69,7 @@ tytest_sources = ['termptyesc.c', 'termptyesc.h', 'col.c', 'col.h', 'sb.c', 'sb.h', 'md5/md5.c', 'md5/md5.h', - 'tytest.c'] + 'tytest.c', 'tytest.h'] executable('terminology', terminology_sources, diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c index 857b654c..d1a0d9ae 100644 --- a/src/bin/termptyesc.c +++ b/src/bin/termptyesc.c @@ -1,12 +1,16 @@ #include "private.h" #include #include +#include "col.h" #include "termio.h" #include "termpty.h" #include "termptydbl.h" #include "termptyesc.h" #include "termptyops.h" #include "termptyext.h" +#if defined(ENABLE_TESTS) +#include "tytest.h" +#endif #undef CRITICAL #undef ERR @@ -579,7 +583,7 @@ _approximate_truecolor_rgb(Termpty *ty, int r0, int g0, int b0) { int chosen_color = COL_DEF; /* TODO: use the function in tests */ -#if defined(ENABLE_FUZZING) || defined(ENABLE_TESTS) +#if defined(ENABLE_FUZZING) (void) ty; (void) r0; (void) g0; diff --git a/src/bin/tyfuzz.c b/src/bin/tyfuzz.c index 70da12cf..175173b7 100644 --- a/src/bin/tyfuzz.c +++ b/src/bin/tyfuzz.c @@ -14,6 +14,8 @@ #include #ifdef TYTEST +#include "col.h" +#include "tytest.h" #include "md5/md5.h" #endif @@ -90,6 +92,41 @@ typedef struct _Termpty_Tests unsigned int bracketed_paste : 1; } Termpty_Tests; +Evas_Object * +termio_textgrid_get(const Evas_Object *obj EINA_UNUSED) +{ + return NULL; +} + +void +test_textgrid_palette_get(const Evas_Object *obj EINA_UNUSED, + Evas_Textgrid_Palette pal, + int idx, + int *r, + int *g, + int *b, + int *a) +{ + if (pal == EVAS_TEXTGRID_PALETTE_EXTENDED) + { + colors_256_get(idx, + (unsigned char *)r, + (unsigned char *)g, + (unsigned char *)b, + (unsigned char *)a); + } + else + { + int set = idx / 12; + int col = idx % 12; + colors_standard_get(set, col, + (unsigned char*)r, + (unsigned char*)g, + (unsigned char*)b, + (unsigned char*)a); + } +} + void termio_set_cursor_shape(Evas_Object *obj EINA_UNUSED, Cursor_Shape shape EINA_UNUSED) diff --git a/src/bin/tytest.h b/src/bin/tytest.h new file mode 100644 index 00000000..e702cec5 --- /dev/null +++ b/src/bin/tytest.h @@ -0,0 +1,15 @@ +#ifndef _TYTEST_H__ +#define _TYTEST_H__ 1 + +#if defined(ENABLE_TESTS) +#define evas_object_textgrid_palette_get test_textgrid_palette_get +void +test_textgrid_palette_get(const Evas_Object *obj, + Evas_Textgrid_Palette pal, + int idx, + int *r, + int *g, + int *b, + int *a); +#endif +#endif