diff --git a/src/bin/termio.c b/src/bin/termio.c index 3bf57d9e..3896833a 100644 --- a/src/bin/termio.c +++ b/src/bin/termio.c @@ -87,6 +87,11 @@ termio_theme_set(Evas_Object *obj, Evas_Object *theme) &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); evas_object_textgrid_palette_get( sd->grid.obj, EVAS_TEXTGRID_PALETTE_STANDARD, 0, @@ -110,6 +115,19 @@ termio_reset_main_colors(Evas_Object *termio) sd->saved_bg.g, sd->saved_bg.b, sd->saved_bg.a); + edje_object_color_class_set(sd->cursor.obj, "CURSOR", + sd->saved_cursor.r, + sd->saved_cursor.g, + sd->saved_cursor.b, + sd->saved_cursor.a, + sd->saved_cursor.r, + sd->saved_cursor.g, + sd->saved_cursor.b, + sd->saved_cursor.a, + sd->saved_cursor.r, + sd->saved_cursor.g, + sd->saved_cursor.b, + sd->saved_cursor.a); evas_object_textgrid_palette_set( sd->grid.obj, EVAS_TEXTGRID_PALETTE_STANDARD, 0, @@ -555,6 +573,14 @@ _cursor_shape_to_group_name(Cursor_Shape shape) return NULL; } +Evas_Object * +termio_get_cursor(const Evas_Object *obj) +{ + Termio *sd = evas_object_smart_data_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(sd, NULL); + return sd->cursor.obj; +} + void termio_set_cursor_shape(Evas_Object *obj, Cursor_Shape shape) { diff --git a/src/bin/termio.h b/src/bin/termio.h index acb2765d..48d44b0f 100644 --- a/src/bin/termio.h +++ b/src/bin/termio.h @@ -45,6 +45,7 @@ pid_t termio_pid_get(const Evas_Object *obj); Eina_Bool termio_cwd_get(const Evas_Object *obj, char *buf, size_t size); Evas_Object *termio_textgrid_get(const Evas_Object *obj); Evas_Object *termio_win_get(const Evas_Object *obj); +Evas_Object *termio_get_cursor(const Evas_Object *obj); const char *termio_title_get(const Evas_Object *obj); const char *termio_user_title_get(const Evas_Object *obj); void termio_user_title_set(Evas_Object *obj, const char *title); diff --git a/src/bin/termiointernals.h b/src/bin/termiointernals.h index 3aacc21d..ae0035a0 100644 --- a/src/bin/termiointernals.h +++ b/src/bin/termiointernals.h @@ -64,7 +64,7 @@ struct _Termio int g; int b; int a; - } saved_bg, saved_fg; + } saved_bg, saved_fg, saved_cursor; Evas_Object *ctxpopup; int zoom_fontsize_start; int scroll; diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c index ea4e2ac4..c9d9eeb6 100644 --- a/src/bin/termptyesc.c +++ b/src/bin/termptyesc.c @@ -4159,34 +4159,41 @@ err: } static void -_handle_xterm_11_command(Termpty *ty, Eina_Unicode *p, int len) +_handle_xterm_set_color_class(Termpty *ty, Eina_Unicode *p, int len, + Evas_Object *obj, + const char *color_class, + uint8_t number) { - - if (!p || !*p) + if (!p || !*p || !obj) goto err; if (*p == '?') { int r = 0, g = 0, b = 0; - char buf[32]; + char buf[64]; size_t l; - if (termio_color_class_get(ty->obj, "BG", &r, &g, &b, NULL) != 0) + if (termio_color_class_get(obj, color_class, &r, &g, &b, NULL) != 0) { - ERR("error getting color class 'BG'"); + ERR("error getting color class '%s'", color_class); } - TERMPTY_WRITE_STR("\033]11;rgb:"); - l = snprintf(buf, sizeof(buf), "%.2x%.2x/%.2x%.2x/%.2x%.2x", - r, r, g, g, b, b); + l = snprintf(buf, sizeof(buf), + "\033]%d;rgb:%.2x%.2x/%.2x%.2x/%.2x%.2x\033\\", + number, r, r, g, g, b, b); termpty_write(ty, buf, l); - TERMPTY_WRITE_STR("\033\\"); } else { unsigned char r, g, b; if (_xterm_parse_color(ty, &p, &r, &g, &b, len) < 0) goto err; - termio_color_class_set(ty->obj, "BG", r, g, b, 0xff); + 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); } return; @@ -4312,15 +4319,19 @@ _handle_esc_osc(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce) _handle_hyperlink(ty, s, len); break; case 10: + DBG("Set foreground color"); _handle_xterm_10_command(ty, p, cc - c - (p - buf)); break; case 11: - if (!p || !*p) - goto err; - _handle_xterm_11_command(ty, p, cc - c - (p - buf)); + DBG("Set background color"); + _handle_xterm_set_color_class(ty, p, cc - c - (p - buf), + ty->obj, "BG", 11); break; case 12: DBG("Set cursor color"); + _handle_xterm_set_color_class(ty, p, cc - c - (p - buf), + termio_get_cursor(ty->obj), + "CURSOR", 12); break; case 50: DBG("xterm font support"); diff --git a/src/bin/tytest_common.c b/src/bin/tytest_common.c index 93090fb5..3d55cf22 100644 --- a/src/bin/tytest_common.c +++ b/src/bin/tytest_common.c @@ -43,10 +43,8 @@ static Termio _sd = { .pty = &_ty, .config = NULL, }; -static int _bg_r = 131; -static int _bg_g = 132; -static int _bg_b = 133; -static int _bg_a = 134; +static Color _bg = { .r = 131, .g = 132, .b = 133, .a = 134 }; +static Color _cursor = { .r = 135, .g = 136, .b = 137, .a = 138 }; static const char *_cursor_shape = "undefined"; #if defined(BINARY_TYTEST) static Evas_Textgrid_Cell *_cells; @@ -88,6 +86,11 @@ main_config_sync(const Config *config EINA_UNUSED) { } +Evas_Object * +termio_get_cursor(const Evas_Object *obj EINA_UNUSED) +{ + return NULL; +} Termio * termio_get_from_obj(Evas_Object *obj EINA_UNUSED) @@ -280,13 +283,25 @@ termio_color_class_get(Evas_Object *termio EINA_UNUSED, const char *key, if (strncmp(key, "BG", strlen("BG")) == 0) { if (r) - *r = _bg_r; + *r = _bg.r; if (g) - *g = _bg_g; + *g = _bg.g; if (b) - *b = _bg_b; + *b = _bg.b; if (a) - *a = _bg_a; + *a = _bg.a; + return 0; + } + if (strncmp(key, "CURSOR", strlen("CURSOR")) == 0) + { + if (r) + *r = _cursor.r; + if (g) + *g = _cursor.g; + if (b) + *b = _cursor.b; + if (a) + *a = _cursor.a; return 0; } return -1; @@ -297,10 +312,18 @@ termio_color_class_set(Evas_Object *termio EINA_UNUSED, const char *key, { if (strncmp(key, "BG", strlen("BG")) == 0) { - _bg_r = r; - _bg_g = g; - _bg_b = b; - _bg_a = a; + _bg.r = r; + _bg.g = g; + _bg.b = b; + _bg.a = a; + return 0; + } + if (strncmp(key, "CURSOR", strlen("CURSOR")) == 0) + { + _cursor.r = r; + _cursor.g = g; + _cursor.b = b; + _cursor.a = a; return 0; } return -1; @@ -309,10 +332,14 @@ termio_color_class_set(Evas_Object *termio EINA_UNUSED, const char *key, void termio_reset_main_colors(Evas_Object *termio EINA_UNUSED) { - _bg_r = 131; - _bg_g = 132; - _bg_b = 133; - _bg_a = 134; + _bg.r = 131; + _bg.g = 132; + _bg.b = 133; + _bg.a = 134; + _cursor.r = 135; + _cursor.g = 136; + _cursor.b = 137; + _cursor.a = 138; } Evas_Object *