forked from enlightenment/terminology
cleanup and fix _termio_link_find();
This commit is contained in:
parent
1b46022c53
commit
1f069a2fbe
|
@ -102,7 +102,7 @@ _termio_link_find(Evas_Object *obj, int cx, int cy,
|
||||||
char endmatch = 0;
|
char endmatch = 0;
|
||||||
int x1, x2, y1, y2, w = 0, h = 0, sc;
|
int x1, x2, y1, y2, w = 0, h = 0, sc;
|
||||||
size_t len;
|
size_t len;
|
||||||
Eina_Bool goback = EINA_TRUE, goforward = EINA_TRUE, extend = EINA_FALSE;
|
Eina_Bool goback = EINA_TRUE, goforward = EINA_FALSE, escaped = EINA_FALSE;
|
||||||
|
|
||||||
x1 = x2 = cx;
|
x1 = x2 = cx;
|
||||||
y1 = y2 = cy;
|
y1 = y2 = cy;
|
||||||
|
@ -118,72 +118,76 @@ _termio_link_find(Evas_Object *obj, int cx, int cy,
|
||||||
if (link_is_protocol(s))
|
if (link_is_protocol(s))
|
||||||
{
|
{
|
||||||
goback = EINA_FALSE;
|
goback = EINA_FALSE;
|
||||||
|
goforward = EINA_TRUE;
|
||||||
|
|
||||||
|
/* Check if the previous char is a delimiter */
|
||||||
coord_back(&x1, &y1, w, h);
|
coord_back(&x1, &y1, w, h);
|
||||||
free(s);
|
free(s);
|
||||||
s = termio_selection_get(obj, x1, y1 - sc, x2, y2 - sc,
|
s = termio_selection_get(obj, x1, y1 - sc, x2, y2 - sc,
|
||||||
&len);
|
&len);
|
||||||
if (!s) break;
|
if (!s) break;
|
||||||
if (s[0] == '"') endmatch = '"';
|
switch (s[0])
|
||||||
else if (s[0] == '\'') endmatch = '\'';
|
{
|
||||||
else if (s[0] == '<') endmatch = '>';
|
case '"': endmatch = '"'; break;
|
||||||
|
case '\'': endmatch = '\''; break;
|
||||||
|
case '`': endmatch = '\''; break;
|
||||||
|
case '<': endmatch = '>'; break;
|
||||||
|
case '[': endmatch = ']'; break;
|
||||||
|
case '{': endmatch = '}'; break;
|
||||||
|
case '(': endmatch = ')'; break;
|
||||||
|
}
|
||||||
coord_forward(&x1, &y1, w, h);
|
coord_forward(&x1, &y1, w, h);
|
||||||
|
|
||||||
free(s);
|
free(s);
|
||||||
s = termio_selection_get(obj, x1, y1 - sc, x2, y2 - sc,
|
s = termio_selection_get(obj, x1, y1 - sc, x2, y2 - sc,
|
||||||
&len);
|
&len);
|
||||||
if (!s) break;
|
if (!s) break;
|
||||||
}
|
}
|
||||||
else if ((isspace(s[0])) ||
|
else
|
||||||
(s[0] == '"') ||
|
|
||||||
(s[0] == '`') ||
|
|
||||||
(s[0] == '\'') ||
|
|
||||||
(s[0] == '<') ||
|
|
||||||
(s[0] == '='))
|
|
||||||
{
|
{
|
||||||
if (s[0] == '"') endmatch = '"';
|
switch (s[0])
|
||||||
else if (s[0] == '\'') endmatch = '\'';
|
{
|
||||||
else if (s[0] == '`') endmatch = '\'';
|
case '"': endmatch = '"'; break;
|
||||||
else if (s[0] == '<') endmatch = '>';
|
case '\'': endmatch = '\''; break;
|
||||||
if ((casestartswith((s + 1), "www.")) ||
|
case '`': endmatch = '\''; break;
|
||||||
(casestartswith((s + 1), "ftp.")) ||
|
case '<': endmatch = '>'; break;
|
||||||
(_is_file(s + 1)))
|
case '[': endmatch = ']'; break;
|
||||||
{
|
case '{': endmatch = '}'; break;
|
||||||
goback = EINA_FALSE;
|
case '(': endmatch = ')'; break;
|
||||||
coord_forward(&x1, &y1, w, h);
|
}
|
||||||
}
|
if ((endmatch) || (isspace(s[0])))
|
||||||
else
|
|
||||||
{
|
{
|
||||||
goback = EINA_FALSE;
|
goback = EINA_FALSE;
|
||||||
coord_forward(&x1, &y1, w, h);
|
coord_forward(&x1, &y1, w, h);
|
||||||
|
goforward = EINA_TRUE;
|
||||||
|
free(s);
|
||||||
|
s = termio_selection_get(obj, x1, y1 - sc, x2, y2 - sc,
|
||||||
|
&len);
|
||||||
|
if (!s) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (goforward)
|
if ((goforward) && (len >= 1))
|
||||||
{
|
{
|
||||||
if (len > 1)
|
char end = s[len - 1];
|
||||||
|
|
||||||
|
if (((endmatch) && (end == endmatch)) ||
|
||||||
|
((!endmatch) && (!escaped) && (isspace(end))))
|
||||||
{
|
{
|
||||||
if (((endmatch) && (s[len - 1] == endmatch)) ||
|
goforward = EINA_FALSE;
|
||||||
((!endmatch) &&
|
coord_back(&x2, &y2, w, h);
|
||||||
((isspace(s[len - 1])) || (s[len - 1] == '>'))
|
endmatch = 0;
|
||||||
))
|
|
||||||
{
|
|
||||||
goforward = EINA_FALSE;
|
|
||||||
coord_back(&x2, &y2, w, h);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
escaped = (end == '\\');
|
||||||
}
|
}
|
||||||
|
if ((goback) && (!coord_back(&x1, &y1, w, h)))
|
||||||
if (goforward)
|
|
||||||
{
|
|
||||||
if (!coord_forward(&x2, &y2, w, h)) goforward = EINA_FALSE;
|
|
||||||
}
|
|
||||||
if (goback)
|
|
||||||
{
|
|
||||||
if (!coord_back(&x1, &y1, w, h)) goback = EINA_FALSE;
|
|
||||||
}
|
|
||||||
if ((!extend) && (!goback))
|
|
||||||
{
|
{
|
||||||
|
goback = EINA_FALSE;
|
||||||
goforward = EINA_TRUE;
|
goforward = EINA_TRUE;
|
||||||
extend = EINA_TRUE;
|
}
|
||||||
|
if ((goforward) && (!coord_forward(&x2, &y2, w, h)))
|
||||||
|
{
|
||||||
|
goforward = EINA_FALSE;
|
||||||
}
|
}
|
||||||
if ((!goback) && (!goforward))
|
if ((!goback) && (!goforward))
|
||||||
{
|
{
|
||||||
|
@ -196,16 +200,7 @@ _termio_link_find(Evas_Object *obj, int cx, int cy,
|
||||||
}
|
}
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
while (len > 1)
|
if ((len > 1) && (!endmatch))
|
||||||
{
|
|
||||||
if (isspace(s[len - 1]))
|
|
||||||
{
|
|
||||||
s[len - 1] = 0;
|
|
||||||
len--;
|
|
||||||
}
|
|
||||||
else break;
|
|
||||||
}
|
|
||||||
if ((!isspace(s[0])) && (len > 1))
|
|
||||||
{
|
{
|
||||||
Eina_Bool is_file = _is_file(s);
|
Eina_Bool is_file = _is_file(s);
|
||||||
if (is_file ||
|
if (is_file ||
|
||||||
|
|
Loading…
Reference in New Issue