diff options
Diffstat (limited to 'src/gmdocument.c')
-rw-r--r-- | src/gmdocument.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c index f8e5b8ad..bade99ce 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -47,6 +47,7 @@ iDeclareType(GmLink) | |||
47 | struct Impl_GmLink { | 47 | struct Impl_GmLink { |
48 | iString url; | 48 | iString url; |
49 | iRangecc urlRange; /* URL in the source */ | 49 | iRangecc urlRange; /* URL in the source */ |
50 | iRangecc labelRange; /* label in the source */ | ||
50 | iRangecc labelIcon; /* special icon defined in the label text */ | 51 | iRangecc labelIcon; /* special icon defined in the label text */ |
51 | iTime when; | 52 | iTime when; |
52 | int flags; | 53 | int flags; |
@@ -55,6 +56,7 @@ struct Impl_GmLink { | |||
55 | void init_GmLink(iGmLink *d) { | 56 | void init_GmLink(iGmLink *d) { |
56 | init_String(&d->url); | 57 | init_String(&d->url); |
57 | d->urlRange = iNullRange; | 58 | d->urlRange = iNullRange; |
59 | d->labelRange = iNullRange; | ||
58 | iZap(d->when); | 60 | iZap(d->when); |
59 | d->flags = 0; | 61 | d->flags = 0; |
60 | } | 62 | } |
@@ -235,6 +237,7 @@ static iRangecc addLink_GmDocument_(iGmDocument *d, iRangecc line, iGmLinkId *li | |||
235 | *linkId = size_PtrArray(&d->links); /* index + 1 */ | 237 | *linkId = size_PtrArray(&d->links); /* index + 1 */ |
236 | iRangecc desc = capturedRange_RegExpMatch(&m, 2); | 238 | iRangecc desc = capturedRange_RegExpMatch(&m, 2); |
237 | trim_Rangecc(&desc); | 239 | trim_Rangecc(&desc); |
240 | link->labelRange = desc; | ||
238 | link->labelIcon = iNullRange; | 241 | link->labelIcon = iNullRange; |
239 | if (!isEmpty_Range(&desc)) { | 242 | if (!isEmpty_Range(&desc)) { |
240 | line = desc; /* Just show the description. */ | 243 | line = desc; /* Just show the description. */ |
@@ -1522,6 +1525,14 @@ iRangecc linkUrlRange_GmDocument(const iGmDocument *d, iGmLinkId linkId) { | |||
1522 | return link->urlRange; | 1525 | return link->urlRange; |
1523 | } | 1526 | } |
1524 | 1527 | ||
1528 | iRangecc linkLabel_GmDocument(const iGmDocument *d, iGmLinkId linkId) { | ||
1529 | const iGmLink *link = link_GmDocument_(d, linkId); | ||
1530 | if (isEmpty_Range(&link->labelRange)) { | ||
1531 | return link->urlRange; | ||
1532 | } | ||
1533 | return link->labelRange; | ||
1534 | } | ||
1535 | |||
1525 | int linkFlags_GmDocument(const iGmDocument *d, iGmLinkId linkId) { | 1536 | int linkFlags_GmDocument(const iGmDocument *d, iGmLinkId linkId) { |
1526 | const iGmLink *link = link_GmDocument_(d, linkId); | 1537 | const iGmLink *link = link_GmDocument_(d, linkId); |
1527 | return link ? link->flags : 0; | 1538 | return link ? link->flags : 0; |