summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-09-17 07:48:40 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-09-17 07:48:56 +0300
commita0f5bccc709866521fefeb34d6b97cafdbec6fad (patch)
treefefbc4c6cfec66bd84b85ede26a28eb1622a6940 /src/ui
parent115602cf34dfb2f151846673468a41f16712eb49 (diff)
Recognize and visualize "mailto:" links
"mailto:" links now have their own icon and when clicked they open the URL in the default web browser. IssueID #5
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/documentwidget.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 84ad1139..e632a65c 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -1715,6 +1715,7 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
1715 topRight_Rect(linkRect), 1715 topRight_Rect(linkRect),
1716 tmInlineContentMetadata_ColorId, 1716 tmInlineContentMetadata_ColorId,
1717 " \u2014 Fetching\u2026"); 1717 " \u2014 Fetching\u2026");
1718 /* TODO: Show amount downloaded so far. */
1718 } 1719 }
1719 } 1720 }
1720 else if (isHover) { 1721 else if (isHover) {
@@ -1723,31 +1724,35 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
1723 const int flags = linkFlags_GmDocument(doc, linkId); 1724 const int flags = linkFlags_GmDocument(doc, linkId);
1724 iUrl parts; 1725 iUrl parts;
1725 init_Url(&parts, url); 1726 init_Url(&parts, url);
1726 fg = linkColor_GmDocument(doc, linkId, textHover_GmLinkPart); 1727 fg = linkColor_GmDocument(doc, linkId, textHover_GmLinkPart);
1727 const iBool showHost = (!isEmpty_Range(&parts.host) && flags & userFriendly_GmLinkFlag); 1728 const iBool showHost = (flags & humanReadable_GmLinkFlag &&
1729 (!isEmpty_Range(&parts.host) || flags & mailto_GmLinkFlag));
1728 const iBool showImage = (flags & imageFileExtension_GmLinkFlag) != 0; 1730 const iBool showImage = (flags & imageFileExtension_GmLinkFlag) != 0;
1729 const iBool showAudio = (flags & audioFileExtension_GmLinkFlag) != 0; 1731 const iBool showAudio = (flags & audioFileExtension_GmLinkFlag) != 0;
1730 iString str; 1732 iString str;
1731 init_String(&str); 1733 init_String(&str);
1734 /* Show scheme and host. */
1732 if (run->flags & endOfLine_GmRunFlag && 1735 if (run->flags & endOfLine_GmRunFlag &&
1733 (flags & (imageFileExtension_GmLinkFlag | audioFileExtension_GmLinkFlag) || 1736 (flags & (imageFileExtension_GmLinkFlag | audioFileExtension_GmLinkFlag) ||
1734 showHost)) { 1737 showHost)) {
1735 format_String( 1738 format_String(&str,
1736 &str, 1739 " \u2014%s%s%s\r%c%s",
1737 " \u2014%s%s%s\r%c%s", 1740 showHost ? " " : "",
1738 showHost ? " " : "", 1741 showHost ? (flags & mailto_GmLinkFlag
1739 showHost ? (!equalCase_Rangecc(parts.scheme, "gemini") 1742 ? cstr_String(url)
1740 ? format_CStr("%s://%s", 1743 : ~flags & gemini_GmLinkFlag
1741 cstr_Rangecc(parts.scheme), 1744 ? format_CStr("%s://%s",
1742 cstr_Rangecc(parts.host)) 1745 cstr_Rangecc(parts.scheme),
1743 : cstr_Rangecc(parts.host)) 1746 cstr_Rangecc(parts.host))
1744 : "", 1747 : cstr_Rangecc(parts.host))
1745 showHost && (showImage || showAudio) ? " \u2014" : "", 1748 : "",
1746 showImage || showAudio 1749 showHost && (showImage || showAudio) ? " \u2014" : "",
1747 ? asciiBase_ColorEscape + fg 1750 showImage || showAudio
1748 : (asciiBase_ColorEscape + linkColor_GmDocument(doc, run->linkId, domain_GmLinkPart)), 1751 ? asciiBase_ColorEscape + fg
1749 showImage ? " View Image \U0001f5bc" 1752 : (asciiBase_ColorEscape +
1750 : showAudio ? " Play Audio \U0001f3b5" : ""); 1753 linkColor_GmDocument(doc, run->linkId, domain_GmLinkPart)),
1754 showImage ? " View Image \U0001f5bc"
1755 : showAudio ? " Play Audio \U0001f3b5" : "");
1751 } 1756 }
1752 if (run->flags & endOfLine_GmRunFlag && flags & visited_GmLinkFlag) { 1757 if (run->flags & endOfLine_GmRunFlag && flags & visited_GmLinkFlag) {
1753 iDate date; 1758 iDate date;