summaryrefslogtreecommitdiff
path: root/src/gmdocument.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-03-12 21:24:54 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-03-12 21:24:54 +0200
commitda62f092258e313bbd28745a6e32e6d8117f4aa3 (patch)
tree81e8e40128aa8adaaa37ebc3af59f6fcbf776b4e /src/gmdocument.c
parent6410ed3c412ad9a9b688f40e981a70da03c8baca (diff)
DocumentWidget: Bookmarking a wrapped link
Only the clicked part of the label text was used for the bookmark.
Diffstat (limited to 'src/gmdocument.c')
-rw-r--r--src/gmdocument.c11
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)
47struct Impl_GmLink { 47struct 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 {
55void init_GmLink(iGmLink *d) { 56void 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
1528iRangecc 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
1525int linkFlags_GmDocument(const iGmDocument *d, iGmLinkId linkId) { 1536int 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;