summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/termptyext.c87
1 files changed, 87 insertions, 0 deletions
diff --git a/src/bin/termptyext.c b/src/bin/termptyext.c
index 1c183b0..7cc41fc 100644
--- a/src/bin/termptyext.c
+++ b/src/bin/termptyext.c
@@ -1,6 +1,7 @@
1#include "private.h" 1#include "private.h"
2#include <Elementary.h> 2#include <Elementary.h>
3#include "termio.h" 3#include "termio.h"
4#include "termiolink.h"
4#include "termpty.h" 5#include "termpty.h"
5#include "termptyops.h" 6#include "termptyops.h"
6#include "termiointernals.h" 7#include "termiointernals.h"
@@ -219,6 +220,88 @@ _handle_mouse_wheel(Termpty *ty,
219 termio_internal_mouse_wheel(sd, &ev, modifiers); 220 termio_internal_mouse_wheel(sd, &ev, modifiers);
220} 221}
221 222
223/*
224 * Format is:
225 * - ln : no link found under cursor
226 * - lT;X1;Y1;X2;Y2;LINK
227 * where T is
228 * e: link is an email
229 * u: link is an url
230 * p: link is a file path
231 */
232static void
233_handle_link(Termpty *ty, const Eina_Unicode *buf)
234{
235 const Eina_Unicode type = buf[0];
236 Termio *sd = termio_get_from_obj(ty->obj);
237 char *link, *c;
238 int x1 = -1, y1 = -1, x2 = -1, y2 = -1;
239 int value;
240
241 /* highlight where the mouse is */
242 {
243 Termcell *cells = NULL;
244 ssize_t w;
245
246 cells = termpty_cellrow_get(ty, sd->mouse.cy, &w);
247 termpty_reset_att(&cells[sd->mouse.cx].att);
248 cells[sd->mouse.cx].att.bold = 1;
249 cells[sd->mouse.cx].att.fg = COL_WHITE;
250 cells[sd->mouse.cx].att.bg = COL_RED;
251 }
252
253 link = termio_link_find(ty->obj, sd->mouse.cx, sd->mouse.cy,
254 &x1, &y1, &x2, &y2);
255
256 ERR("x1:%d y1:%d x2:%d y2:%d link:'%s'", x1, y1, x2, y2, link);
257 if (type == 'n')
258 {
259 assert (link == NULL);
260 return;
261 }
262 /* skip type */
263 buf++;
264 /* Get numeric values */
265 buf += _tytest_arg_get(buf, &value);
266 assert(x1 == value);
267 buf += _tytest_arg_get(buf, &value);
268 assert(y1 == value);
269 buf += _tytest_arg_get(buf, &value);
270 assert(x2 == value);
271 buf += _tytest_arg_get(buf, &value);
272 assert(y2 == value);
273 /* skip ; */
274 buf++;
275 /* Compare strings */
276 c = link;
277 while (*buf)
278 {
279 int idx = 0;
280 Eina_Unicode u = eina_unicode_utf8_next_get(c, &idx);
281
282 ERR("%c vs %c", *buf, u);
283 assert(*buf == u && "unexpected character in selection");
284 c += idx;
285 buf++;
286 }
287
288 switch (type)
289 {
290 case 'u':
291 assert(link_is_url(link));
292 break;
293 case 'p':
294 assert(link_is_file(link));
295 break;
296 case 'e':
297 assert(link_is_email(link));
298 break;
299 default:
300 abort();
301 }
302 free(link);
303}
304
222static void 305static void
223_handle_selection_is(Termpty *ty, 306_handle_selection_is(Termpty *ty,
224 const Eina_Unicode *buf) 307 const Eina_Unicode *buf)
@@ -295,6 +378,7 @@ _handle_corner(Termpty *ty, const Eina_Unicode *buf)
295 * - 'd': mouse down: 378 * - 'd': mouse down:
296 * - 'u': mouse up; 379 * - 'u': mouse up;
297 * - 'm': mouse move; 380 * - 'm': mouse move;
381 * - 'l': assert mouse is over a link
298 * - 'r': force rendering and possibly remove selection; 382 * - 'r': force rendering and possibly remove selection;
299 * - 'n': assert there is no selection 383 * - 'n': assert there is no selection
300 * - 's': assert selection is what follows till '\0' 384 * - 's': assert selection is what follows till '\0'
@@ -311,6 +395,9 @@ tytest_handle_escape_codes(Termpty *ty,
311 case 'd': 395 case 'd':
312 _handle_mouse_down(ty, buf + 1); 396 _handle_mouse_down(ty, buf + 1);
313 break; 397 break;
398 case 'l':
399 _handle_link(ty, buf + 1);
400 break;
314 case 'm': 401 case 'm':
315 _handle_mouse_move(ty, buf + 1); 402 _handle_mouse_move(ty, buf + 1);
316 break; 403 break;