termptyext: be able to test color links
This commit is contained in:
parent
ef81f975c0
commit
990ef95c8b
|
@ -253,6 +253,57 @@ _handle_mouse_wheel(Termpty *ty,
|
||||||
termio_internal_mouse_wheel(sd, &ev, modifiers);
|
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:
|
* Format is:
|
||||||
* - ln : no link found under cursor
|
* - ln : no link found under cursor
|
||||||
|
@ -261,6 +312,7 @@ _handle_mouse_wheel(Termpty *ty,
|
||||||
* e: link is an email
|
* e: link is an email
|
||||||
* u: link is an url
|
* u: link is an url
|
||||||
* p: link is a file path
|
* p: link is a file path
|
||||||
|
* c: link is a color
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
_handle_link(Termpty *ty, const Eina_Unicode *buf)
|
_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;
|
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,
|
link = termio_link_find(ty->obj, sd->mouse.cx, sd->mouse.cy,
|
||||||
&x1, &y1, &x2, &y2);
|
&x1, &y1, &x2, &y2);
|
||||||
|
|
||||||
|
@ -292,8 +352,7 @@ _handle_link(Termpty *ty, const Eina_Unicode *buf)
|
||||||
assert (link == NULL);
|
assert (link == NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* skip type */
|
|
||||||
buf++;
|
|
||||||
/* Get numeric values */
|
/* Get numeric values */
|
||||||
buf += _tytest_arg_get(buf, &value);
|
buf += _tytest_arg_get(buf, &value);
|
||||||
assert(x1 == value);
|
assert(x1 == value);
|
||||||
|
@ -305,6 +364,7 @@ _handle_link(Termpty *ty, const Eina_Unicode *buf)
|
||||||
assert(y2 == value);
|
assert(y2 == value);
|
||||||
/* skip ; */
|
/* skip ; */
|
||||||
buf++;
|
buf++;
|
||||||
|
|
||||||
/* Compare strings */
|
/* Compare strings */
|
||||||
c = link;
|
c = link;
|
||||||
while (*buf)
|
while (*buf)
|
||||||
|
|
Loading…
Reference in New Issue