From 990ef95c8b08cd29541936f5344c39d36d4e8347 Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Thu, 14 May 2020 23:34:13 +0200 Subject: [PATCH] termptyext: be able to test color links --- src/bin/termptyext.c | 64 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/src/bin/termptyext.c b/src/bin/termptyext.c index a1677e36..ebe4cd77 100644 --- a/src/bin/termptyext.c +++ b/src/bin/termptyext.c @@ -253,6 +253,57 @@ _handle_mouse_wheel(Termpty *ty, termio_internal_mouse_wheel(sd, &ev, modifiers); } +static void +_handle_color_link(Termpty *ty, const Eina_Unicode *buf) +{ + uint8_t r = 0, g = 0, b = 0, a = 0; + int value; + Eina_Bool found; + int x1 = -1, y1 = -1, x2 = -1, y2 = -1; + Termio *sd = termio_get_from_obj(ty->obj); + + found = termio_color_find(ty->obj, sd->mouse.cx, sd->mouse.cy, + &x1, &y1, &x2, &y2, + &r, &g, &b, &a); + if (found) + { + ERR("printf '\\033}tlc;%d;%d;%d;%d;%d;%d;%d;%d\\0'", + x1,y1,x2,y2, r,g,b,a); + } + else + { + ERR("printf '\\033}tlcn\\0'"); + } + if (*buf == 'n') + { + assert(!found); + return; + } + assert(found); + + /* Get numeric values */ + buf += _tytest_arg_get(buf, &value); + assert(x1 == value); + buf += _tytest_arg_get(buf, &value); + assert(y1 == value); + buf += _tytest_arg_get(buf, &value); + assert(x2 == value); + buf += _tytest_arg_get(buf, &value); + assert(y2 == value); + /* skip ; */ + buf++; + + /* Get numeric values */ + buf += _tytest_arg_get(buf, &value); + assert(r == value); + buf += _tytest_arg_get(buf, &value); + assert(g == value); + buf += _tytest_arg_get(buf, &value); + assert(b == value); + _tytest_arg_get(buf, &value); + assert(a == value); +} + /* * Format is: * - ln : no link found under cursor @@ -261,6 +312,7 @@ _handle_mouse_wheel(Termpty *ty, * e: link is an email * u: link is an url * p: link is a file path + * c: link is a color */ static void _handle_link(Termpty *ty, const Eina_Unicode *buf) @@ -283,6 +335,14 @@ _handle_link(Termpty *ty, const Eina_Unicode *buf) cells[sd->mouse.cx].att.bg = COL_RED; } + /* skip type */ + buf++; + + if (type == 'c') + { + _handle_color_link(ty, buf); + return; + } link = termio_link_find(ty->obj, sd->mouse.cx, sd->mouse.cy, &x1, &y1, &x2, &y2); @@ -292,8 +352,7 @@ _handle_link(Termpty *ty, const Eina_Unicode *buf) assert (link == NULL); return; } - /* skip type */ - buf++; + /* Get numeric values */ buf += _tytest_arg_get(buf, &value); assert(x1 == value); @@ -305,6 +364,7 @@ _handle_link(Termpty *ty, const Eina_Unicode *buf) assert(y2 == value); /* skip ; */ buf++; + /* Compare strings */ c = link; while (*buf)