aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/termptyesc.c
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2014-08-17 17:44:19 +0200
committerBoris Faure <billiob@gmail.com>2014-08-17 17:44:19 +0200
commit5dfb63a14a7436b81803d5232ef2cd3c5990499d (patch)
tree8f7c41d5a89453b6803637421bf9245059cd6b88 /src/bin/termptyesc.c
parentclean up xterm escape codes handling (diff)
downloadterminology-5dfb63a14a7436b81803d5232ef2cd3c5990499d.tar.gz
handle queries on some xterm escape codes
Diffstat (limited to 'src/bin/termptyesc.c')
-rw-r--r--src/bin/termptyesc.c96
1 files changed, 69 insertions, 27 deletions
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index b83fe1d..7490eaa 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -1096,6 +1096,9 @@ _handle_esc_xterm(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
if ((*cc == ST) || (*cc == BEL) || (*cc == '\\')) cc++;
else return 0;
+#define TERMPTY_WRITE_STR(_S) \
+ termpty_write(ty, _S, strlen(_S))
+
arg = _xterm_arg_get(&b);
switch (arg)
{
@@ -1105,56 +1108,92 @@ _handle_esc_xterm(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
// XXX: title + name - callback
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.icon) eina_stringshare_del(ty->prop.icon);
- if (s)
+ if (*b == '?')
{
- ty->prop.title = eina_stringshare_add(s);
- ty->prop.icon = eina_stringshare_add(s);
- free(s);
+ TERMPTY_WRITE_STR("\033]0;");
+ if (ty->prop.title)
+ {
+ TERMPTY_WRITE_STR(ty->prop.title);
+ }
+ TERMPTY_WRITE_STR("\007");
}
else
{
- ty->prop.title = NULL;
- ty->prop.icon = NULL;
+ s = eina_unicode_unicode_to_utf8(b, &len);
+ if (ty->prop.title) eina_stringshare_del(ty->prop.title);
+ if (ty->prop.icon) eina_stringshare_del(ty->prop.icon);
+ if (s)
+ {
+ ty->prop.title = eina_stringshare_add(s);
+ ty->prop.icon = eina_stringshare_add(s);
+ free(s);
+ }
+ else
+ {
+ ty->prop.title = NULL;
+ ty->prop.icon = NULL;
+ }
+ 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_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);
break;
case 1:
+ // XXX: icon name - callback
if (!*b)
goto err;
- // XXX: icon name - callback
- s = eina_unicode_unicode_to_utf8(b, &len);
- if (ty->prop.icon) eina_stringshare_del(ty->prop.icon);
- if (s)
+ if (*b == '?')
{
- ty->prop.icon = eina_stringshare_add(s);
- free(s);
+ TERMPTY_WRITE_STR("\033]0;");
+ if (ty->prop.icon)
+ {
+ TERMPTY_WRITE_STR(ty->prop.icon);
+ }
+ TERMPTY_WRITE_STR("\007");
}
else
{
- ty->prop.icon = NULL;
+ s = eina_unicode_unicode_to_utf8(b, &len);
+ if (ty->prop.icon) eina_stringshare_del(ty->prop.icon);
+ if (s)
+ {
+ ty->prop.icon = eina_stringshare_add(s);
+ free(s);
+ }
+ else
+ {
+ ty->prop.icon = NULL;
+ }
+ 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;
case 2:
+ // XXX: title - callback
if (!*b)
goto err;
- // XXX: title - callback
- s = eina_unicode_unicode_to_utf8(b, &len);
- if (ty->prop.title) eina_stringshare_del(ty->prop.title);
- if (s)
+ if (*b == '?')
{
- ty->prop.title = eina_stringshare_add(s);
- free(s);
+ TERMPTY_WRITE_STR("\033]0;");
+ if (ty->prop.title)
+ {
+ TERMPTY_WRITE_STR(ty->prop.title);
+ }
+ TERMPTY_WRITE_STR("\007");
}
else
{
- ty->prop.title = NULL;
+ s = eina_unicode_unicode_to_utf8(b, &len);
+ if (ty->prop.title) eina_stringshare_del(ty->prop.title);
+ if (s)
+ {
+ ty->prop.title = eina_stringshare_add(s);
+ free(s);
+ }
+ else
+ {
+ ty->prop.title = NULL;
+ }
+ 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;
case 4:
if (!*b)
@@ -1168,6 +1207,9 @@ _handle_esc_xterm(Termpty *ty, const Eina_Unicode *c, Eina_Unicode *ce)
ERR("unhandled xterm esc %d", arg);
break;
}
+
+#undef TERMPTY_WRITE_STR
+
return cc - c;
err:
ERR("invalid xterm sequence");