diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-18 16:56:20 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-18 16:56:20 +0300 |
commit | d3b7d71b7a9afff15e589f0302bf48c36d1ac6cf (patch) | |
tree | 37d1d816be0b20c1e24ebcb24f8afe8a1b036398 | |
parent | 3dccecbfa923319ec3a99462b11a26492cc14806 (diff) |
Handle image metadata overlapping the link
-rw-r--r-- | src/ui/documentwidget.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 29803252..5c9c91b7 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -1505,6 +1505,12 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) { | |||
1505 | appendFormat_String( | 1505 | appendFormat_String( |
1506 | &text, " %s\u2a2f", isHover ? escape_Color(tmLinkText_ColorId) : ""); | 1506 | &text, " %s\u2a2f", isHover ? escape_Color(tmLinkText_ColorId) : ""); |
1507 | } | 1507 | } |
1508 | const iInt2 size = measureRange_Text(metaFont, range_String(&text)); | ||
1509 | fillRect_Paint( | ||
1510 | &d->paint, | ||
1511 | (iRect){ add_I2(origin, addX_I2(topRight_Rect(run->bounds), -size.x - gap_UI)), | ||
1512 | addX_I2(size, 2 * gap_UI) }, | ||
1513 | tmBackground_ColorId); | ||
1508 | drawAlign_Text(metaFont, | 1514 | drawAlign_Text(metaFont, |
1509 | add_I2(topRight_Rect(run->bounds), origin), | 1515 | add_I2(topRight_Rect(run->bounds), origin), |
1510 | fg, | 1516 | fg, |
@@ -1527,9 +1533,8 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) { | |||
1527 | const int flags = linkFlags_GmDocument(doc, linkId); | 1533 | const int flags = linkFlags_GmDocument(doc, linkId); |
1528 | iUrl parts; | 1534 | iUrl parts; |
1529 | init_Url(&parts, url); | 1535 | init_Url(&parts, url); |
1530 | const iString *host = collect_String(newRange_String(parts.host)); | ||
1531 | fg = linkColor_GmDocument(doc, linkId, textHover_GmLinkPart); | 1536 | fg = linkColor_GmDocument(doc, linkId, textHover_GmLinkPart); |
1532 | const iBool showHost = (!isEmpty_String(host) && flags & userFriendly_GmLinkFlag); | 1537 | const iBool showHost = (!isEmpty_Range(&parts.host) && flags & userFriendly_GmLinkFlag); |
1533 | const iBool showImage = (flags & imageFileExtension_GmLinkFlag) != 0; | 1538 | const iBool showImage = (flags & imageFileExtension_GmLinkFlag) != 0; |
1534 | const iBool showAudio = (flags & audioFileExtension_GmLinkFlag) != 0; | 1539 | const iBool showAudio = (flags & audioFileExtension_GmLinkFlag) != 0; |
1535 | iString str; | 1540 | iString str; |
@@ -1541,7 +1546,12 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) { | |||
1541 | &str, | 1546 | &str, |
1542 | " \u2014%s%s%s\r%c%s", | 1547 | " \u2014%s%s%s\r%c%s", |
1543 | showHost ? " " : "", | 1548 | showHost ? " " : "", |
1544 | showHost ? cstr_String(host) : "", | 1549 | showHost ? (!equalCase_Rangecc(&parts.protocol, "gemini") |
1550 | ? format_CStr("%s://%s", | ||
1551 | cstr_Rangecc(parts.protocol), | ||
1552 | cstr_Rangecc(parts.host)) | ||
1553 | : cstr_Rangecc(parts.host)) | ||
1554 | : "", | ||
1545 | showHost && (showImage || showAudio) ? " \u2014" : "", | 1555 | showHost && (showImage || showAudio) ? " \u2014" : "", |
1546 | showImage || showAudio | 1556 | showImage || showAudio |
1547 | ? '0' + fg | 1557 | ? '0' + fg |