diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/color.c | 8 | ||||
-rw-r--r-- | src/ui/color.h | 1 | ||||
-rw-r--r-- | src/ui/text.c | 8 |
3 files changed, 12 insertions, 5 deletions
diff --git a/src/ui/color.c b/src/ui/color.c index 870db2d0..3adf857d 100644 --- a/src/ui/color.c +++ b/src/ui/color.c | |||
@@ -427,8 +427,12 @@ const char *escape_Color(int color) { | |||
427 | if (color >= 0 && color < (int) iElemCount(esc)) { | 427 | if (color >= 0 && color < (int) iElemCount(esc)) { |
428 | return esc[color]; | 428 | return esc[color]; |
429 | } | 429 | } |
430 | iAssert(asciiBase_ColorEscape + color <= 127); | 430 | /* Double-\r is used for range extension. */ |
431 | return format_CStr("\r%c", asciiBase_ColorEscape + color); | 431 | if (color + asciiBase_ColorEscape > 127) { |
432 | iAssert(color - asciiExtended_ColorEscape + asciiBase_ColorEscape <= 127); | ||
433 | return format_CStr("\r\r%c", color - asciiExtended_ColorEscape + asciiBase_ColorEscape); | ||
434 | } | ||
435 | return format_CStr("\r%c", color + asciiBase_ColorEscape); | ||
432 | } | 436 | } |
433 | 437 | ||
434 | iHSLColor setSat_HSLColor(iHSLColor d, float sat) { | 438 | iHSLColor setSat_HSLColor(iHSLColor d, float sat) { |
diff --git a/src/ui/color.h b/src/ui/color.h index 69dbe797..e2a1c95b 100644 --- a/src/ui/color.h +++ b/src/ui/color.h | |||
@@ -173,6 +173,7 @@ iLocalDef iBool isRegularText_ColorId(enum iColorId d) { | |||
173 | #define permanent_ColorId 0x80 /* cannot be changed via escapes */ | 173 | #define permanent_ColorId 0x80 /* cannot be changed via escapes */ |
174 | 174 | ||
175 | #define asciiBase_ColorEscape 33 | 175 | #define asciiBase_ColorEscape 33 |
176 | #define asciiExtended_ColorEscape (128 - asciiBase_ColorEscape) | ||
176 | 177 | ||
177 | #define black_ColorEscape "\r!" | 178 | #define black_ColorEscape "\r!" |
178 | #define gray25_ColorEscape "\r\"" | 179 | #define gray25_ColorEscape "\r\"" |
diff --git a/src/ui/text.c b/src/ui/text.c index 016aeef1..65c7a256 100644 --- a/src/ui/text.c +++ b/src/ui/text.c | |||
@@ -734,8 +734,7 @@ static iRect run_Font_(iFont *d, const iRunArgs *args) { | |||
734 | for (const char *chPos = args->text.start; chPos != args->text.end; ) { | 734 | for (const char *chPos = args->text.start; chPos != args->text.end; ) { |
735 | iAssert(chPos < args->text.end); | 735 | iAssert(chPos < args->text.end); |
736 | const char *currentPos = chPos; | 736 | const char *currentPos = chPos; |
737 | if (*chPos == 0x1b) { | 737 | if (*chPos == 0x1b) { /* ANSI escape. */ |
738 | /* ANSI escape. */ | ||
739 | chPos++; | 738 | chPos++; |
740 | iRegExpMatch m; | 739 | iRegExpMatch m; |
741 | init_RegExpMatch(&m); | 740 | init_RegExpMatch(&m); |
@@ -821,7 +820,10 @@ static iRect run_Font_(iFont *d, const iRunArgs *args) { | |||
821 | continue; | 820 | continue; |
822 | } | 821 | } |
823 | if (ch == '\r') { | 822 | if (ch == '\r') { |
824 | const iChar esc = nextChar_(&chPos, args->text.end); | 823 | iChar esc = nextChar_(&chPos, args->text.end); |
824 | if (esc == '\r') { /* Extended range. */ | ||
825 | esc = nextChar_(&chPos, args->text.end) + asciiExtended_ColorEscape; | ||
826 | } | ||
825 | if (mode & draw_RunMode && ~mode & permanentColorFlag_RunMode) { | 827 | if (mode & draw_RunMode && ~mode & permanentColorFlag_RunMode) { |
826 | const iColor clr = get_Color(esc - asciiBase_ColorEscape); | 828 | const iColor clr = get_Color(esc - asciiBase_ColorEscape); |
827 | SDL_SetTextureColorMod(text_.cache, clr.r, clr.g, clr.b); | 829 | SDL_SetTextureColorMod(text_.cache, clr.r, clr.g, clr.b); |