forked from enlightenment/terminology
termptyesc: be able to set selection from escape codes
This commit is contained in:
parent
112a5226a3
commit
f1504e1c68
|
@ -13,6 +13,7 @@
|
||||||
#if defined(BINARY_TYTEST)
|
#if defined(BINARY_TYTEST)
|
||||||
#include "tytest.h"
|
#include "tytest.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#undef CRITICAL
|
#undef CRITICAL
|
||||||
#undef ERR
|
#undef ERR
|
||||||
|
@ -4310,6 +4311,68 @@ err:
|
||||||
ty->decoding_error = EINA_TRUE;
|
ty->decoding_error = EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Elm_Sel_Type
|
||||||
|
_elm_sel_type_from_osc52(Eina_Unicode c)
|
||||||
|
{
|
||||||
|
Elm_Sel_Type sel_type;
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case 's':
|
||||||
|
sel_type = ELM_SEL_TYPE_SECONDARY;
|
||||||
|
break;
|
||||||
|
case 'c':
|
||||||
|
sel_type = ELM_SEL_TYPE_CLIPBOARD;
|
||||||
|
break;
|
||||||
|
case ';':
|
||||||
|
EINA_FALLTHROUGH;
|
||||||
|
case 'p':
|
||||||
|
EINA_FALLTHROUGH;
|
||||||
|
default:
|
||||||
|
sel_type = ELM_SEL_TYPE_PRIMARY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return sel_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_handle_osc_selection(Termpty *ty, Eina_Unicode *p, int len)
|
||||||
|
{
|
||||||
|
Eina_Unicode *c;
|
||||||
|
Elm_Sel_Type sel_type;
|
||||||
|
|
||||||
|
if (!p || !*p || len <= 0)
|
||||||
|
goto err;
|
||||||
|
c = p;
|
||||||
|
while (*c != ';' && (c - p) < len)
|
||||||
|
c++;
|
||||||
|
if (*c != ';')
|
||||||
|
goto err;
|
||||||
|
c++;
|
||||||
|
if (*c == '?')
|
||||||
|
{
|
||||||
|
/* Report */
|
||||||
|
/* TODO */
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Set */
|
||||||
|
sel_type = _elm_sel_type_from_osc52(*p);
|
||||||
|
/* Decode base64 from the request */
|
||||||
|
p[len] = '\0';
|
||||||
|
char *out = ty_eina_unicode_base64_decode(c);
|
||||||
|
|
||||||
|
if (out)
|
||||||
|
{
|
||||||
|
termio_set_selection_text(ty->obj, sel_type, out);
|
||||||
|
free(out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
err:
|
||||||
|
ty->decoding_error = EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_handle_esc_osc(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
|
_handle_esc_osc(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
|
||||||
{
|
{
|
||||||
|
@ -4454,6 +4517,11 @@ _handle_esc_osc(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
|
||||||
free(s);
|
free(s);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 52:
|
||||||
|
DBG("Manipulate selection data");
|
||||||
|
if (ty->config->selection_escapes)
|
||||||
|
_handle_osc_selection(ty, p, cc - c - (p - buf));
|
||||||
|
break;
|
||||||
case 110:
|
case 110:
|
||||||
DBG("Reset VT100 text foreground color");
|
DBG("Reset VT100 text foreground color");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -359,6 +359,37 @@ termio_bg_get(const Evas_Object *obj EINA_UNUSED)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *_sel_primary = NULL;
|
||||||
|
static char *_sel_secondary = NULL;
|
||||||
|
static char *_sel_clipboard = NULL;
|
||||||
|
|
||||||
|
void
|
||||||
|
termio_set_selection_text(Evas_Object *obj EINA_UNUSED,
|
||||||
|
Elm_Sel_Type type, const char *text)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case ELM_SEL_TYPE_PRIMARY:
|
||||||
|
free(_sel_primary);
|
||||||
|
if (text)
|
||||||
|
_sel_primary = strdup(text);
|
||||||
|
break;
|
||||||
|
case ELM_SEL_TYPE_SECONDARY:
|
||||||
|
free(_sel_secondary);
|
||||||
|
if (text)
|
||||||
|
_sel_secondary = strdup(text);
|
||||||
|
break;
|
||||||
|
case ELM_SEL_TYPE_CLIPBOARD:
|
||||||
|
free(_sel_clipboard);
|
||||||
|
if (text)
|
||||||
|
_sel_clipboard = strdup(text);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(BINARY_TYTEST)
|
#if defined(BINARY_TYTEST)
|
||||||
void
|
void
|
||||||
test_textgrid_palette_get(const Evas_Object *obj EINA_UNUSED,
|
test_textgrid_palette_get(const Evas_Object *obj EINA_UNUSED,
|
||||||
|
|
Loading…
Reference in New Issue