termptyesc: handle xterm 12 to change cursor color
This commit is contained in:
parent
049af922e2
commit
f0404cd5fd
|
@ -87,6 +87,11 @@ termio_theme_set(Evas_Object *obj, Evas_Object *theme)
|
||||||
&sd->saved_bg.g,
|
&sd->saved_bg.g,
|
||||||
&sd->saved_bg.b,
|
&sd->saved_bg.b,
|
||||||
&sd->saved_bg.a);
|
&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(
|
evas_object_textgrid_palette_get(
|
||||||
sd->grid.obj,
|
sd->grid.obj,
|
||||||
EVAS_TEXTGRID_PALETTE_STANDARD, 0,
|
EVAS_TEXTGRID_PALETTE_STANDARD, 0,
|
||||||
|
@ -110,6 +115,19 @@ termio_reset_main_colors(Evas_Object *termio)
|
||||||
sd->saved_bg.g,
|
sd->saved_bg.g,
|
||||||
sd->saved_bg.b,
|
sd->saved_bg.b,
|
||||||
sd->saved_bg.a);
|
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(
|
evas_object_textgrid_palette_set(
|
||||||
sd->grid.obj,
|
sd->grid.obj,
|
||||||
EVAS_TEXTGRID_PALETTE_STANDARD, 0,
|
EVAS_TEXTGRID_PALETTE_STANDARD, 0,
|
||||||
|
@ -555,6 +573,14 @@ _cursor_shape_to_group_name(Cursor_Shape shape)
|
||||||
return NULL;
|
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
|
void
|
||||||
termio_set_cursor_shape(Evas_Object *obj, Cursor_Shape shape)
|
termio_set_cursor_shape(Evas_Object *obj, Cursor_Shape shape)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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);
|
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_textgrid_get(const Evas_Object *obj);
|
||||||
Evas_Object *termio_win_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_title_get(const Evas_Object *obj);
|
||||||
const char *termio_user_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);
|
void termio_user_title_set(Evas_Object *obj, const char *title);
|
||||||
|
|
|
@ -64,7 +64,7 @@ struct _Termio
|
||||||
int g;
|
int g;
|
||||||
int b;
|
int b;
|
||||||
int a;
|
int a;
|
||||||
} saved_bg, saved_fg;
|
} saved_bg, saved_fg, saved_cursor;
|
||||||
Evas_Object *ctxpopup;
|
Evas_Object *ctxpopup;
|
||||||
int zoom_fontsize_start;
|
int zoom_fontsize_start;
|
||||||
int scroll;
|
int scroll;
|
||||||
|
|
|
@ -4159,34 +4159,41 @@ err:
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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 || !obj)
|
||||||
if (!p || !*p)
|
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (*p == '?')
|
if (*p == '?')
|
||||||
{
|
{
|
||||||
int r = 0, g = 0, b = 0;
|
int r = 0, g = 0, b = 0;
|
||||||
char buf[32];
|
char buf[64];
|
||||||
size_t l;
|
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),
|
||||||
l = snprintf(buf, sizeof(buf), "%.2x%.2x/%.2x%.2x/%.2x%.2x",
|
"\033]%d;rgb:%.2x%.2x/%.2x%.2x/%.2x%.2x\033\\",
|
||||||
r, r, g, g, b, b);
|
number, r, r, g, g, b, b);
|
||||||
termpty_write(ty, buf, l);
|
termpty_write(ty, buf, l);
|
||||||
TERMPTY_WRITE_STR("\033\\");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned char r, g, b;
|
unsigned char r, g, b;
|
||||||
if (_xterm_parse_color(ty, &p, &r, &g, &b, len) < 0)
|
if (_xterm_parse_color(ty, &p, &r, &g, &b, len) < 0)
|
||||||
goto err;
|
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;
|
return;
|
||||||
|
@ -4312,15 +4319,19 @@ _handle_esc_osc(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
|
||||||
_handle_hyperlink(ty, s, len);
|
_handle_hyperlink(ty, s, len);
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
|
DBG("Set foreground color");
|
||||||
_handle_xterm_10_command(ty, p, cc - c - (p - buf));
|
_handle_xterm_10_command(ty, p, cc - c - (p - buf));
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
if (!p || !*p)
|
DBG("Set background color");
|
||||||
goto err;
|
_handle_xterm_set_color_class(ty, p, cc - c - (p - buf),
|
||||||
_handle_xterm_11_command(ty, p, cc - c - (p - buf));
|
ty->obj, "BG", 11);
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
DBG("Set cursor color");
|
DBG("Set cursor color");
|
||||||
|
_handle_xterm_set_color_class(ty, p, cc - c - (p - buf),
|
||||||
|
termio_get_cursor(ty->obj),
|
||||||
|
"CURSOR", 12);
|
||||||
break;
|
break;
|
||||||
case 50:
|
case 50:
|
||||||
DBG("xterm font support");
|
DBG("xterm font support");
|
||||||
|
|
|
@ -43,10 +43,8 @@ static Termio _sd = {
|
||||||
.pty = &_ty,
|
.pty = &_ty,
|
||||||
.config = NULL,
|
.config = NULL,
|
||||||
};
|
};
|
||||||
static int _bg_r = 131;
|
static Color _bg = { .r = 131, .g = 132, .b = 133, .a = 134 };
|
||||||
static int _bg_g = 132;
|
static Color _cursor = { .r = 135, .g = 136, .b = 137, .a = 138 };
|
||||||
static int _bg_b = 133;
|
|
||||||
static int _bg_a = 134;
|
|
||||||
static const char *_cursor_shape = "undefined";
|
static const char *_cursor_shape = "undefined";
|
||||||
#if defined(BINARY_TYTEST)
|
#if defined(BINARY_TYTEST)
|
||||||
static Evas_Textgrid_Cell *_cells;
|
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 *
|
||||||
termio_get_from_obj(Evas_Object *obj EINA_UNUSED)
|
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 (strncmp(key, "BG", strlen("BG")) == 0)
|
||||||
{
|
{
|
||||||
if (r)
|
if (r)
|
||||||
*r = _bg_r;
|
*r = _bg.r;
|
||||||
if (g)
|
if (g)
|
||||||
*g = _bg_g;
|
*g = _bg.g;
|
||||||
if (b)
|
if (b)
|
||||||
*b = _bg_b;
|
*b = _bg.b;
|
||||||
if (a)
|
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 0;
|
||||||
}
|
}
|
||||||
return -1;
|
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)
|
if (strncmp(key, "BG", strlen("BG")) == 0)
|
||||||
{
|
{
|
||||||
_bg_r = r;
|
_bg.r = r;
|
||||||
_bg_g = g;
|
_bg.g = g;
|
||||||
_bg_b = b;
|
_bg.b = b;
|
||||||
_bg_a = a;
|
_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 0;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -309,10 +332,14 @@ termio_color_class_set(Evas_Object *termio EINA_UNUSED, const char *key,
|
||||||
void
|
void
|
||||||
termio_reset_main_colors(Evas_Object *termio EINA_UNUSED)
|
termio_reset_main_colors(Evas_Object *termio EINA_UNUSED)
|
||||||
{
|
{
|
||||||
_bg_r = 131;
|
_bg.r = 131;
|
||||||
_bg_g = 132;
|
_bg.g = 132;
|
||||||
_bg_b = 133;
|
_bg.b = 133;
|
||||||
_bg_a = 134;
|
_bg.a = 134;
|
||||||
|
_cursor.r = 135;
|
||||||
|
_cursor.g = 136;
|
||||||
|
_cursor.b = 137;
|
||||||
|
_cursor.a = 138;
|
||||||
}
|
}
|
||||||
|
|
||||||
Evas_Object *
|
Evas_Object *
|
||||||
|
|
Loading…
Reference in New Issue