summaryrefslogtreecommitdiff
path: root/src/gmdocument.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-01-02 14:18:41 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-01-02 14:18:41 +0200
commitfe4302d8cbd04d64cab96d7781285a9cf602d591 (patch)
treecb1ba90fe45b7cc926e2376b69fff07621f9435f /src/gmdocument.c
parent51d823832538d495f382299ec668e7afa1cc12f8 (diff)
GmDocument: New link icon for Finger links
Added a new link flag to identify Finger links so they can use their own icon.
Diffstat (limited to 'src/gmdocument.c')
-rw-r--r--src/gmdocument.c59
1 files changed, 29 insertions, 30 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c
index 8d2e3f1f..6f038524 100644
--- a/src/gmdocument.c
+++ b/src/gmdocument.c
@@ -177,13 +177,15 @@ static iRangecc addLink_GmDocument_(iGmDocument *d, iRangecc line, iGmLinkId *li
177 else if (startsWithCase_Rangecc(parts.scheme, "http")) { 177 else if (startsWithCase_Rangecc(parts.scheme, "http")) {
178 link->flags |= http_GmLinkFlag; 178 link->flags |= http_GmLinkFlag;
179 } 179 }
180 else if (equalCase_Rangecc(parts.scheme, "gopher") || 180 else if (equalCase_Rangecc(parts.scheme, "gopher")) {
181 equalCase_Rangecc(parts.scheme, "finger")) { 181 link->flags |= gopher_GmLinkFlag;
182 link->flags |= gopher_finger_GmLinkFlag;
183 if (startsWith_Rangecc(parts.path, "/7")) { 182 if (startsWith_Rangecc(parts.path, "/7")) {
184 link->flags |= query_GmLinkFlag; 183 link->flags |= query_GmLinkFlag;
185 } 184 }
186 } 185 }
186 else if (equalCase_Rangecc(parts.scheme, "finger")) {
187 link->flags |= finger_GmLinkFlag;
188 }
187 else if (equalCase_Rangecc(parts.scheme, "file")) { 189 else if (equalCase_Rangecc(parts.scheme, "file")) {
188 link->flags |= file_GmLinkFlag; 190 link->flags |= file_GmLinkFlag;
189 } 191 }
@@ -291,6 +293,7 @@ static void doLayout_GmDocument_(iGmDocument *d) {
291 static const char *globe = "\U0001f310"; 293 static const char *globe = "\U0001f310";
292 static const char *quote = "\u201c"; 294 static const char *quote = "\u201c";
293 static const char *magnifyingGlass = "\U0001f50d"; 295 static const char *magnifyingGlass = "\U0001f50d";
296 static const char *pointingFinger = "\U0001f449";
294 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 */
295 const iPrefs *prefs = prefs_App(); 298 const iPrefs *prefs = prefs_App();
296 clear_Array(&d->layout); 299 clear_Array(&d->layout);
@@ -307,7 +310,7 @@ static void doLayout_GmDocument_(iGmDocument *d) {
307 iBool isFirstText = prefs->bigFirstParagraph; 310 iBool isFirstText = prefs->bigFirstParagraph;
308 iBool addQuoteIcon = prefs->quoteIcon; 311 iBool addQuoteIcon = prefs->quoteIcon;
309 iBool isPreformat = iFalse; 312 iBool isPreformat = iFalse;
310 iRangecc preAltText = iNullRange; 313 iRangecc preAltText = iNullRange; /* TODO: alt text is being ignored */
311 int preFont = preformatted_FontId; 314 int preFont = preformatted_FontId;
312 uint16_t preId = 0; 315 uint16_t preId = 0;
313 iBool enableIndents = iFalse; 316 iBool enableIndents = iFalse;
@@ -474,6 +477,7 @@ static void doLayout_GmDocument_(iGmDocument *d) {
474 const iGmLink *link = constAt_PtrArray(&d->links, run.linkId - 1); 477 const iGmLink *link = constAt_PtrArray(&d->links, run.linkId - 1);
475 icon.text = range_CStr(link->flags & query_GmLinkFlag ? magnifyingGlass 478 icon.text = range_CStr(link->flags & query_GmLinkFlag ? magnifyingGlass
476 : link->flags & file_GmLinkFlag ? folder 479 : link->flags & file_GmLinkFlag ? folder
480 : link->flags & finger_GmLinkFlag ? pointingFinger
477 : link->flags & mailto_GmLinkFlag ? envelope 481 : link->flags & mailto_GmLinkFlag ? envelope
478 : link->flags & remote_GmLinkFlag ? globe 482 : link->flags & remote_GmLinkFlag ? globe
479 : arrow); 483 : arrow);
@@ -1111,7 +1115,7 @@ static void normalize_GmDocument(iGmDocument *d) {
1111 iRangecc src = range_String(&d->source); 1115 iRangecc src = range_String(&d->source);
1112 iRangecc line = iNullRange; 1116 iRangecc line = iNullRange;
1113 iBool isPreformat = iFalse; 1117 iBool isPreformat = iFalse;
1114 if (d->format == plainText_GmDocumentFormat) { // || isGopher_GmDocument_(d)) { 1118 if (d->format == plainText_GmDocumentFormat) {
1115 isPreformat = iTrue; /* Cannot be turned off. */ 1119 isPreformat = iTrue; /* Cannot be turned off. */
1116 } 1120 }
1117 const int preTabWidth = 4; /* TODO: user-configurable parameter */ 1121 const int preTabWidth = 4; /* TODO: user-configurable parameter */
@@ -1364,7 +1368,8 @@ iMediaId linkAudio_GmDocument(const iGmDocument *d, iGmLinkId linkId) {
1364 1368
1365enum iColorId linkColor_GmDocument(const iGmDocument *d, iGmLinkId linkId, enum iGmLinkPart part) { 1369enum iColorId linkColor_GmDocument(const iGmDocument *d, iGmLinkId linkId, enum iGmLinkPart part) {
1366 const iGmLink *link = link_GmDocument_(d, linkId); 1370 const iGmLink *link = link_GmDocument_(d, linkId);
1367 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;
1368 if (link) { 1373 if (link) {
1369 const iBool isUnsupported = (link->flags & supportedProtocol_GmLinkFlag) == 0; 1374 const iBool isUnsupported = (link->flags & supportedProtocol_GmLinkFlag) == 0;
1370 if (part == icon_GmLinkPart) { 1375 if (part == icon_GmLinkPart) {
@@ -1372,42 +1377,36 @@ enum iColorId linkColor_GmDocument(const iGmDocument *d, iGmLinkId linkId, enum
1372 return tmBadLink_ColorId; 1377 return tmBadLink_ColorId;
1373 } 1378 }
1374 if (link->flags & visited_GmLinkFlag) { 1379 if (link->flags & visited_GmLinkFlag) {
1375 return link->flags & www_GmLinkFlag 1380 return link->flags & www_GmLinkFlag ? tmHypertextLinkIconVisited_ColorId
1376 ? tmHypertextLinkIconVisited_ColorId 1381 : link->flags & gopherOrFinger_GmLinkFlag ? tmGopherLinkIconVisited_ColorId
1377 : link->flags & gopher_finger_GmLinkFlag ? tmGopherLinkIconVisited_ColorId 1382 : tmLinkIconVisited_ColorId;
1378 : tmLinkIconVisited_ColorId;
1379 } 1383 }
1380 return link->flags & www_GmLinkFlag 1384 return link->flags & www_GmLinkFlag ? tmHypertextLinkIcon_ColorId
1381 ? tmHypertextLinkIcon_ColorId 1385 : link->flags & gopherOrFinger_GmLinkFlag ? tmGopherLinkIcon_ColorId
1382 : link->flags & gopher_finger_GmLinkFlag ? tmGopherLinkIcon_ColorId 1386 : tmLinkIcon_ColorId;
1383 : tmLinkIcon_ColorId;
1384 } 1387 }
1385 if (part == text_GmLinkPart) { 1388 if (part == text_GmLinkPart) {
1386 return link->flags & www_GmLinkFlag 1389 return link->flags & www_GmLinkFlag ? tmHypertextLinkText_ColorId
1387 ? tmHypertextLinkText_ColorId 1390 : link->flags & gopherOrFinger_GmLinkFlag ? tmGopherLinkText_ColorId
1388 : link->flags & gopher_finger_GmLinkFlag ? tmGopherLinkText_ColorId 1391 : tmLinkText_ColorId;
1389 : tmLinkText_ColorId;
1390 } 1392 }
1391 if (part == textHover_GmLinkPart) { 1393 if (part == textHover_GmLinkPart) {
1392 return link->flags & www_GmLinkFlag 1394 return link->flags & www_GmLinkFlag ? tmHypertextLinkTextHover_ColorId
1393 ? tmHypertextLinkTextHover_ColorId 1395 : link->flags & gopherOrFinger_GmLinkFlag ? tmGopherLinkTextHover_ColorId
1394 : link->flags & gopher_finger_GmLinkFlag ? tmGopherLinkTextHover_ColorId 1396 : tmLinkTextHover_ColorId;
1395 : tmLinkTextHover_ColorId;
1396 } 1397 }
1397 if (part == domain_GmLinkPart) { 1398 if (part == domain_GmLinkPart) {
1398 if (isUnsupported) { 1399 if (isUnsupported) {
1399 return tmBadLink_ColorId; 1400 return tmBadLink_ColorId;
1400 } 1401 }
1401 return link->flags & www_GmLinkFlag 1402 return link->flags & www_GmLinkFlag ? tmHypertextLinkDomain_ColorId
1402 ? tmHypertextLinkDomain_ColorId 1403 : link->flags & gopherOrFinger_GmLinkFlag ? tmGopherLinkDomain_ColorId
1403 : link->flags & gopher_finger_GmLinkFlag ? tmGopherLinkDomain_ColorId 1404 : tmLinkDomain_ColorId;
1404 : tmLinkDomain_ColorId;
1405 } 1405 }
1406 if (part == visited_GmLinkPart) { 1406 if (part == visited_GmLinkPart) {
1407 return link->flags & www_GmLinkFlag 1407 return link->flags & www_GmLinkFlag ? tmHypertextLinkLastVisitDate_ColorId
1408 ? tmHypertextLinkLastVisitDate_ColorId 1408 : link->flags & gopherOrFinger_GmLinkFlag ? tmGopherLinkLastVisitDate_ColorId
1409 : link->flags & gopher_finger_GmLinkFlag ? tmGopherLinkLastVisitDate_ColorId 1409 : tmLinkLastVisitDate_ColorId;
1410 : tmLinkLastVisitDate_ColorId;
1411 } 1410 }
1412 } 1411 }
1413 return tmLinkText_ColorId; 1412 return tmLinkText_ColorId;