diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-18 14:06:42 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-18 14:06:42 +0300 |
commit | 442e5fcdefb71058dbed8fa8d85121020d87aeef (patch) | |
tree | 6058b1ce8a782d2c699a126080ad8f602ab5496c /src/gmdocument.c | |
parent | d85be5627478949876a5bb10d9d4152ac75a07b9 (diff) |
GmDocument: Added an icon for quote blocks
Diffstat (limited to 'src/gmdocument.c')
-rw-r--r-- | src/gmdocument.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c index f8d5c7cf..4d4ba603 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -329,6 +329,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
329 | static const char *bullet = "\u2022"; | 329 | static const char *bullet = "\u2022"; |
330 | static const char *folder = "\U0001f4c1"; | 330 | static const char *folder = "\U0001f4c1"; |
331 | static const char *globe = "\U0001f310"; | 331 | static const char *globe = "\U0001f310"; |
332 | static const char *quote = "\u201c"; | ||
332 | const float midRunSkip = 0; /*0.120f;*/ /* extra space between wrapped text/quote lines */ | 333 | const float midRunSkip = 0; /*0.120f;*/ /* extra space between wrapped text/quote lines */ |
333 | clear_Array(&d->layout); | 334 | clear_Array(&d->layout); |
334 | clearLinks_GmDocument_(d); | 335 | clearLinks_GmDocument_(d); |
@@ -341,6 +342,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
341 | iRangecc contentLine = iNullRange; | 342 | iRangecc contentLine = iNullRange; |
342 | iInt2 pos = zero_I2(); | 343 | iInt2 pos = zero_I2(); |
343 | iBool isFirstText = isGemini; | 344 | iBool isFirstText = isGemini; |
345 | iBool addQuoteIcon = iTrue; | ||
344 | iBool isPreformat = iFalse; | 346 | iBool isPreformat = iFalse; |
345 | iRangecc preAltText = iNullRange; | 347 | iRangecc preAltText = iNullRange; |
346 | int preFont = preformatted_FontId; | 348 | int preFont = preformatted_FontId; |
@@ -471,10 +473,30 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
471 | bulRun.visBounds.size = advance_Text(run.font, bullet); | 473 | bulRun.visBounds.size = advance_Text(run.font, bullet); |
472 | bulRun.visBounds.pos.x -= 4 * gap_Text - width_Rect(bulRun.visBounds) / 2; | 474 | bulRun.visBounds.pos.x -= 4 * gap_Text - width_Rect(bulRun.visBounds) / 2; |
473 | bulRun.bounds = zero_Rect(); /* just visual */ | 475 | bulRun.bounds = zero_Rect(); /* just visual */ |
474 | bulRun.text = range_CStr(bullet); | 476 | bulRun.text = range_CStr(bullet); |
475 | bulRun.flags |= decoration_GmRunFlag; | 477 | bulRun.flags |= decoration_GmRunFlag; |
476 | pushBack_Array(&d->layout, &bulRun); | 478 | pushBack_Array(&d->layout, &bulRun); |
477 | } | 479 | } |
480 | /* Quote icon. */ | ||
481 | if (type == quote_GmLineType && addQuoteIcon) { | ||
482 | addQuoteIcon = iFalse; | ||
483 | iGmRun quoteRun = run; | ||
484 | quoteRun.font = heading1_FontId; | ||
485 | quoteRun.text = range_CStr(quote); | ||
486 | quoteRun.color = tmQuoteIcon_ColorId; | ||
487 | iRect vis = visualBounds_Text(quoteRun.font, quoteRun.text); | ||
488 | quoteRun.visBounds.size = advance_Text(quoteRun.font, quote); | ||
489 | quoteRun.visBounds.pos = | ||
490 | add_I2(pos, | ||
491 | init_I2(indents[text_GmLineType] * gap_Text, | ||
492 | lineHeight_Text(quote_FontId) / 2 - bottom_Rect(vis))); | ||
493 | quoteRun.bounds = zero_Rect(); /* just visual */ | ||
494 | quoteRun.flags |= decoration_GmRunFlag; | ||
495 | pushBack_Array(&d->layout, "eRun); | ||
496 | } | ||
497 | else if (type != quote_GmLineType) { | ||
498 | addQuoteIcon = iTrue; | ||
499 | } | ||
478 | /* Link icon. */ | 500 | /* Link icon. */ |
479 | if (type == link_GmLineType) { | 501 | if (type == link_GmLineType) { |
480 | iGmRun icon = run; | 502 | iGmRun icon = run; |
@@ -875,6 +897,8 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { | |||
875 | setHsl_Color(i, color); | 897 | setHsl_Color(i, color); |
876 | } | 898 | } |
877 | } | 899 | } |
900 | set_Color(tmQuoteIcon_ColorId, | ||
901 | mix_Color(get_Color(tmQuote_ColorId), get_Color(tmBackground_ColorId), 0.55f)); | ||
878 | /* Special exceptions. */ | 902 | /* Special exceptions. */ |
879 | if (seed) { | 903 | if (seed) { |
880 | if (equal_CStr(cstr_Block(seed), "gemini.circumlunar.space")) { | 904 | if (equal_CStr(cstr_Block(seed), "gemini.circumlunar.space")) { |
@@ -987,7 +1011,7 @@ void setImage_GmDocument(iGmDocument *d, iGmLinkId linkId, const iString *mime, | |||
987 | } | 1011 | } |
988 | else { | 1012 | else { |
989 | delete_GmImage(img); | 1013 | delete_GmImage(img); |
990 | } | 1014 | } |
991 | } | 1015 | } |
992 | } | 1016 | } |
993 | doLayout_GmDocument_(d); | 1017 | doLayout_GmDocument_(d); |