termio/termptyesc: clean up mess with color classes

terminology-1.9
Boris Faure 2 years ago
parent 5b186b69a3
commit 11abaaa0b4
Signed by: borisfaure
GPG Key ID: 35C0410516166BE8
  1. 104
      src/bin/termio.c
  2. 7
      src/bin/termio.h
  3. 20
      src/bin/termptyesc.c
  4. 13
      src/bin/tytest.h
  5. 19
      src/bin/tytest_common.c

@ -76,22 +76,30 @@ void
termio_theme_set(Evas_Object *obj, Evas_Object *theme)
{
Termio *sd = evas_object_smart_data_get(obj);
Evas_Object *bg;
EINA_SAFETY_ON_NULL_RETURN(sd);
EINA_SAFETY_ON_NULL_RETURN(sd->grid.obj);
EINA_SAFETY_ON_NULL_RETURN(theme);
sd->theme = theme;
bg = term_bg_get(sd->term);
EINA_SAFETY_ON_NULL_RETURN(bg);
termio_color_class_get(obj, "BG",
edje_object_color_class_get(bg, "BG",
&sd->saved_bg.r,
&sd->saved_bg.g,
&sd->saved_bg.b,
&sd->saved_bg.a);
termio_color_class_get(sd->cursor.obj, "CURSOR",
&sd->saved_cursor.r,
&sd->saved_cursor.g,
&sd->saved_cursor.b,
&sd->saved_cursor.a);
&sd->saved_bg.a,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL);
edje_object_color_class_get(sd->cursor.obj, "CURSOR",
&sd->saved_cursor.r,
&sd->saved_cursor.g,
&sd->saved_cursor.b,
&sd->saved_cursor.a,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL);
evas_object_textgrid_palette_get(
sd->grid.obj,
EVAS_TEXTGRID_PALETTE_STANDARD, 0,
@ -107,10 +115,22 @@ termio_reset_main_colors(Evas_Object *termio)
if (termio)
{
Termio *sd = evas_object_smart_data_get(termio);
Evas_Object *bg;
EINA_SAFETY_ON_NULL_RETURN(sd);
EINA_SAFETY_ON_NULL_RETURN(sd->grid.obj);
termio_color_class_set(termio, "BG",
bg = term_bg_get(sd->term);
EINA_SAFETY_ON_NULL_RETURN(bg);
edje_object_color_class_set(bg, "BG",
sd->saved_bg.r,
sd->saved_bg.g,
sd->saved_bg.b,
sd->saved_bg.a,
sd->saved_bg.r,
sd->saved_bg.g,
sd->saved_bg.b,
sd->saved_bg.a,
sd->saved_bg.r,
sd->saved_bg.g,
sd->saved_bg.b,
@ -329,6 +349,15 @@ termio_term_get(const Evas_Object *obj)
return sd->term;
}
Evas_Object *
termio_bg_get(const Evas_Object *obj)
{
Termio *sd = evas_object_smart_data_get(obj);
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL);
return term_bg_get(sd->term);
}
static void
_font_size_set(Evas_Object *obj, int size)
{
@ -4187,62 +4216,3 @@ termio_key_down(Evas_Object *termio,
edje_object_signal_emit(sd->cursor.obj, "key,down", "terminology");
ev->event_flags = EVAS_EVENT_FLAG_ON_HOLD;
}
int
termio_color_class_get(Evas_Object *termio, const char *key,
int *r, int *g, int *b, int *a)
{
Termio *sd = evas_object_smart_data_get(termio);
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, -1);
if (sd->term)
{
Evas_Object *bg = term_bg_get(sd->term);
if (!edje_object_color_class_get(bg, key,
r,
g,
b,
a,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL))
{
ERR("color class '%s' not found in theme", key);
return -1;
}
}
else
{
ERR("term not found");
return -1;
}
return 0;
}
int
termio_color_class_set(Evas_Object *termio, const char *key,
int r, int g, int b, int a)
{
Termio *sd = evas_object_smart_data_get(termio);
EINA_SAFETY_ON_NULL_RETURN_VAL(sd, -1);
if (sd->term)
{
Evas_Object *bg = term_bg_get(sd->term);
if (!edje_object_color_class_set(bg, key,
r, g, b, a,
r, g, b, a,
r, g, b, a))
{
ERR("can not set color class '%s'", key);
return -1;
}
}
else
{
ERR("term not found");
return -1;
}
return 0;
}

@ -65,6 +65,7 @@ termio_imf_cursor_set(Evas_Object *obj, Ecore_IMF_Context *imf);
Termpty *termio_pty_get(const Evas_Object *obj);
Evas_Object * termio_miniview_get(const Evas_Object *obj);
Term* termio_term_get(const Evas_Object *obj);
Evas_Object *termio_bg_get(const Evas_Object *obj);
void termio_key_down(Evas_Object *termio,
Evas_Event_Key_Down *ev,
@ -84,12 +85,6 @@ void
termio_block_activate(Evas_Object *obj, Termblock *blk);
const char *
term_preedit_str_get(Term *term);
int
termio_color_class_get(Evas_Object *termio, const char *key,
int *r, int *g, int *b, int *a);
int
termio_color_class_set(Evas_Object *termio, const char *key,
int r, int g, int b, int a);
void
termio_reset_main_colors(Evas_Object *termio);
#endif

@ -4173,12 +4173,14 @@ _handle_xterm_set_color_class(Termpty *ty, Eina_Unicode *p, int len,
char buf[64];
size_t l;
if (termio_color_class_get(obj, color_class, &r, &g, &b, NULL) != 0)
if (edje_object_color_class_get(obj, color_class, &r, &g, &b, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL) != 0)
{
ERR("error getting color class '%s'", color_class);
}
l = snprintf(buf, sizeof(buf),
"\033]%d;rgb:%.2x%.2x/%.2x%.2x/%.2x%.2x\033\\",
"\033]%d;rgb:%.2x%.2x/%.2x%.2x/%.2x%.2x\007",
number, r, r, g, g, b, b);
termpty_write(ty, buf, l);
}
@ -4187,13 +4189,10 @@ _handle_xterm_set_color_class(Termpty *ty, Eina_Unicode *p, int len,
unsigned char r, g, b;
if (_xterm_parse_color(ty, &p, &r, &g, &b, len) < 0)
goto err;
if (obj == ty->obj)
termio_color_class_set(obj, color_class, r, g, b, 0xff);
else
edje_object_color_class_set(obj, "CURSOR",
r, g, b, 0xff,
r, g, b, 0xff,
r, g, b, 0xff);
edje_object_color_class_set(obj, color_class,
r, g, b, 0xff,
r, g, b, 0xff,
r, g, b, 0xff);
}
return;
@ -4325,7 +4324,8 @@ _handle_esc_osc(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
case 11:
DBG("Set background color");
_handle_xterm_set_color_class(ty, p, cc - c - (p - buf),
ty->obj, "BG", 11);
termio_bg_get(ty->obj),
"BG", 11);
break;
case 12:
DBG("Set cursor color");

@ -16,6 +16,19 @@ test_textgrid_palette_get(const Evas_Object *obj,
Evas_Textgrid_Cell *
tytest_textgrid_cellrow_get(Evas_Object *obj, int y);
#define edje_object_color_class_get tytest_edje_object_color_class_get
int
tytest_edje_object_color_class_get(Evas_Object *termio EINA_UNUSED, const char *key,
int *r, int *g, int *b, int *a,
int *r1 EINA_UNUSED, int *g1 EINA_UNUSED, int *b1 EINA_UNUSED, int *a1 EINA_UNUSED,
int *r2 EINA_UNUSED, int *g2 EINA_UNUSED, int *b2 EINA_UNUSED, int *a2 EINA_UNUSED);
#define edje_object_color_class_set tytest_edje_object_color_class_set
int
tytest_edje_object_color_class_set(Evas_Object *termio EINA_UNUSED, const char *key,
int r, int g, int b, int a,
int r1 EINA_UNUSED, int g1 EINA_UNUSED, int b1 EINA_UNUSED, int a1 EINA_UNUSED,
int r2 EINA_UNUSED, int g2 EINA_UNUSED, int b2 EINA_UNUSED, int a2 EINA_UNUSED);
void
tytest_termio_resize(int w, int h);
#endif

@ -277,8 +277,10 @@ termio_set_cursor_shape(Evas_Object *obj EINA_UNUSED,
int
termio_color_class_get(Evas_Object *termio EINA_UNUSED, const char *key,
int *r, int *g, int *b, int *a)
tytest_edje_object_color_class_get(Evas_Object *termio EINA_UNUSED, const char *key,
int *r, int *g, int *b, int *a,
int *r1 EINA_UNUSED, int *g1 EINA_UNUSED, int *b1 EINA_UNUSED, int *a1 EINA_UNUSED,
int *r2 EINA_UNUSED, int *g2 EINA_UNUSED, int *b2 EINA_UNUSED, int *a2 EINA_UNUSED)
{
if (strncmp(key, "BG", strlen("BG")) == 0)
{
@ -306,9 +308,12 @@ termio_color_class_get(Evas_Object *termio EINA_UNUSED, const char *key,
}
return -1;
}
int
termio_color_class_set(Evas_Object *termio EINA_UNUSED, const char *key,
int r, int g, int b, int a)
tytest_edje_object_color_class_set(Evas_Object *termio EINA_UNUSED, const char *key,
int r, int g, int b, int a,
int r1 EINA_UNUSED, int g1 EINA_UNUSED, int b1 EINA_UNUSED, int a1 EINA_UNUSED,
int r2 EINA_UNUSED, int g2 EINA_UNUSED, int b2 EINA_UNUSED, int a2 EINA_UNUSED)
{
if (strncmp(key, "BG", strlen("BG")) == 0)
{
@ -348,6 +353,12 @@ termio_textgrid_get(const Evas_Object *obj EINA_UNUSED)
return NULL;
}
Evas_Object *
termio_bg_get(const Evas_Object *obj EINA_UNUSED)
{
return NULL;
}
#if defined(BINARY_TYTEST)
void
test_textgrid_palette_get(const Evas_Object *obj EINA_UNUSED,

Loading…
Cancel
Save