diff options
Diffstat (limited to 'src/ui/text.c')
-rw-r--r-- | src/ui/text.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/ui/text.c b/src/ui/text.c index b610d3b8..200108ed 100644 --- a/src/ui/text.c +++ b/src/ui/text.c | |||
@@ -390,8 +390,12 @@ static void deinitCache_Text_(iText *d) { | |||
390 | SDL_DestroyTexture(d->cache); | 390 | SDL_DestroyTexture(d->cache); |
391 | } | 391 | } |
392 | 392 | ||
393 | iRegExp *makeAnsiEscapePattern_Text(void) { | 393 | iRegExp *makeAnsiEscapePattern_Text(iBool includeEscChar) { |
394 | return new_RegExp("[[()][?]?([0-9;AB]*?)([ABCDEFGHJKSTfhilmn])", 0); | 394 | const char *pattern = "\x1b[[()][?]?([0-9;AB]*?)([ABCDEFGHJKSTfhilmn])"; |
395 | if (!includeEscChar) { | ||
396 | pattern++; | ||
397 | } | ||
398 | return new_RegExp(pattern, 0); | ||
395 | } | 399 | } |
396 | 400 | ||
397 | void init_Text(iText *d, SDL_Renderer *render) { | 401 | void init_Text(iText *d, SDL_Renderer *render) { |
@@ -399,7 +403,7 @@ void init_Text(iText *d, SDL_Renderer *render) { | |||
399 | activeText_ = d; | 403 | activeText_ = d; |
400 | init_Array(&d->fonts, sizeof(iFont)); | 404 | init_Array(&d->fonts, sizeof(iFont)); |
401 | d->contentFontSize = contentScale_Text_; | 405 | d->contentFontSize = contentScale_Text_; |
402 | d->ansiEscape = makeAnsiEscapePattern_Text(); | 406 | d->ansiEscape = makeAnsiEscapePattern_Text(iFalse /* no ESC */); |
403 | d->baseFontId = -1; | 407 | d->baseFontId = -1; |
404 | d->baseFgColorId = -1; | 408 | d->baseFgColorId = -1; |
405 | d->missingGlyphs = iFalse; | 409 | d->missingGlyphs = iFalse; |
@@ -1988,6 +1992,7 @@ static iBool cbAdvanceOneLine_(iWrapText *d, iRangecc range, iTextAttrib attrib, | |||
1988 | } | 1992 | } |
1989 | 1993 | ||
1990 | iInt2 tryAdvance_Text(int fontId, iRangecc text, int width, const char **endPos) { | 1994 | iInt2 tryAdvance_Text(int fontId, iRangecc text, int width, const char **endPos) { |
1995 | *endPos = text.end; | ||
1991 | iWrapText wrap = { .mode = word_WrapTextMode, | 1996 | iWrapText wrap = { .mode = word_WrapTextMode, |
1992 | .text = text, | 1997 | .text = text, |
1993 | .maxWidth = width, | 1998 | .maxWidth = width, |
@@ -2002,6 +2007,7 @@ iInt2 tryAdvanceNoWrap_Text(int fontId, iRangecc text, int width, const char **e | |||
2002 | *endPos = text.start; | 2007 | *endPos = text.start; |
2003 | return zero_I2(); | 2008 | return zero_I2(); |
2004 | } | 2009 | } |
2010 | *endPos = text.end; | ||
2005 | /* "NoWrap" means words aren't wrapped; the line is broken at nearest character. */ | 2011 | /* "NoWrap" means words aren't wrapped; the line is broken at nearest character. */ |
2006 | iWrapText wrap = { .mode = anyCharacter_WrapTextMode, | 2012 | iWrapText wrap = { .mode = anyCharacter_WrapTextMode, |
2007 | .text = text, | 2013 | .text = text, |