summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-07-17 08:59:20 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-07-17 08:59:20 +0300
commit7e536572b602cba180ad4e85bd9c071479f6fa22 (patch)
tree6684609ee55ace94b3a65a48667f6c13a5cb12db /src/ui
parent49656e357eb9741e8d44ae01d96268312e6fdc83 (diff)
GmDocument: Link scheme flags
A better way to keep track of the scheme used in a link.
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/documentwidget.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 53f5d09b..8072a025 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -3857,7 +3857,7 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
3857 } 3857 }
3858 refresh_Widget(w); 3858 refresh_Widget(w);
3859 } 3859 }
3860 else if (linkFlags & supportedProtocol_GmLinkFlag) { 3860 else if (linkFlags & supportedScheme_GmLinkFlag) {
3861 int tabMode = openTabMode_Sym(modState_Keys()); 3861 int tabMode = openTabMode_Sym(modState_Keys());
3862 if (isPinned_DocumentWidget_(d)) { 3862 if (isPinned_DocumentWidget_(d)) {
3863 tabMode ^= otherRoot_OpenTabFlag; 3863 tabMode ^= otherRoot_OpenTabFlag;
@@ -4309,8 +4309,10 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
4309 iUrl parts; 4309 iUrl parts;
4310 init_Url(&parts, url); 4310 init_Url(&parts, url);
4311 fg = linkColor_GmDocument(doc, linkId, textHover_GmLinkPart); 4311 fg = linkColor_GmDocument(doc, linkId, textHover_GmLinkPart);
4312 const enum iGmLinkScheme scheme = scheme_GmLinkFlag(flags);
4312 const iBool showHost = (flags & humanReadable_GmLinkFlag && 4313 const iBool showHost = (flags & humanReadable_GmLinkFlag &&
4313 (!isEmpty_Range(&parts.host) || flags & mailto_GmLinkFlag)); 4314 (!isEmpty_Range(&parts.host) ||
4315 scheme == mailto_GmLinkScheme));
4314 const iBool showImage = (flags & imageFileExtension_GmLinkFlag) != 0; 4316 const iBool showImage = (flags & imageFileExtension_GmLinkFlag) != 0;
4315 const iBool showAudio = (flags & audioFileExtension_GmLinkFlag) != 0; 4317 const iBool showAudio = (flags & audioFileExtension_GmLinkFlag) != 0;
4316 iString str; 4318 iString str;
@@ -4324,11 +4326,11 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
4324 "%s%s%s%s%s", 4326 "%s%s%s%s%s",
4325 showHost ? "" : "", 4327 showHost ? "" : "",
4326 showHost 4328 showHost
4327 ? (flags & mailto_GmLinkFlag ? cstr_String(url) 4329 ? (scheme == mailto_GmLinkScheme ? cstr_String(url)
4328 : ~flags & gemini_GmLinkFlag ? format_CStr("%s://%s", 4330 : scheme != gemini_GmLinkScheme ? format_CStr("%s://%s",
4329 cstr_Rangecc(parts.scheme), 4331 cstr_Rangecc(parts.scheme),
4330 cstr_Rangecc(parts.host)) 4332 cstr_Rangecc(parts.host))
4331 : cstr_Rangecc(parts.host)) 4333 : cstr_Rangecc(parts.host))
4332 : "", 4334 : "",
4333 showHost && (showImage || showAudio) ? " \u2014" : "", 4335 showHost && (showImage || showAudio) ? " \u2014" : "",
4334 showImage || showAudio 4336 showImage || showAudio