termptyesc: _handle_xterm_set_color_class() gets obj==NULL in tests

+ simplify _handle_xterm_10_command()
This commit is contained in:
Boris Faure 2020-11-15 20:10:43 +01:00
parent 05b95705ae
commit a29e7a718a
Signed by: borisfaure
GPG Key ID: 35C0410516166BE8
1 changed files with 15 additions and 12 deletions

View File

@ -4124,7 +4124,8 @@ _handle_xterm_10_command(Termpty *ty, Eina_Unicode *p, int len)
if (*p == '?') if (*p == '?')
{ {
int r, g, b; int r, g, b;
char bf[7]; char bf[32];
int l;
#if !defined(BINARY_TYFUZZ) && !defined(BINARY_TYTEST) #if !defined(BINARY_TYFUZZ) && !defined(BINARY_TYTEST)
evas_object_textgrid_palette_get( evas_object_textgrid_palette_get(
termio_textgrid_get(ty->obj), termio_textgrid_get(ty->obj),
@ -4136,10 +4137,8 @@ _handle_xterm_10_command(Termpty *ty, Eina_Unicode *p, int len)
g = config->colors[0].g; g = config->colors[0].g;
b = config->colors[0].b; b = config->colors[0].b;
#endif #endif
TERMPTY_WRITE_STR("\033]10;#"); l = snprintf(bf, sizeof(bf), "\033]10;#%.2X%.2X%.2X\007", r, g, b);
snprintf(bf, sizeof(bf), "%.2X%.2X%.2X", r, g, b); termpty_write(ty, bf, l);
termpty_write(ty, bf, 6);
TERMPTY_WRITE_STR("\007");
} }
else else
{ {
@ -4164,14 +4163,18 @@ _handle_xterm_set_color_class(Termpty *ty, Eina_Unicode *p, int len,
const char *color_class, const char *color_class,
uint8_t number) uint8_t number)
{ {
if (!p || !*p || !obj) if (!p || !*p)
goto err; goto err;
#if !defined(BINARY_TYFUZZ) && !defined(BINARY_TYTEST)
if (!obj)
goto err;
#endif
if (*p == '?') if (*p == '?')
{ {
int r = 0, g = 0, b = 0; int r = 0, g = 0, b = 0;
char buf[64]; char buf[64];
size_t l; int l;
if (edje_object_color_class_get(obj, color_class, &r, &g, &b, NULL, if (edje_object_color_class_get(obj, color_class, &r, &g, &b, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,