Add: {PUSH_COLOUR} and {POP_COLOUR} control codes to handle switching colours. (#6737)

This replaces the internal SCC_PREVIOUS_COLOUR swap.
This commit is contained in:
2018-04-19 19:33:21 +01:00
committed by GitHub
parent f4f9e18790
commit 3b32075e8a
5 changed files with 33 additions and 13 deletions

View File

@@ -449,6 +449,8 @@ static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, Money n
/* convert from negative */
if (number < 0) {
if (buff + Utf8CharLen(SCC_PUSH_COLOUR) > last) return buff;
buff += Utf8Encode(buff, SCC_PUSH_COLOUR);
if (buff + Utf8CharLen(SCC_RED) > last) return buff;
buff += Utf8Encode(buff, SCC_RED);
buff = strecpy(buff, "-", last);
@@ -485,8 +487,8 @@ static char *FormatGenericCurrency(char *buff, const CurrencySpec *spec, Money n
if (spec->symbol_pos != 0) buff = strecpy(buff, spec->suffix, last);
if (negative) {
if (buff + Utf8CharLen(SCC_PREVIOUS_COLOUR) > last) return buff;
buff += Utf8Encode(buff, SCC_PREVIOUS_COLOUR);
if (buff + Utf8CharLen(SCC_POP_COLOUR) > last) return buff;
buff += Utf8Encode(buff, SCC_POP_COLOUR);
*buff = '\0';
}