diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-01-02 14:18:52 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-01-02 14:18:52 +0200 |
commit | 46e17ce859a5507000629484227e3d8e68f6ad1d (patch) | |
tree | 04f7cb7ba462ab11acdf605bd6ff51441ac4cc4f /src | |
parent | b24dde82d9ab52634f088be9546f24de5c5aa861 (diff) | |
parent | fe4302d8cbd04d64cab96d7781285a9cf602d591 (diff) |
Merge branch 'finger' into dev
Diffstat (limited to 'src')
-rw-r--r-- | src/gmdocument.c | 59 | ||||
-rw-r--r-- | src/gmdocument.h | 11 | ||||
-rw-r--r-- | src/gmrequest.c | 9 | ||||
-rw-r--r-- | src/gopher.c | 17 | ||||
-rw-r--r-- | src/ui/documentwidget.c | 1 |
5 files changed, 53 insertions, 44 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c index 1f8ecb75..6f038524 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -183,11 +183,13 @@ static iRangecc addLink_GmDocument_(iGmDocument *d, iRangecc line, iGmLinkId *li | |||
183 | link->flags |= query_GmLinkFlag; | 183 | link->flags |= query_GmLinkFlag; |
184 | } | 184 | } |
185 | } | 185 | } |
186 | else if (equalCase_Rangecc(parts.scheme, "finger")) { | ||
187 | link->flags |= finger_GmLinkFlag; | ||
188 | } | ||
186 | else if (equalCase_Rangecc(parts.scheme, "file")) { | 189 | else if (equalCase_Rangecc(parts.scheme, "file")) { |
187 | link->flags |= file_GmLinkFlag; | 190 | link->flags |= file_GmLinkFlag; |
188 | } | 191 | } |
189 | else if (equalCase_Rangecc(parts.scheme, "data")) { | 192 | else if (equalCase_Rangecc(parts.scheme, "data")) { |
190 | link->flags |= data_GmLinkFlag; | ||
191 | } | 193 | } |
192 | else if (equalCase_Rangecc(parts.scheme, "about")) { | 194 | else if (equalCase_Rangecc(parts.scheme, "about")) { |
193 | link->flags |= about_GmLinkFlag; | 195 | link->flags |= about_GmLinkFlag; |
@@ -245,7 +247,8 @@ static iBool isForcedMonospace_GmDocument_(const iGmDocument *d) { | |||
245 | if (equalCase_Rangecc(scheme, "gemini")) { | 247 | if (equalCase_Rangecc(scheme, "gemini")) { |
246 | return prefs_App()->monospaceGemini; | 248 | return prefs_App()->monospaceGemini; |
247 | } | 249 | } |
248 | if (equalCase_Rangecc(scheme, "gopher")) { | 250 | if (equalCase_Rangecc(scheme, "gopher") || |
251 | equalCase_Rangecc(scheme, "finger")) { | ||
249 | return prefs_App()->monospaceGopher; | 252 | return prefs_App()->monospaceGopher; |
250 | } | 253 | } |
251 | return iFalse; | 254 | return iFalse; |
@@ -290,6 +293,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
290 | static const char *globe = "\U0001f310"; | 293 | static const char *globe = "\U0001f310"; |
291 | static const char *quote = "\u201c"; | 294 | static const char *quote = "\u201c"; |
292 | static const char *magnifyingGlass = "\U0001f50d"; | 295 | static const char *magnifyingGlass = "\U0001f50d"; |
296 | static const char *pointingFinger = "\U0001f449"; | ||
293 | const float midRunSkip = 0; /*0.120f;*/ /* extra space between wrapped text/quote lines */ | 297 | const float midRunSkip = 0; /*0.120f;*/ /* extra space between wrapped text/quote lines */ |
294 | const iPrefs *prefs = prefs_App(); | 298 | const iPrefs *prefs = prefs_App(); |
295 | clear_Array(&d->layout); | 299 | clear_Array(&d->layout); |
@@ -306,7 +310,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
306 | iBool isFirstText = prefs->bigFirstParagraph; | 310 | iBool isFirstText = prefs->bigFirstParagraph; |
307 | iBool addQuoteIcon = prefs->quoteIcon; | 311 | iBool addQuoteIcon = prefs->quoteIcon; |
308 | iBool isPreformat = iFalse; | 312 | iBool isPreformat = iFalse; |
309 | iRangecc preAltText = iNullRange; | 313 | iRangecc preAltText = iNullRange; /* TODO: alt text is being ignored */ |
310 | int preFont = preformatted_FontId; | 314 | int preFont = preformatted_FontId; |
311 | uint16_t preId = 0; | 315 | uint16_t preId = 0; |
312 | iBool enableIndents = iFalse; | 316 | iBool enableIndents = iFalse; |
@@ -473,6 +477,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
473 | const iGmLink *link = constAt_PtrArray(&d->links, run.linkId - 1); | 477 | const iGmLink *link = constAt_PtrArray(&d->links, run.linkId - 1); |
474 | icon.text = range_CStr(link->flags & query_GmLinkFlag ? magnifyingGlass | 478 | icon.text = range_CStr(link->flags & query_GmLinkFlag ? magnifyingGlass |
475 | : link->flags & file_GmLinkFlag ? folder | 479 | : link->flags & file_GmLinkFlag ? folder |
480 | : link->flags & finger_GmLinkFlag ? pointingFinger | ||
476 | : link->flags & mailto_GmLinkFlag ? envelope | 481 | : link->flags & mailto_GmLinkFlag ? envelope |
477 | : link->flags & remote_GmLinkFlag ? globe | 482 | : link->flags & remote_GmLinkFlag ? globe |
478 | : arrow); | 483 | : arrow); |
@@ -1110,7 +1115,7 @@ static void normalize_GmDocument(iGmDocument *d) { | |||
1110 | iRangecc src = range_String(&d->source); | 1115 | iRangecc src = range_String(&d->source); |
1111 | iRangecc line = iNullRange; | 1116 | iRangecc line = iNullRange; |
1112 | iBool isPreformat = iFalse; | 1117 | iBool isPreformat = iFalse; |
1113 | if (d->format == plainText_GmDocumentFormat) { // || isGopher_GmDocument_(d)) { | 1118 | if (d->format == plainText_GmDocumentFormat) { |
1114 | isPreformat = iTrue; /* Cannot be turned off. */ | 1119 | isPreformat = iTrue; /* Cannot be turned off. */ |
1115 | } | 1120 | } |
1116 | const int preTabWidth = 4; /* TODO: user-configurable parameter */ | 1121 | const int preTabWidth = 4; /* TODO: user-configurable parameter */ |
@@ -1363,7 +1368,8 @@ iMediaId linkAudio_GmDocument(const iGmDocument *d, iGmLinkId linkId) { | |||
1363 | 1368 | ||
1364 | enum iColorId linkColor_GmDocument(const iGmDocument *d, iGmLinkId linkId, enum iGmLinkPart part) { | 1369 | enum iColorId linkColor_GmDocument(const iGmDocument *d, iGmLinkId linkId, enum iGmLinkPart part) { |
1365 | const iGmLink *link = link_GmDocument_(d, linkId); | 1370 | const iGmLink *link = link_GmDocument_(d, linkId); |
1366 | const int www_GmLinkFlag = http_GmLinkFlag | mailto_GmLinkFlag; | 1371 | const int www_GmLinkFlag = http_GmLinkFlag | mailto_GmLinkFlag; |
1372 | const int gopherOrFinger_GmLinkFlag = gopher_GmLinkFlag | finger_GmLinkFlag; | ||
1367 | if (link) { | 1373 | if (link) { |
1368 | const iBool isUnsupported = (link->flags & supportedProtocol_GmLinkFlag) == 0; | 1374 | const iBool isUnsupported = (link->flags & supportedProtocol_GmLinkFlag) == 0; |
1369 | if (part == icon_GmLinkPart) { | 1375 | if (part == icon_GmLinkPart) { |
@@ -1371,42 +1377,36 @@ enum iColorId linkColor_GmDocument(const iGmDocument *d, iGmLinkId linkId, enum | |||
1371 | return tmBadLink_ColorId; | 1377 | return tmBadLink_ColorId; |
1372 | } | 1378 | } |
1373 | if (link->flags & visited_GmLinkFlag) { | 1379 | if (link->flags & visited_GmLinkFlag) { |
1374 | return link->flags & www_GmLinkFlag | 1380 | return link->flags & www_GmLinkFlag ? tmHypertextLinkIconVisited_ColorId |
1375 | ? tmHypertextLinkIconVisited_ColorId | 1381 | : link->flags & gopherOrFinger_GmLinkFlag ? tmGopherLinkIconVisited_ColorId |
1376 | : link->flags & gopher_GmLinkFlag ? tmGopherLinkIconVisited_ColorId | 1382 | : tmLinkIconVisited_ColorId; |
1377 | : tmLinkIconVisited_ColorId; | ||
1378 | } | 1383 | } |
1379 | return link->flags & www_GmLinkFlag | 1384 | return link->flags & www_GmLinkFlag ? tmHypertextLinkIcon_ColorId |
1380 | ? tmHypertextLinkIcon_ColorId | 1385 | : link->flags & gopherOrFinger_GmLinkFlag ? tmGopherLinkIcon_ColorId |
1381 | : link->flags & gopher_GmLinkFlag ? tmGopherLinkIcon_ColorId | 1386 | : tmLinkIcon_ColorId; |
1382 | : tmLinkIcon_ColorId; | ||
1383 | } | 1387 | } |
1384 | if (part == text_GmLinkPart) { | 1388 | if (part == text_GmLinkPart) { |
1385 | return link->flags & www_GmLinkFlag | 1389 | return link->flags & www_GmLinkFlag ? tmHypertextLinkText_ColorId |
1386 | ? tmHypertextLinkText_ColorId | 1390 | : link->flags & gopherOrFinger_GmLinkFlag ? tmGopherLinkText_ColorId |
1387 | : link->flags & gopher_GmLinkFlag ? tmGopherLinkText_ColorId | 1391 | : tmLinkText_ColorId; |
1388 | : tmLinkText_ColorId; | ||
1389 | } | 1392 | } |
1390 | if (part == textHover_GmLinkPart) { | 1393 | if (part == textHover_GmLinkPart) { |
1391 | return link->flags & www_GmLinkFlag | 1394 | return link->flags & www_GmLinkFlag ? tmHypertextLinkTextHover_ColorId |
1392 | ? tmHypertextLinkTextHover_ColorId | 1395 | : link->flags & gopherOrFinger_GmLinkFlag ? tmGopherLinkTextHover_ColorId |
1393 | : link->flags & gopher_GmLinkFlag ? tmGopherLinkTextHover_ColorId | 1396 | : tmLinkTextHover_ColorId; |
1394 | : tmLinkTextHover_ColorId; | ||
1395 | } | 1397 | } |
1396 | if (part == domain_GmLinkPart) { | 1398 | if (part == domain_GmLinkPart) { |
1397 | if (isUnsupported) { | 1399 | if (isUnsupported) { |
1398 | return tmBadLink_ColorId; | 1400 | return tmBadLink_ColorId; |
1399 | } | 1401 | } |
1400 | return link->flags & www_GmLinkFlag | 1402 | return link->flags & www_GmLinkFlag ? tmHypertextLinkDomain_ColorId |
1401 | ? tmHypertextLinkDomain_ColorId | 1403 | : link->flags & gopherOrFinger_GmLinkFlag ? tmGopherLinkDomain_ColorId |
1402 | : link->flags & gopher_GmLinkFlag ? tmGopherLinkDomain_ColorId | 1404 | : tmLinkDomain_ColorId; |
1403 | : tmLinkDomain_ColorId; | ||
1404 | } | 1405 | } |
1405 | if (part == visited_GmLinkPart) { | 1406 | if (part == visited_GmLinkPart) { |
1406 | return link->flags & www_GmLinkFlag | 1407 | return link->flags & www_GmLinkFlag ? tmHypertextLinkLastVisitDate_ColorId |
1407 | ? tmHypertextLinkLastVisitDate_ColorId | 1408 | : link->flags & gopherOrFinger_GmLinkFlag ? tmGopherLinkLastVisitDate_ColorId |
1408 | : link->flags & gopher_GmLinkFlag ? tmGopherLinkLastVisitDate_ColorId | 1409 | : tmLinkLastVisitDate_ColorId; |
1409 | : tmLinkLastVisitDate_ColorId; | ||
1410 | } | 1410 | } |
1411 | } | 1411 | } |
1412 | return tmLinkText_ColorId; | 1412 | return tmLinkText_ColorId; |
@@ -1416,6 +1416,7 @@ iBool isMediaLink_GmDocument(const iGmDocument *d, iGmLinkId linkId) { | |||
1416 | const iString *dstUrl = absoluteUrl_String(&d->url, linkUrl_GmDocument(d, linkId)); | 1416 | const iString *dstUrl = absoluteUrl_String(&d->url, linkUrl_GmDocument(d, linkId)); |
1417 | const iRangecc scheme = urlScheme_String(dstUrl); | 1417 | const iRangecc scheme = urlScheme_String(dstUrl); |
1418 | if (equalCase_Rangecc(scheme, "gemini") || equalCase_Rangecc(scheme, "gopher") || | 1418 | if (equalCase_Rangecc(scheme, "gemini") || equalCase_Rangecc(scheme, "gopher") || |
1419 | equalCase_Rangecc(scheme, "finger") || | ||
1419 | equalCase_Rangecc(scheme, "file") || willUseProxy_App(scheme)) { | 1420 | equalCase_Rangecc(scheme, "file") || willUseProxy_App(scheme)) { |
1420 | return (linkFlags_GmDocument(d, linkId) & | 1421 | return (linkFlags_GmDocument(d, linkId) & |
1421 | (imageFileExtension_GmLinkFlag | audioFileExtension_GmLinkFlag)) != 0; | 1422 | (imageFileExtension_GmLinkFlag | audioFileExtension_GmLinkFlag)) != 0; |
diff --git a/src/gmdocument.h b/src/gmdocument.h index b1121d85..e2c7e10c 100644 --- a/src/gmdocument.h +++ b/src/gmdocument.h | |||
@@ -54,11 +54,12 @@ typedef uint16_t iGmLinkId; | |||
54 | enum iGmLinkFlags { | 54 | enum iGmLinkFlags { |
55 | gemini_GmLinkFlag = iBit(1), | 55 | gemini_GmLinkFlag = iBit(1), |
56 | gopher_GmLinkFlag = iBit(2), | 56 | gopher_GmLinkFlag = iBit(2), |
57 | http_GmLinkFlag = iBit(3), | 57 | finger_GmLinkFlag = iBit(3), |
58 | file_GmLinkFlag = iBit(4), | 58 | http_GmLinkFlag = iBit(4), |
59 | data_GmLinkFlag = iBit(5), | 59 | file_GmLinkFlag = iBit(5), |
60 | about_GmLinkFlag = iBit(6), | 60 | data_GmLinkFlag = iBit(6), |
61 | mailto_GmLinkFlag = iBit(7), | 61 | about_GmLinkFlag = iBit(7), |
62 | mailto_GmLinkFlag = iBit(8), | ||
62 | supportedProtocol_GmLinkFlag = 0xff, | 63 | supportedProtocol_GmLinkFlag = 0xff, |
63 | remote_GmLinkFlag = iBit(9), | 64 | remote_GmLinkFlag = iBit(9), |
64 | humanReadable_GmLinkFlag = iBit(10), /* link has a human-readable description */ | 65 | humanReadable_GmLinkFlag = iBit(10), /* link has a human-readable description */ |
diff --git a/src/gmrequest.c b/src/gmrequest.c index 5b005fbb..a1cf1a8e 100644 --- a/src/gmrequest.c +++ b/src/gmrequest.c | |||
@@ -434,9 +434,6 @@ static void gopherError_GmRequest_(iGmRequest *d, iSocket *socket, int error, co | |||
434 | } | 434 | } |
435 | 435 | ||
436 | static void beginGopherConnection_GmRequest_(iGmRequest *d, const iString *host, uint16_t port) { | 436 | static void beginGopherConnection_GmRequest_(iGmRequest *d, const iString *host, uint16_t port) { |
437 | if (port == 0) { | ||
438 | port = 70; /* default port */ | ||
439 | } | ||
440 | clear_Block(&d->gopher.source); | 437 | clear_Block(&d->gopher.source); |
441 | iGmResponse *resp = d->resp; | 438 | iGmResponse *resp = d->resp; |
442 | d->gopher.meta = &resp->meta; | 439 | d->gopher.meta = &resp->meta; |
@@ -642,7 +639,11 @@ void submit_GmRequest(iGmRequest *d) { | |||
642 | } | 639 | } |
643 | } | 640 | } |
644 | else if (equalCase_Rangecc(url.scheme, "gopher")) { | 641 | else if (equalCase_Rangecc(url.scheme, "gopher")) { |
645 | beginGopherConnection_GmRequest_(d, host, port); | 642 | beginGopherConnection_GmRequest_(d, host, port ? port : 70); |
643 | return; | ||
644 | } | ||
645 | else if (equalCase_Rangecc(url.scheme, "finger")) { | ||
646 | beginGopherConnection_GmRequest_(d, host, port ? port : 79); | ||
646 | return; | 647 | return; |
647 | } | 648 | } |
648 | else if (!equalCase_Rangecc(url.scheme, "gemini")) { | 649 | else if (!equalCase_Rangecc(url.scheme, "gemini")) { |
diff --git a/src/gopher.c b/src/gopher.c index dfdcf672..229ff9f4 100644 --- a/src/gopher.c +++ b/src/gopher.c | |||
@@ -149,16 +149,21 @@ void deinit_Gopher(iGopher *d) { | |||
149 | void open_Gopher(iGopher *d, const iString *url) { | 149 | void open_Gopher(iGopher *d, const iString *url) { |
150 | iUrl parts; | 150 | iUrl parts; |
151 | init_Url(&parts, url); | 151 | init_Url(&parts, url); |
152 | /* Determine Gopher item type. */ | ||
153 | d->type = '1'; | ||
154 | if (!isEmpty_Range(&parts.path)) { | 152 | if (!isEmpty_Range(&parts.path)) { |
155 | if (*parts.path.start == '/') { | 153 | if (*parts.path.start == '/') { |
156 | parts.path.start++; | 154 | parts.path.start++; |
157 | } | 155 | } |
158 | if (parts.path.start < parts.path.end) { | 156 | } |
159 | d->type = *parts.path.start; | 157 | /* Determine Gopher item type (finger is type 0). */ |
160 | parts.path.start++; | 158 | if (equalCase_Rangecc(parts.scheme, "finger")) { |
161 | } | 159 | d->type = '0'; |
160 | } | ||
161 | else if (parts.path.start < parts.path.end) { | ||
162 | d->type = *parts.path.start; | ||
163 | parts.path.start++; | ||
164 | } | ||
165 | else { | ||
166 | d->type = '1'; | ||
162 | } | 167 | } |
163 | if (d->type == '7' && isEmpty_Range(&parts.query)) { | 168 | if (d->type == '7' && isEmpty_Range(&parts.query)) { |
164 | /* Ask for the query parameters first. */ | 169 | /* Ask for the query parameters first. */ |
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 0723ed9d..0a8197b5 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -2293,6 +2293,7 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e | |||
2293 | const iRangecc scheme = urlScheme_String(linkUrl); | 2293 | const iRangecc scheme = urlScheme_String(linkUrl); |
2294 | const iBool isGemini = equalCase_Rangecc(scheme, "gemini"); | 2294 | const iBool isGemini = equalCase_Rangecc(scheme, "gemini"); |
2295 | if (willUseProxy_App(scheme) || isGemini || | 2295 | if (willUseProxy_App(scheme) || isGemini || |
2296 | equalCase_Rangecc(scheme, "finger") || | ||
2296 | equalCase_Rangecc(scheme, "gopher")) { | 2297 | equalCase_Rangecc(scheme, "gopher")) { |
2297 | /* Regular links that we can open. */ | 2298 | /* Regular links that we can open. */ |
2298 | pushBackN_Array( | 2299 | pushBackN_Array( |