diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-23 06:04:20 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-23 06:04:20 +0200 |
commit | 492d80a084685fc30bb8e9ef7689dcdcbe9ab307 (patch) | |
tree | 5233d70a57bbc189de7e246b671a05ba311a5601 /src/ui/text.c | |
parent | 7f7011c021bdeed29963942e3a5dc8f3361f39c4 (diff) |
Text: Escape for restoring original color
Diffstat (limited to 'src/ui/text.c')
-rw-r--r-- | src/ui/text.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/ui/text.c b/src/ui/text.c index 8736ed18..b2a9af2e 100644 --- a/src/ui/text.c +++ b/src/ui/text.c | |||
@@ -716,6 +716,7 @@ struct Impl_RunArgs { | |||
716 | iInt2 pos; | 716 | iInt2 pos; |
717 | int xposLimit; /* hard limit for wrapping */ | 717 | int xposLimit; /* hard limit for wrapping */ |
718 | int xposLayoutBound; /* visible bound for layout purposes; does not affect wrapping */ | 718 | int xposLayoutBound; /* visible bound for layout purposes; does not affect wrapping */ |
719 | int color; | ||
719 | const char ** continueFrom_out; | 720 | const char ** continueFrom_out; |
720 | int * runAdvance_out; | 721 | int * runAdvance_out; |
721 | }; | 722 | }; |
@@ -770,17 +771,6 @@ static iRect run_Font_(iFont *d, const iRunArgs *args) { | |||
770 | ch = nextChar_(&chPos, args->text.end); | 771 | ch = nextChar_(&chPos, args->text.end); |
771 | } | 772 | } |
772 | } | 773 | } |
773 | #if 0 | ||
774 | iChar nextCh = 0; { | ||
775 | /* TODO: Since we're peeking ahead, should use this on the next loop iteration. */ | ||
776 | const char *ncp = chPos; | ||
777 | nextCh = nextChar_(&ncp, text.end); | ||
778 | } | ||
779 | /* VS15: Peek ahead and treat as Emoji font. */ | ||
780 | if (nextCh == emojiVariationSelector_Char) { | ||
781 | isEmoji = iTrue; | ||
782 | } | ||
783 | #endif | ||
784 | if (isVariationSelector_Char(ch)) { | 774 | if (isVariationSelector_Char(ch)) { |
785 | ch = nextChar_(&chPos, args->text.end); /* skip it */ | 775 | ch = nextChar_(&chPos, args->text.end); /* skip it */ |
786 | } | 776 | } |
@@ -832,11 +822,16 @@ static iRect run_Font_(iFont *d, const iRunArgs *args) { | |||
832 | } | 822 | } |
833 | if (ch == '\r') { | 823 | if (ch == '\r') { |
834 | iChar esc = nextChar_(&chPos, args->text.end); | 824 | iChar esc = nextChar_(&chPos, args->text.end); |
835 | if (esc == '\r') { /* Extended range. */ | 825 | int colorNum = args->color; |
826 | if (esc != 0x24) { /* ASCII Cancel */ | ||
827 | colorNum = esc - asciiBase_ColorEscape; | ||
828 | } | ||
829 | else if (esc == '\r') { /* Extended range. */ | ||
836 | esc = nextChar_(&chPos, args->text.end) + asciiExtended_ColorEscape; | 830 | esc = nextChar_(&chPos, args->text.end) + asciiExtended_ColorEscape; |
831 | colorNum = esc - asciiBase_ColorEscape; | ||
837 | } | 832 | } |
838 | if (mode & draw_RunMode && ~mode & permanentColorFlag_RunMode) { | 833 | if (mode & draw_RunMode && ~mode & permanentColorFlag_RunMode) { |
839 | const iColor clr = get_Color(esc - asciiBase_ColorEscape); | 834 | const iColor clr = get_Color(colorNum); |
840 | SDL_SetTextureColorMod(text_.cache, clr.r, clr.g, clr.b); | 835 | SDL_SetTextureColorMod(text_.cache, clr.r, clr.g, clr.b); |
841 | } | 836 | } |
842 | prevCh = 0; | 837 | prevCh = 0; |
@@ -1036,9 +1031,10 @@ static void drawBounded_Text_(int fontId, iInt2 pos, int xposBound, int color, i | |||
1036 | &(iRunArgs){ .mode = draw_RunMode | | 1031 | &(iRunArgs){ .mode = draw_RunMode | |
1037 | (color & permanent_ColorId ? permanentColorFlag_RunMode : 0) | | 1032 | (color & permanent_ColorId ? permanentColorFlag_RunMode : 0) | |
1038 | runFlagsFromId_(fontId), | 1033 | runFlagsFromId_(fontId), |
1039 | .text = text, | 1034 | .text = text, |
1040 | .pos = pos, | 1035 | .pos = pos, |
1041 | .xposLayoutBound = xposBound }); | 1036 | .xposLayoutBound = xposBound, |
1037 | .color = color }); | ||
1042 | } | 1038 | } |
1043 | 1039 | ||
1044 | static void draw_Text_(int fontId, iInt2 pos, int color, iRangecc text) { | 1040 | static void draw_Text_(int fontId, iInt2 pos, int color, iRangecc text) { |