diff options
-rw-r--r-- | src/gmdocument.c | 11 | ||||
-rw-r--r-- | src/gmdocument.h | 1 | ||||
-rw-r--r-- | src/ui/documentwidget.c | 3 |
3 files changed, 14 insertions, 1 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; |
diff --git a/src/gmdocument.h b/src/gmdocument.h index 1909460f..98eef152 100644 --- a/src/gmdocument.h +++ b/src/gmdocument.h | |||
@@ -169,6 +169,7 @@ const char * findLoc_GmDocument (const iGmDocument *, iInt2 pos); | |||
169 | const iGmRun * findRunAtLoc_GmDocument (const iGmDocument *, const char *loc); | 169 | const iGmRun * findRunAtLoc_GmDocument (const iGmDocument *, const char *loc); |
170 | const iString * linkUrl_GmDocument (const iGmDocument *, iGmLinkId linkId); | 170 | const iString * linkUrl_GmDocument (const iGmDocument *, iGmLinkId linkId); |
171 | iRangecc linkUrlRange_GmDocument (const iGmDocument *, iGmLinkId linkId); | 171 | iRangecc linkUrlRange_GmDocument (const iGmDocument *, iGmLinkId linkId); |
172 | iRangecc linkLabel_GmDocument (const iGmDocument *, iGmLinkId linkId); | ||
172 | iMediaId linkImage_GmDocument (const iGmDocument *, iGmLinkId linkId); | 173 | iMediaId linkImage_GmDocument (const iGmDocument *, iGmLinkId linkId); |
173 | iMediaId linkAudio_GmDocument (const iGmDocument *, iGmLinkId linkId); | 174 | iMediaId linkAudio_GmDocument (const iGmDocument *, iGmLinkId linkId); |
174 | int linkFlags_GmDocument (const iGmDocument *, iGmLinkId linkId); | 175 | int linkFlags_GmDocument (const iGmDocument *, iGmLinkId linkId); |
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index b0107a75..5d3aa3ba 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -2449,7 +2449,8 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e | |||
2449 | format_CStr("!open noproxy:1 url:%s", cstr_String(linkUrl)) } }, | 2449 | format_CStr("!open noproxy:1 url:%s", cstr_String(linkUrl)) } }, |
2450 | 2); | 2450 | 2); |
2451 | } | 2451 | } |
2452 | iString *linkLabel = collect_String(newRange_String(d->contextLink->text)); | 2452 | iString *linkLabel = collectNewRange_String( |
2453 | linkLabel_GmDocument(d->doc, d->contextLink->linkId)); | ||
2453 | urlEncodeSpaces_String(linkLabel); | 2454 | urlEncodeSpaces_String(linkLabel); |
2454 | pushBackN_Array(&items, | 2455 | pushBackN_Array(&items, |
2455 | (iMenuItem[]){ { "---", 0, 0, NULL }, | 2456 | (iMenuItem[]){ { "---", 0, 0, NULL }, |