termptyext: add testing escape codes about selections

This commit is contained in:
Boris Faure 2019-02-10 19:36:46 +01:00
parent 5e4f814104
commit ac82934c83
1 changed files with 26 additions and 3 deletions

View File

@ -217,6 +217,23 @@ _handle_mouse_move(Termpty *ty,
termio_internal_mouse_move(sd, &ev, modifiers); termio_internal_mouse_move(sd, &ev, modifiers);
} }
static void
_handle_selection_is(Termpty *ty,
const Eina_Unicode *buf)
{
Eina_Unicode *cp = ty->selection.codepoints;
assert(ty->selection.is_active);
assert(ty->selection.codepoints != NULL);
while (*buf)
{
assert(*buf == *cp);
cp++;
buf++;
}
}
/* Testing escape codes that start with '\033}t' and end with '\0' /* Testing escape codes that start with '\033}t' and end with '\0'
* Then, * Then,
* - 'd': mouse down: * - 'd': mouse down:
@ -230,13 +247,19 @@ tytest_handle_escape_codes(Termpty *ty,
switch (buf[0]) switch (buf[0])
{ {
case 'd': case 'd':
return _handle_mouse_down(ty, buf + 1); _handle_mouse_down(ty, buf + 1);
break; break;
case 'm': case 'm':
return _handle_mouse_move(ty, buf + 1); _handle_mouse_move(ty, buf + 1);
break;
case 'n':
assert(!ty->selection.is_active);
break;
case 's':
_handle_selection_is(ty, buf+1);
break; break;
case 'u': case 'u':
return _handle_mouse_up(ty, buf + 1); _handle_mouse_up(ty, buf + 1);
break; break;
default: default:
break; break;