diff options
-rw-r--r-- | src/gmdocument.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c index 582af833..76b5ef22 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -295,19 +295,20 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
295 | if (d->size.x <= 0 || isEmpty_String(&d->source)) { | 295 | if (d->size.x <= 0 || isEmpty_String(&d->source)) { |
296 | return; | 296 | return; |
297 | } | 297 | } |
298 | const iRangecc content = range_String(&d->source); | 298 | const iRangecc content = range_String(&d->source); |
299 | iInt2 pos = zero_I2(); | 299 | iInt2 pos = zero_I2(); |
300 | iRangecc line = iNullRange; | 300 | iRangecc line = iNullRange; |
301 | iRangecc preAltText = iNullRange; | 301 | iRangecc preAltText = iNullRange; |
302 | enum iGmLineType prevType = text_GmLineType; | 302 | enum iGmLineType prevType; // = text_GmLineType; |
303 | iBool isPreformat = iFalse; | 303 | iBool isPreformat = iFalse; |
304 | iBool isFirstText = iTrue; | 304 | iBool isFirstText = iTrue; |
305 | iBool enableIndents = iFalse; | ||
305 | iBool addSiteBanner = iTrue; | 306 | iBool addSiteBanner = iTrue; |
306 | int preFont = preformatted_FontId; | 307 | int preFont = preformatted_FontId; |
307 | if (d->format == plainText_GmDocumentFormat) { | 308 | if (d->format == plainText_GmDocumentFormat) { |
308 | isPreformat = iTrue; | 309 | isPreformat = iTrue; |
309 | isFirstText = iFalse; | 310 | isFirstText = iFalse; |
310 | } | 311 | } |
311 | while (nextSplit_Rangecc(&content, "\n", &line)) { | 312 | while (nextSplit_Rangecc(&content, "\n", &line)) { |
312 | iGmRun run; | 313 | iGmRun run; |
313 | run.flags = 0; | 314 | run.flags = 0; |
@@ -318,6 +319,9 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
318 | int indent = 0; | 319 | int indent = 0; |
319 | if (!isPreformat) { | 320 | if (!isPreformat) { |
320 | type = lineType_GmDocument_(d, &line); | 321 | type = lineType_GmDocument_(d, &line); |
322 | if (line.start == content.start) { | ||
323 | prevType = type; | ||
324 | } | ||
321 | indent = indents[type]; | 325 | indent = indents[type]; |
322 | if (type == preformatted_GmLineType) { | 326 | if (type == preformatted_GmLineType) { |
323 | isPreformat = iTrue; | 327 | isPreformat = iTrue; |
@@ -376,6 +380,13 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
376 | /* TODO: Extra skip needed here? */ | 380 | /* TODO: Extra skip needed here? */ |
377 | continue; | 381 | continue; |
378 | } | 382 | } |
383 | /* Begin indenting after the first preformatted block. */ | ||
384 | if (type != preformatted_GmLineType || prevType != preformatted_GmLineType) { | ||
385 | enableIndents = iTrue; | ||
386 | } | ||
387 | if (!enableIndents) { | ||
388 | indent = 0; | ||
389 | } | ||
379 | /* Check the margin vs. previous run. */ | 390 | /* Check the margin vs. previous run. */ |
380 | if (!isPreformat || (prevType != preformatted_GmLineType)) { | 391 | if (!isPreformat || (prevType != preformatted_GmLineType)) { |
381 | int required = | 392 | int required = |