summaryrefslogtreecommitdiff
path: root/src/gmdocument.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-09-01 15:37:09 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-09-01 15:37:09 +0300
commitb4a8cc763081d128788e3b9c393cc34bc206bd22 (patch)
tree8362d303544bfd1b5aed8890467bff0ab8dd77a7 /src/gmdocument.c
parenteef068155763e335ed1000901b0b7c321a8aabe1 (diff)
GmDocument: Better formatting for Gopher URLs
Diffstat (limited to 'src/gmdocument.c')
-rw-r--r--src/gmdocument.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c
index d61e199a..fc49dac4 100644
--- a/src/gmdocument.c
+++ b/src/gmdocument.c
@@ -279,16 +279,21 @@ static size_t findLinkImage_GmDocument_(const iGmDocument *d, iGmLinkId linkId)
279 return iInvalidPos; 279 return iInvalidPos;
280} 280}
281 281
282static iBool isGopher_GmDocument_(const iGmDocument *d) {
283 return equalCase_Rangecc(urlScheme_String(&d->url), "gopher");
284}
285
282static void doLayout_GmDocument_(iGmDocument *d) { 286static void doLayout_GmDocument_(iGmDocument *d) {
287 const iBool isGemini = !isGopher_GmDocument_(d);
283 /* TODO: Collect these parameters into a GmTheme. */ 288 /* TODO: Collect these parameters into a GmTheme. */
284 static const int fonts[max_GmLineType] = { 289 const int fonts[max_GmLineType] = {
285 paragraph_FontId, 290 isGemini ? paragraph_FontId : preformatted_FontId,
286 paragraph_FontId, /* bullet */ 291 isGemini ? paragraph_FontId : preformatted_FontId, /* bullet */
287 preformatted_FontId, 292 preformatted_FontId,
288 quote_FontId, 293 quote_FontId,
289 heading1_FontId, 294 isGemini ? heading1_FontId : preformatted_FontId,
290 heading2_FontId, 295 isGemini ? heading2_FontId : preformatted_FontId,
291 heading3_FontId, 296 isGemini ? heading3_FontId : preformatted_FontId,
292 regular_FontId, 297 regular_FontId,
293 }; 298 };
294 static const int colors[max_GmLineType] = { 299 static const int colors[max_GmLineType] = {
@@ -325,7 +330,7 @@ static void doLayout_GmDocument_(iGmDocument *d) {
325 const iRangecc content = range_String(&d->source); 330 const iRangecc content = range_String(&d->source);
326 iRangecc contentLine = iNullRange; 331 iRangecc contentLine = iNullRange;
327 iInt2 pos = zero_I2(); 332 iInt2 pos = zero_I2();
328 iBool isFirstText = iTrue; 333 iBool isFirstText = isGemini;
329 iBool isPreformat = iFalse; 334 iBool isPreformat = iFalse;
330 iRangecc preAltText = iNullRange; 335 iRangecc preAltText = iNullRange;
331 int preFont = preformatted_FontId; 336 int preFont = preformatted_FontId;
@@ -849,7 +854,7 @@ static void normalize_GmDocument(iGmDocument *d) {
849 iRangecc src = range_String(&d->source); 854 iRangecc src = range_String(&d->source);
850 iRangecc line = iNullRange; 855 iRangecc line = iNullRange;
851 iBool isPreformat = iFalse; 856 iBool isPreformat = iFalse;
852 if (d->format == plainText_GmDocumentFormat) { 857 if (d->format == plainText_GmDocumentFormat || isGopher_GmDocument_(d)) {
853 isPreformat = iTrue; /* Cannot be turned off. */ 858 isPreformat = iTrue; /* Cannot be turned off. */
854 } 859 }
855 const int preTabWidth = 4; /* TODO: user-configurable parameter */ 860 const int preTabWidth = 4; /* TODO: user-configurable parameter */