This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository terminology.
View the commit online.
commit f1504e1c687dff7b01c3c45f62085798e128a126
Author: Boris Faure <bill...@gmail.com>
AuthorDate: Sun Aug 20 16:02:45 2023 +0200
termptyesc: be able to set selection from escape codes
---
src/bin/termptyesc.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++
src/bin/tytest_common.c | 31 ++++++++++++++++++++++
2 files changed, 99 insertions(+)
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index 08f92f2..bc9a7d4 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -13,6 +13,7 @@
#if defined(BINARY_TYTEST)
#include "tytest.h"
#endif
+#include "utils.h"
#undef CRITICAL
#undef ERR
@@ -4310,6 +4311,68 @@ err:
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
_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);
}
break;
+ case 52:
+ DBG("Manipulate selection data");
+ if (ty->config->selection_escapes)
+ _handle_osc_selection(ty, p, cc - c - (p - buf));
+ break;
case 110:
DBG("Reset VT100 text foreground color");
break;
diff --git a/src/bin/tytest_common.c b/src/bin/tytest_common.c
index 3aa910f..0527b3a 100644
--- a/src/bin/tytest_common.c
+++ b/src/bin/tytest_common.c
@@ -359,6 +359,37 @@ termio_bg_get(const Evas_Object *obj EINA_UNUSED)
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)
void
test_textgrid_palette_get(const Evas_Object *obj EINA_UNUSED,
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.