aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/termiolink.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2012-10-09 15:11:09 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2012-10-09 15:11:09 +0000
commit2a0e0fd2b429af5e8ec151ae3e4fe67c4e4f13ef (patch)
tree3114771beeea657f51bf298e3a88b53bab59c5ee /src/bin/termiolink.c
parentjust highlight emails with domains containing a period. (diff)
downloadterminology-2a0e0fd2b429af5e8ec151ae3e4fe67c4e4f13ef.tar.gz
refactor url handling.
there are still some left to be done, will come to it later. SVN revision: 77653
Diffstat (limited to 'src/bin/termiolink.c')
-rw-r--r--src/bin/termiolink.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/src/bin/termiolink.c b/src/bin/termiolink.c
index 86a6628..4fd1302 100644
--- a/src/bin/termiolink.c
+++ b/src/bin/termiolink.c
@@ -1,6 +1,7 @@
#include "private.h"
#include <Elementary.h>
#include "termio.h"
+#include "utils.h"
static Eina_Bool
coord_back(int *x, int *y, int w, int h __UNUSED__)
@@ -56,10 +57,7 @@ _termio_link_find(Evas_Object *obj, int cx, int cy, int *x1r, int *y1r, int *x2r
if (!s) break;
if (goback)
{
- if ((!strncasecmp(s, "http://", 7))||
- (!strncasecmp(s, "https://", 8)) ||
- (!strncasecmp(s, "file://", 7)) ||
- (!strncasecmp(s, "ftp://", 6)))
+ if (link_is_protocol(s))
{
goback = EINA_FALSE;
coord_back(&x1, &y1, w, h);
@@ -87,7 +85,7 @@ _termio_link_find(Evas_Object *obj, int cx, int cy, int *x1r, int *y1r, int *x2r
else if (s[0] == '<') endmatch = '>';
if ((!strncasecmp((s + 1), "www.", 4)) ||
(!strncasecmp((s + 1), "ftp.", 4)) ||
- (!strncasecmp((s + 1), "/", 1)))
+ (s[1] == '/'))
{
goback = EINA_FALSE;
coord_forward(&x1, &y1, w, h);
@@ -160,17 +158,9 @@ _termio_link_find(Evas_Object *obj, int cx, int cy, int *x1r, int *y1r, int *x2r
}
if ((!isspace(s[0])) && (len > 1))
{
- const char *at = strchr(s, '@');
-
- if ((at && (strchr(at + 1, '.'))) ||
- (!strncasecmp(s, "http://", 7))||
- (!strncasecmp(s, "https://", 8)) ||
- (!strncasecmp(s, "ftp://", 6)) ||
- (!strncasecmp(s, "file://", 7)) ||
- (!strncasecmp(s, "www.", 4)) ||
- (!strncasecmp(s, "ftp.", 4)) ||
- (!strncasecmp(s, "/", 1))
- )
+ if (link_is_email(s) ||
+ link_is_url(s) ||
+ (s[0] == '/'))
{
if (x1r) *x1r = x1;
if (y1r) *y1r = y1;