diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-07-15 15:13:16 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-07-15 15:13:16 +0300 |
commit | 9f7bbeecba762213c7dec4555e0cbb1da2b2ea66 (patch) | |
tree | ee25294aac08e2921b3e5514d2d81af08e0df006 /src | |
parent | 353848947c4de934f0b932d4d3fe97b61f3a1d4a (diff) |
RTL line quote and link hover info
Diffstat (limited to 'src')
-rw-r--r-- | src/gmdocument.c | 10 | ||||
-rw-r--r-- | src/ui/documentwidget.c | 18 |
2 files changed, 21 insertions, 7 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c index 5034373d..b403773a 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -820,7 +820,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
820 | if (!prefs->quoteIcon && type == quote_GmLineType) { | 820 | if (!prefs->quoteIcon && type == quote_GmLineType) { |
821 | rts.run.flags |= quoteBorder_GmRunFlag; | 821 | rts.run.flags |= quoteBorder_GmRunFlag; |
822 | } | 822 | } |
823 | for (;;) { /* may need to retry */ | 823 | for (;;) { /* need to retry if the font needs changing */ |
824 | rts.run.flags |= startOfLine_GmRunFlag; | 824 | rts.run.flags |= startOfLine_GmRunFlag; |
825 | iWrapText wrapText = { .text = line, | 825 | iWrapText wrapText = { .text = line, |
826 | .maxWidth = rts.isWordWrapped | 826 | .maxWidth = rts.isWordWrapped |
@@ -841,12 +841,14 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
841 | prun->visBounds.pos.x += offset; | 841 | prun->visBounds.pos.x += offset; |
842 | } | 842 | } |
843 | if (type == bullet_GmLineType || type == link_GmLineType || | 843 | if (type == bullet_GmLineType || type == link_GmLineType || |
844 | type == quote_GmLineType) { | 844 | (type == quote_GmLineType && prefs->quoteIcon)) { |
845 | iGmRun *decor = back_Array(&d->layout); | 845 | iGmRun *decor = back_Array(&d->layout); |
846 | iAssert(decor->flags & decoration_GmRunFlag); | 846 | iAssert(decor->flags & decoration_GmRunFlag); |
847 | decor->visBounds.pos.x = d->size.x - width_Rect(decor->visBounds) - | 847 | decor->visBounds.pos.x = d->size.x - width_Rect(decor->visBounds) - |
848 | decor->visBounds.pos.x + gap_Text * | 848 | decor->visBounds.pos.x + |
849 | (type == bullet_GmLineType ? 1.5f : 1); | 849 | gap_Text * (type == bullet_GmLineType ? 1.5f |
850 | : type == quote_GmLineType ? 0.0f | ||
851 | : 1.0f); | ||
850 | } | 852 | } |
851 | } | 853 | } |
852 | commit_RunTypesetter_(&rts, d); | 854 | commit_RunTypesetter_(&rts, d); |
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index ea4909eb..7e6c2ea4 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -4193,7 +4193,10 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) { | |||
4193 | } | 4193 | } |
4194 | if (run->flags & quoteBorder_GmRunFlag) { | 4194 | if (run->flags & quoteBorder_GmRunFlag) { |
4195 | drawVLine_Paint(&d->paint, | 4195 | drawVLine_Paint(&d->paint, |
4196 | addX_I2(visPos, -gap_Text * 5 / 2), | 4196 | addX_I2(visPos, |
4197 | !run->textParams.isRTL | ||
4198 | ? -gap_Text * 5 / 2 | ||
4199 | : (width_Rect(run->visBounds) + gap_Text * 5 / 2)), | ||
4197 | height_Rect(run->visBounds), | 4200 | height_Rect(run->visBounds), |
4198 | tmQuoteIcon_ColorId); | 4201 | tmQuoteIcon_ColorId); |
4199 | } | 4202 | } |
@@ -4286,8 +4289,8 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) { | |||
4286 | showHost)) { | 4289 | showHost)) { |
4287 | format_String( | 4290 | format_String( |
4288 | &str, | 4291 | &str, |
4289 | " \u2014%s%s%s%s%s", | 4292 | "%s%s%s%s%s", |
4290 | showHost ? " " : "", | 4293 | showHost ? "" : "", |
4291 | showHost | 4294 | showHost |
4292 | ? (flags & mailto_GmLinkFlag ? cstr_String(url) | 4295 | ? (flags & mailto_GmLinkFlag ? cstr_String(url) |
4293 | : ~flags & gemini_GmLinkFlag ? format_CStr("%s://%s", | 4296 | : ~flags & gemini_GmLinkFlag ? format_CStr("%s://%s", |
@@ -4313,9 +4316,18 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) { | |||
4313 | append_String(&str, collect_String(format_Date(&date, "%b %d"))); | 4316 | append_String(&str, collect_String(format_Date(&date, "%b %d"))); |
4314 | } | 4317 | } |
4315 | if (!isEmpty_String(&str)) { | 4318 | if (!isEmpty_String(&str)) { |
4319 | if (run->textParams.isRTL) { | ||
4320 | appendCStr_String(&str, " \u2014 "); | ||
4321 | } | ||
4322 | else { | ||
4323 | prependCStr_String(&str, " \u2014 "); | ||
4324 | } | ||
4316 | const iInt2 textSize = measure_Text(metaFont, cstr_String(&str)).bounds.size; | 4325 | const iInt2 textSize = measure_Text(metaFont, cstr_String(&str)).bounds.size; |
4317 | int tx = topRight_Rect(linkRect).x; | 4326 | int tx = topRight_Rect(linkRect).x; |
4318 | const char *msg = cstr_String(&str); | 4327 | const char *msg = cstr_String(&str); |
4328 | if (run->textParams.isRTL) { | ||
4329 | tx = topLeft_Rect(linkRect).x - textSize.x; | ||
4330 | } | ||
4319 | if (tx + textSize.x > right_Rect(d->widgetBounds)) { | 4331 | if (tx + textSize.x > right_Rect(d->widgetBounds)) { |
4320 | tx = right_Rect(d->widgetBounds) - textSize.x; | 4332 | tx = right_Rect(d->widgetBounds) - textSize.x; |
4321 | fillRect_Paint(&d->paint, (iRect){ init_I2(tx, top_Rect(linkRect)), textSize }, | 4333 | fillRect_Paint(&d->paint, (iRect){ init_I2(tx, top_Rect(linkRect)), textSize }, |