mothra: linkify text starting with gemini:// and ftp://
This commit is contained in:
parent
8781283fbd
commit
67c15c1e47
1 changed files with 14 additions and 4 deletions
|
@ -35,6 +35,16 @@ struct Fontdata{
|
||||||
"lucidasans/typeunicode.16", 0, 0,
|
"lucidasans/typeunicode.16", 0, 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct{
|
||||||
|
char *prefix;
|
||||||
|
int len;
|
||||||
|
}links[]={
|
||||||
|
{"http://", 7},
|
||||||
|
{"https://", 8},
|
||||||
|
{"gemini://", 9},
|
||||||
|
{"ftp://", 6},
|
||||||
|
};
|
||||||
|
|
||||||
Font *pl_whichfont(int f, int s, int *space){
|
Font *pl_whichfont(int f, int s, int *space){
|
||||||
char name[NNAME];
|
char name[NNAME];
|
||||||
|
|
||||||
|
@ -296,11 +306,11 @@ int entchar(int c){
|
||||||
|
|
||||||
/* return url if text token looks like a hyperlink */
|
/* return url if text token looks like a hyperlink */
|
||||||
char *linkify(char *s){
|
char *linkify(char *s){
|
||||||
|
int i;
|
||||||
if(s == 0 && s[0] == 0)
|
if(s == 0 && s[0] == 0)
|
||||||
return 0;
|
return 0;
|
||||||
if(!cistrncmp(s, "http://", 7))
|
for(i = 0; i < nelem(links); i++)
|
||||||
return strdup(s);
|
if(!cistrncmp(s, links[i].prefix, links[i].len))
|
||||||
if(!cistrncmp(s, "https://", 8))
|
|
||||||
return strdup(s);
|
return strdup(s);
|
||||||
if(!cistrncmp(s, "www.", 4)){
|
if(!cistrncmp(s, "www.", 4)){
|
||||||
int d, i;
|
int d, i;
|
||||||
|
|
Loading…
Reference in a new issue