diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-24 05:42:44 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-24 05:42:44 +0200 |
commit | ec826e393ad5feba5960662a75b62adafc7b6673 (patch) | |
tree | ff17477e8749519706b3ac1e42cde808c95a1829 /src | |
parent | 925e57fe599931cb41b5a6f8a8ed4085e7a12987 (diff) |
GmDocument: Balance horizontal space
Right margin should match the indented left margin.
Diffstat (limited to 'src')
-rw-r--r-- | src/gmdocument.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c index b6353926..ae9f6d9c 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -295,7 +295,6 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
295 | static const char *quote = "\u201c"; | 295 | static const char *quote = "\u201c"; |
296 | static const char *magnifyingGlass = "\U0001f50d"; | 296 | static const char *magnifyingGlass = "\U0001f50d"; |
297 | static const char *pointingFinger = "\U0001f449"; | 297 | static const char *pointingFinger = "\U0001f449"; |
298 | const float midRunSkip = 0; /*0.120f;*/ /* extra space between wrapped text/quote lines */ | ||
299 | const iPrefs *prefs = prefs_App(); | 298 | const iPrefs *prefs = prefs_App(); |
300 | clear_Array(&d->layout); | 299 | clear_Array(&d->layout); |
301 | clearLinks_GmDocument_(d); | 300 | clearLinks_GmDocument_(d); |
@@ -326,6 +325,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
326 | iGmRun run = { .color = white_ColorId }; | 325 | iGmRun run = { .color = white_ColorId }; |
327 | enum iGmLineType type; | 326 | enum iGmLineType type; |
328 | int indent = 0; | 327 | int indent = 0; |
328 | int rightMargin = 0; | ||
329 | /* Detect the type of the line. */ | 329 | /* Detect the type of the line. */ |
330 | if (!isPreformat) { | 330 | if (!isPreformat) { |
331 | type = lineType_GmDocument_(d, line); | 331 | type = lineType_GmDocument_(d, line); |
@@ -432,8 +432,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
432 | if ((type == link_GmLineType && prevType == link_GmLineType) || | 432 | if ((type == link_GmLineType && prevType == link_GmLineType) || |
433 | (type == quote_GmLineType && prevType == quote_GmLineType)) { | 433 | (type == quote_GmLineType && prevType == quote_GmLineType)) { |
434 | /* No margin between consecutive links/quote lines. */ | 434 | /* No margin between consecutive links/quote lines. */ |
435 | required = | 435 | required = 0; |
436 | (type == link_GmLineType ? midRunSkip * lineHeight_Text(paragraph_FontId) : 0); | ||
437 | } | 436 | } |
438 | if (isEmpty_Array(&d->layout)) { | 437 | if (isEmpty_Array(&d->layout)) { |
439 | required = 0; /* top of document */ | 438 | required = 0; /* top of document */ |
@@ -523,17 +522,13 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
523 | if (!prefs->quoteIcon && type == quote_GmLineType) { | 522 | if (!prefs->quoteIcon && type == quote_GmLineType) { |
524 | run.flags |= quoteBorder_GmRunFlag; | 523 | run.flags |= quoteBorder_GmRunFlag; |
525 | } | 524 | } |
525 | rightMargin = (type == text_GmLineType || type == bullet_GmLineType || | ||
526 | type == link_GmLineType || type == quote_GmLineType ? 5 : 0); | ||
526 | iAssert(!isEmpty_Range(&runLine)); /* must have something at this point */ | 527 | iAssert(!isEmpty_Range(&runLine)); /* must have something at this point */ |
527 | while (!isEmpty_Range(&runLine)) { | 528 | while (!isEmpty_Range(&runLine)) { |
528 | /* Little bit of breathing space between wrapped lines. */ | ||
529 | if ((type == text_GmLineType || type == quote_GmLineType || | ||
530 | type == bullet_GmLineType) && | ||
531 | runLine.start != line.start) { | ||
532 | pos.y += midRunSkip * lineHeight_Text(run.font); | ||
533 | } | ||
534 | run.bounds.pos = addX_I2(pos, indent * gap_Text); | 529 | run.bounds.pos = addX_I2(pos, indent * gap_Text); |
535 | const char *contPos; | 530 | const char *contPos; |
536 | const int avail = isPreformat ? 0 : (d->size.x - run.bounds.pos.x); | 531 | const int avail = isPreformat ? 0 : (d->size.x - run.bounds.pos.x - rightMargin * gap_Text); |
537 | const iInt2 dims = tryAdvance_Text(run.font, runLine, avail, &contPos); | 532 | const iInt2 dims = tryAdvance_Text(run.font, runLine, avail, &contPos); |
538 | iChangeFlags(run.flags, wide_GmRunFlag, (isPreformat && dims.x > d->size.x)); | 533 | iChangeFlags(run.flags, wide_GmRunFlag, (isPreformat && dims.x > d->size.x)); |
539 | run.bounds.size.x = iMax(avail, dims.x); /* Extends to the right edge for selection. */ | 534 | run.bounds.size.x = iMax(avail, dims.x); /* Extends to the right edge for selection. */ |