diff options
-rw-r--r-- | src/ui/color.c | 3 | ||||
-rw-r--r-- | src/ui/color.h | 40 | ||||
-rw-r--r-- | src/ui/documentwidget.c | 4 | ||||
-rw-r--r-- | src/ui/labelwidget.c | 4 | ||||
-rw-r--r-- | src/ui/text.c | 2 |
5 files changed, 28 insertions, 25 deletions
diff --git a/src/ui/color.c b/src/ui/color.c index e6130aad..723e9805 100644 --- a/src/ui/color.c +++ b/src/ui/color.c | |||
@@ -401,7 +401,8 @@ const char *escape_Color(int color) { | |||
401 | if (color >= 0 && color < (int) iElemCount(esc)) { | 401 | if (color >= 0 && color < (int) iElemCount(esc)) { |
402 | return esc[color]; | 402 | return esc[color]; |
403 | } | 403 | } |
404 | return format_CStr("\r%c", color + '0'); | 404 | iAssert(asciiBase_ColorEscape + color <= 127); |
405 | return format_CStr("\r%c", asciiBase_ColorEscape + color); | ||
405 | } | 406 | } |
406 | 407 | ||
407 | iHSLColor setSat_HSLColor(iHSLColor d, float sat) { | 408 | iHSLColor setSat_HSLColor(iHSLColor d, float sat) { |
diff --git a/src/ui/color.h b/src/ui/color.h index 46e7b56a..76e5b2a7 100644 --- a/src/ui/color.h +++ b/src/ui/color.h | |||
@@ -68,6 +68,7 @@ enum iColorId { | |||
68 | uiText_ColorId, | 68 | uiText_ColorId, |
69 | uiTextPressed_ColorId, | 69 | uiTextPressed_ColorId, |
70 | uiTextSelected_ColorId, | 70 | uiTextSelected_ColorId, |
71 | uiTextDisabled_ColorId, | ||
71 | uiTextFramelessHover_ColorId, | 72 | uiTextFramelessHover_ColorId, |
72 | uiTextFramelessSelected_ColorId, | 73 | uiTextFramelessSelected_ColorId, |
73 | uiTextStrong_ColorId, | 74 | uiTextStrong_ColorId, |
@@ -101,7 +102,6 @@ enum iColorId { | |||
101 | uiSeparator_ColorId, | 102 | uiSeparator_ColorId, |
102 | uiMarked_ColorId, | 103 | uiMarked_ColorId, |
103 | uiMatching_ColorId, | 104 | uiMatching_ColorId, |
104 | uiTextDisabled_ColorId, | ||
105 | 105 | ||
106 | /* content theme colors */ | 106 | /* content theme colors */ |
107 | tmFirst_ColorId, | 107 | tmFirst_ColorId, |
@@ -163,24 +163,26 @@ iLocalDef iBool isRegularText_ColorId(enum iColorId d) { | |||
163 | #define mask_ColorId 0x7f | 163 | #define mask_ColorId 0x7f |
164 | #define permanent_ColorId 0x80 /* cannot be changed via escapes */ | 164 | #define permanent_ColorId 0x80 /* cannot be changed via escapes */ |
165 | 165 | ||
166 | #define black_ColorEscape "\r0" | 166 | #define asciiBase_ColorEscape 33 |
167 | #define gray25_ColorEscape "\r1" | 167 | |
168 | #define gray50_ColorEscape "\r2" | 168 | #define black_ColorEscape "\r!" |
169 | #define gray75_ColorEscape "\r3" | 169 | #define gray25_ColorEscape "\r\"" |
170 | #define white_ColorEscape "\r4" | 170 | #define gray50_ColorEscape "\r#" |
171 | #define brown_ColorEscape "\r5" | 171 | #define gray75_ColorEscape "\r$" |
172 | #define orange_ColorEscape "\r6" | 172 | #define white_ColorEscape "\r%" |
173 | #define teal_ColorEscape "\r7" | 173 | #define brown_ColorEscape "\r&" |
174 | #define cyan_ColorEscape "\r8" | 174 | #define orange_ColorEscape "\r'" |
175 | #define yellow_ColorEscape "\r9" | 175 | #define teal_ColorEscape "\r(" |
176 | #define red_ColorEscape "\r:" | 176 | #define cyan_ColorEscape "\r)" |
177 | #define magenta_ColorEscape "\r;" | 177 | #define yellow_ColorEscape "\r*" |
178 | #define blue_ColorEscape "\r<" | 178 | #define red_ColorEscape "\r+" |
179 | #define green_ColorEscape "\r=" | 179 | #define magenta_ColorEscape "\r," |
180 | #define uiText_ColorEscape "\rC" | 180 | #define blue_ColorEscape "\r-" |
181 | #define uiTextAction_ColorEscape "\rJ" | 181 | #define green_ColorEscape "\r." |
182 | #define uiTextCaution_ColorEscape "\rK" | 182 | #define uiText_ColorEscape "\r4" |
183 | #define uiHeading_ColorEscape "\r`" | 183 | #define uiTextAction_ColorEscape "\r<" |
184 | #define uiTextCaution_ColorEscape "\r=" | ||
185 | #define uiHeading_ColorEscape "\rR" | ||
184 | 186 | ||
185 | iDeclareType(Color) | 187 | iDeclareType(Color) |
186 | iDeclareType(HSLColor) | 188 | iDeclareType(HSLColor) |
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 676c94bd..6ca6e4c2 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -1718,8 +1718,8 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) { | |||
1718 | : "", | 1718 | : "", |
1719 | showHost && (showImage || showAudio) ? " \u2014" : "", | 1719 | showHost && (showImage || showAudio) ? " \u2014" : "", |
1720 | showImage || showAudio | 1720 | showImage || showAudio |
1721 | ? '0' + fg | 1721 | ? asciiBase_ColorEscape + fg |
1722 | : ('0' + linkColor_GmDocument(doc, run->linkId, domain_GmLinkPart)), | 1722 | : (asciiBase_ColorEscape + linkColor_GmDocument(doc, run->linkId, domain_GmLinkPart)), |
1723 | showImage ? " View Image \U0001f5bc" | 1723 | showImage ? " View Image \U0001f5bc" |
1724 | : showAudio ? " Play Audio \U0001f3b5" : ""); | 1724 | : showAudio ? " Play Audio \U0001f3b5" : ""); |
1725 | } | 1725 | } |
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c index d41cc73c..8b2506e7 100644 --- a/src/ui/labelwidget.c +++ b/src/ui/labelwidget.c | |||
@@ -175,11 +175,11 @@ static void getColors_LabelWidget_(const iLabelWidget *d, int *bg, int *fg, int | |||
175 | /* Frames matching color escaped text. */ | 175 | /* Frames matching color escaped text. */ |
176 | if (startsWith_String(&d->label, "\r")) { | 176 | if (startsWith_String(&d->label, "\r")) { |
177 | if (isDark_ColorTheme(colorTheme_App())) { | 177 | if (isDark_ColorTheme(colorTheme_App())) { |
178 | *frame1 = cstr_String(&d->label)[1] - '0'; | 178 | *frame1 = cstr_String(&d->label)[1] - asciiBase_ColorEscape; |
179 | *frame2 = darker_Color(*frame1); | 179 | *frame2 = darker_Color(*frame1); |
180 | } | 180 | } |
181 | else { | 181 | else { |
182 | *bg = *frame1 = *frame2 = cstr_String(&d->label)[1] - '0'; | 182 | *bg = *frame1 = *frame2 = cstr_String(&d->label)[1] - asciiBase_ColorEscape; |
183 | *fg = uiBackground_ColorId | permanent_ColorId; | 183 | *fg = uiBackground_ColorId | permanent_ColorId; |
184 | } | 184 | } |
185 | } | 185 | } |
diff --git a/src/ui/text.c b/src/ui/text.c index a4a3804d..836d540f 100644 --- a/src/ui/text.c +++ b/src/ui/text.c | |||
@@ -460,7 +460,7 @@ static iRect run_Font_(iFont *d, enum iRunMode mode, iRangecc text, size_t maxLe | |||
460 | if (ch == '\r') { | 460 | if (ch == '\r') { |
461 | const iChar esc = nextChar_(&chPos, text.end); | 461 | const iChar esc = nextChar_(&chPos, text.end); |
462 | if (mode == draw_RunMode) { | 462 | if (mode == draw_RunMode) { |
463 | const iColor clr = get_Color(esc - '0'); | 463 | const iColor clr = get_Color(esc - asciiBase_ColorEscape); |
464 | SDL_SetTextureColorMod(text_.cache, clr.r, clr.g, clr.b); | 464 | SDL_SetTextureColorMod(text_.cache, clr.r, clr.g, clr.b); |
465 | } | 465 | } |
466 | prevCh = 0; | 466 | prevCh = 0; |