clean up xterm escape codes handling
This commit is contained in:
parent
fa88d971b1
commit
61050bd7cc
|
@ -1043,6 +1043,26 @@ unhandled:
|
||||||
return cc - c;
|
return cc - c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_xterm_arg_get(Eina_Unicode **ptr)
|
||||||
|
{
|
||||||
|
Eina_Unicode *b = *ptr;
|
||||||
|
int sum = 0;
|
||||||
|
|
||||||
|
while (isdigit(*b))
|
||||||
|
{
|
||||||
|
sum *= 10;
|
||||||
|
sum += *b - '0';
|
||||||
|
b++;
|
||||||
|
}
|
||||||
|
if (*b != ';')
|
||||||
|
sum = -1;
|
||||||
|
else
|
||||||
|
b++;
|
||||||
|
*ptr = b;
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_handle_esc_xterm(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
|
_handle_esc_xterm(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
|
||||||
{
|
{
|
||||||
|
@ -1050,6 +1070,7 @@ _handle_esc_xterm(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
|
||||||
Eina_Unicode buf[4096], *b;
|
Eina_Unicode buf[4096], *b;
|
||||||
char *s;
|
char *s;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
int arg;
|
||||||
|
|
||||||
cc = c;
|
cc = c;
|
||||||
b = buf;
|
b = buf;
|
||||||
|
@ -1071,13 +1092,20 @@ _handle_esc_xterm(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
|
||||||
return cc - c;
|
return cc - c;
|
||||||
}
|
}
|
||||||
*b = 0;
|
*b = 0;
|
||||||
|
b = buf;
|
||||||
if ((*cc == ST) || (*cc == BEL) || (*cc == '\\')) cc++;
|
if ((*cc == ST) || (*cc == BEL) || (*cc == '\\')) cc++;
|
||||||
else return 0;
|
else return 0;
|
||||||
switch (buf[0])
|
|
||||||
|
arg = _xterm_arg_get(&b);
|
||||||
|
switch (arg)
|
||||||
{
|
{
|
||||||
case '0':
|
case -1:
|
||||||
|
goto err;
|
||||||
|
case 0:
|
||||||
// XXX: title + name - callback
|
// XXX: title + name - callback
|
||||||
s = eina_unicode_unicode_to_utf8(&(buf[2]), &len);
|
if (!*b)
|
||||||
|
goto err;
|
||||||
|
s = eina_unicode_unicode_to_utf8(b, &len);
|
||||||
if (ty->prop.title) eina_stringshare_del(ty->prop.title);
|
if (ty->prop.title) eina_stringshare_del(ty->prop.title);
|
||||||
if (ty->prop.icon) eina_stringshare_del(ty->prop.icon);
|
if (ty->prop.icon) eina_stringshare_del(ty->prop.icon);
|
||||||
if (s)
|
if (s)
|
||||||
|
@ -1094,9 +1122,11 @@ _handle_esc_xterm(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
|
||||||
if (ty->cb.set_title.func) ty->cb.set_title.func(ty->cb.set_title.data);
|
if (ty->cb.set_title.func) ty->cb.set_title.func(ty->cb.set_title.data);
|
||||||
if (ty->cb.set_icon.func) ty->cb.set_icon.func(ty->cb.set_icon.data);
|
if (ty->cb.set_icon.func) ty->cb.set_icon.func(ty->cb.set_icon.data);
|
||||||
break;
|
break;
|
||||||
case '1':
|
case 1:
|
||||||
|
if (!*b)
|
||||||
|
goto err;
|
||||||
// XXX: icon name - callback
|
// XXX: icon name - callback
|
||||||
s = eina_unicode_unicode_to_utf8(&(buf[2]), &len);
|
s = eina_unicode_unicode_to_utf8(b, &len);
|
||||||
if (ty->prop.icon) eina_stringshare_del(ty->prop.icon);
|
if (ty->prop.icon) eina_stringshare_del(ty->prop.icon);
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
|
@ -1109,9 +1139,11 @@ _handle_esc_xterm(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
|
||||||
}
|
}
|
||||||
if (ty->cb.set_icon.func) ty->cb.set_icon.func(ty->cb.set_icon.data);
|
if (ty->cb.set_icon.func) ty->cb.set_icon.func(ty->cb.set_icon.data);
|
||||||
break;
|
break;
|
||||||
case '2':
|
case 2:
|
||||||
|
if (!*b)
|
||||||
|
goto err;
|
||||||
// XXX: title - callback
|
// XXX: title - callback
|
||||||
s = eina_unicode_unicode_to_utf8(&(buf[2]), &len);
|
s = eina_unicode_unicode_to_utf8(b, &len);
|
||||||
if (ty->prop.title) eina_stringshare_del(ty->prop.title);
|
if (ty->prop.title) eina_stringshare_del(ty->prop.title);
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
|
@ -1124,17 +1156,22 @@ _handle_esc_xterm(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
|
||||||
}
|
}
|
||||||
if (ty->cb.set_title.func) ty->cb.set_title.func(ty->cb.set_title.data);
|
if (ty->cb.set_title.func) ty->cb.set_title.func(ty->cb.set_title.data);
|
||||||
break;
|
break;
|
||||||
case '4':
|
case 4:
|
||||||
|
if (!*b)
|
||||||
|
goto err;
|
||||||
// XXX: set palette entry. not supported.
|
// XXX: set palette entry. not supported.
|
||||||
DBG("set palette, not supported");
|
WRN("set palette, not supported");
|
||||||
if ((cc - c) < 3) return 0;
|
if ((cc - c) < 3) return 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// many others
|
// many others
|
||||||
ERR("unhandled xterm esc '%c'", buf[0]);
|
ERR("unhandled xterm esc %d", arg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return cc - c;
|
return cc - c;
|
||||||
|
err:
|
||||||
|
ERR("invalid xterm sequence");
|
||||||
|
return cc - c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Reference in New Issue