diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/documentwidget.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 200bda95..3b8c468b 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -144,14 +144,20 @@ void deinit_DocumentWidget(iDocumentWidget *d) { | |||
144 | SDL_FreeCursor(d->handCursor); | 144 | SDL_FreeCursor(d->handCursor); |
145 | } | 145 | } |
146 | 146 | ||
147 | #if 0 | ||
147 | static iString *cleanUrl_(const iString *url) { | 148 | static iString *cleanUrl_(const iString *url) { |
148 | iString *clean = copy_String(url); | 149 | iString *clean = copy_String(url); |
149 | if (indexOfCStr_String(url, "://") == iInvalidPos && !startsWithCase_String(url, "gemini:")) { | 150 | if (startsWith_String(url, "//")) { |
151 | prependCStr_String(clean, "gemini:"); | ||
152 | } | ||
153 | else if (indexOfCStr_String(url, "://") == iInvalidPos && !startsWithCase_String(url, "gemini:") | ||
154 | && !startsWithCase_String(url, "data:")) { | ||
150 | /* Prepend default protocol. */ | 155 | /* Prepend default protocol. */ |
151 | prependCStr_String(clean, "gemini://"); | 156 | prependCStr_String(clean, "gemini://"); |
152 | } | 157 | } |
153 | return clean; | 158 | return clean; |
154 | } | 159 | } |
160 | #endif | ||
155 | 161 | ||
156 | static int documentWidth_DocumentWidget_(const iDocumentWidget *d) { | 162 | static int documentWidth_DocumentWidget_(const iDocumentWidget *d) { |
157 | const iWidget *w = constAs_Widget(d); | 163 | const iWidget *w = constAs_Widget(d); |
@@ -201,7 +207,7 @@ static iRangei visibleRange_DocumentWidget_(const iDocumentWidget *d) { | |||
201 | 207 | ||
202 | static void addVisibleLink_DocumentWidget_(void *context, const iGmRun *run) { | 208 | static void addVisibleLink_DocumentWidget_(void *context, const iGmRun *run) { |
203 | iDocumentWidget *d = context; | 209 | iDocumentWidget *d = context; |
204 | if (run->linkId) { | 210 | if (run->linkId && linkFlags_GmDocument(d->doc, run->linkId) & supportedProtocol_GmLinkFlag) { |
205 | pushBack_PtrArray(&d->visibleLinks, run); | 211 | pushBack_PtrArray(&d->visibleLinks, run); |
206 | } | 212 | } |
207 | } | 213 | } |
@@ -363,9 +369,8 @@ static void fetch_DocumentWidget_(iDocumentWidget *d) { | |||
363 | } | 369 | } |
364 | 370 | ||
365 | void setUrl_DocumentWidget(iDocumentWidget *d, const iString *url) { | 371 | void setUrl_DocumentWidget(iDocumentWidget *d, const iString *url) { |
366 | iString *newUrl = collect_String(cleanUrl_(url)); | 372 | if (cmpStringSc_String(d->url, url, &iCaseInsensitive)) { |
367 | if (cmpStringSc_String(d->url, newUrl, &iCaseInsensitive)) { | 373 | set_String(d->url, url); |
368 | set_String(d->url, newUrl); | ||
369 | fetch_DocumentWidget_(d); | 374 | fetch_DocumentWidget_(d); |
370 | } | 375 | } |
371 | /* See if there a username in the URL. */ { | 376 | /* See if there a username in the URL. */ { |
@@ -861,7 +866,7 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) { | |||
861 | fillRange_DrawContext_(d, run, teal_ColorId, d->widget->foundMark, &d->inFoundMark); | 866 | fillRange_DrawContext_(d, run, teal_ColorId, d->widget->foundMark, &d->inFoundMark); |
862 | fillRange_DrawContext_(d, run, brown_ColorId, d->widget->selectMark, &d->inSelectMark); | 867 | fillRange_DrawContext_(d, run, brown_ColorId, d->widget->selectMark, &d->inSelectMark); |
863 | if (run->linkId && !isEmpty_Rect(run->bounds)) { | 868 | if (run->linkId && !isEmpty_Rect(run->bounds)) { |
864 | const int flags = linkFlags_GmDocument(doc, run->linkId); | 869 | // const int flags = linkFlags_GmDocument(doc, run->linkId); |
865 | fg = /*flags & visited_GmLinkFlag ? gray88_ColorId :*/ white_ColorId; | 870 | fg = /*flags & visited_GmLinkFlag ? gray88_ColorId :*/ white_ColorId; |
866 | if (isHover || linkFlags_GmDocument(doc, run->linkId) & content_GmLinkFlag) { | 871 | if (isHover || linkFlags_GmDocument(doc, run->linkId) & content_GmLinkFlag) { |
867 | fg = linkColor_GmDocument(doc, run->linkId); | 872 | fg = linkColor_GmDocument(doc, run->linkId); |
@@ -913,7 +918,7 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) { | |||
913 | init_Url(&parts, url); | 918 | init_Url(&parts, url); |
914 | const iString *host = collect_String(newRange_String(parts.host)); | 919 | const iString *host = collect_String(newRange_String(parts.host)); |
915 | fg = linkColor_GmDocument(doc, linkId); | 920 | fg = linkColor_GmDocument(doc, linkId); |
916 | const iBool showHost = (!isEmpty_String(host) && flags & userFriendly_GmLinkFlag); | 921 | const iBool showHost = (!isEmpty_String(host) && flags & userFriendly_GmLinkFlag); |
917 | const iBool showImage = (flags & imageFileExtension_GmLinkFlag) != 0; | 922 | const iBool showImage = (flags & imageFileExtension_GmLinkFlag) != 0; |
918 | const iBool showAudio = (flags & audioFileExtension_GmLinkFlag) != 0; | 923 | const iBool showAudio = (flags & audioFileExtension_GmLinkFlag) != 0; |
919 | iString str; | 924 | iString str; |