summaryrefslogtreecommitdiff
path: root/src/ui/text.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/text.c')
-rw-r--r--src/ui/text.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/ui/text.c b/src/ui/text.c
index 6189c334..4baf60d3 100644
--- a/src/ui/text.c
+++ b/src/ui/text.c
@@ -261,7 +261,7 @@ struct Impl_Text {
261 SDL_Palette * grayscale; 261 SDL_Palette * grayscale;
262 SDL_Palette * blackAndWhite; /* unsmoothed glyph palette */ 262 SDL_Palette * blackAndWhite; /* unsmoothed glyph palette */
263 iRegExp * ansiEscape; 263 iRegExp * ansiEscape;
264 iBool enableAnsiEscapes; 264 int ansiFlags;
265 int baseFontId; /* base attributes (for restoring via escapes) */ 265 int baseFontId; /* base attributes (for restoring via escapes) */
266 int baseColorId; 266 int baseColorId;
267}; 267};
@@ -588,8 +588,8 @@ void setBaseAttributes_Text(int fontId, int colorId) {
588 activeText_->baseColorId = colorId; 588 activeText_->baseColorId = colorId;
589} 589}
590 590
591void setAnsiEscapesEnabled_Text(iBool enableAnsiEscapes) { 591void setAnsiFlags_Text(int ansiFlags) {
592 activeText_->enableAnsiEscapes = enableAnsiEscapes; 592 activeText_->ansiFlags = ansiFlags;
593} 593}
594 594
595void setDocumentFontSize_Text(iText *d, float fontSizeFactor) { 595void setDocumentFontSize_Text(iText *d, float fontSizeFactor) {
@@ -1057,10 +1057,11 @@ static void prepare_AttributedText_(iAttributedText *d, int overrideBaseDir, iCh
1057 init_RegExpMatch(&m); 1057 init_RegExpMatch(&m);
1058 if (match_RegExp(activeText_->ansiEscape, srcPos, d->source.end - srcPos, &m)) { 1058 if (match_RegExp(activeText_->ansiEscape, srcPos, d->source.end - srcPos, &m)) {
1059 finishRun_AttributedText_(d, &run, pos - 1); 1059 finishRun_AttributedText_(d, &run, pos - 1);
1060 if (activeText_->enableAnsiEscapes) { 1060 const int ansi = activeText_->ansiFlags;
1061 if (ansi) {
1061 const iRangecc sequence = capturedRange_RegExpMatch(&m, 1); 1062 const iRangecc sequence = capturedRange_RegExpMatch(&m, 1);
1062 /* Note: This styling is hardcoded to match `typesetOneLine_RunTypesetter_()`. */ 1063 /* Note: This styling is hardcoded to match `typesetOneLine_RunTypesetter_()`. */
1063 if (equal_Rangecc(sequence, "1")) { 1064 if (ansi & allowFontStyle_AnsiFlag && equal_Rangecc(sequence, "1")) {
1064 run.attrib.bold = iTrue; 1065 run.attrib.bold = iTrue;
1065 if (d->baseColorId == tmParagraph_ColorId) { 1066 if (d->baseColorId == tmParagraph_ColorId) {
1066 setFgColor_AttributedRun_(&run, tmFirstParagraph_ColorId); 1067 setFgColor_AttributedRun_(&run, tmFirstParagraph_ColorId);
@@ -1068,12 +1069,12 @@ static void prepare_AttributedText_(iAttributedText *d, int overrideBaseDir, iCh
1068 attribFont = font_Text_(fontWithStyle_Text(fontId_Text_(d->baseFont), 1069 attribFont = font_Text_(fontWithStyle_Text(fontId_Text_(d->baseFont),
1069 bold_FontStyle)); 1070 bold_FontStyle));
1070 } 1071 }
1071 else if (equal_Rangecc(sequence, "3")) { 1072 else if (ansi & allowFontStyle_AnsiFlag && equal_Rangecc(sequence, "3")) {
1072 run.attrib.italic = iTrue; 1073 run.attrib.italic = iTrue;
1073 attribFont = font_Text_(fontWithStyle_Text(fontId_Text_(d->baseFont), 1074 attribFont = font_Text_(fontWithStyle_Text(fontId_Text_(d->baseFont),
1074 italic_FontStyle)); 1075 italic_FontStyle));
1075 } 1076 }
1076 else if (equal_Rangecc(sequence, "4")) { 1077 else if (ansi & allowFontStyle_AnsiFlag && equal_Rangecc(sequence, "4")) {
1077 run.attrib.monospace = iTrue; 1078 run.attrib.monospace = iTrue;
1078 setFgColor_AttributedRun_(&run, tmPreformatted_ColorId); 1079 setFgColor_AttributedRun_(&run, tmPreformatted_ColorId);
1079 attribFont = font_Text_(fontWithFamily_Text(fontId_Text_(d->baseFont), 1080 attribFont = font_Text_(fontWithFamily_Text(fontId_Text_(d->baseFont),
@@ -1086,7 +1087,7 @@ static void prepare_AttributedText_(iAttributedText *d, int overrideBaseDir, iCh
1086 attribFont = run.font = d->baseFont; 1087 attribFont = run.font = d->baseFont;
1087 setFgColor_AttributedRun_(&run, d->baseColorId); 1088 setFgColor_AttributedRun_(&run, d->baseColorId);
1088 } 1089 }
1089 else { 1090 else if (ansi & allowFg_AnsiFlag) {
1090 run.fgColor_ = ansiForeground_Color(sequence, tmParagraph_ColorId); 1091 run.fgColor_ = ansiForeground_Color(sequence, tmParagraph_ColorId);
1091 } 1092 }
1092 } 1093 }