# HG changeset patch # User Darkvater # Date 1163698884 0 # Node ID 88ee12d715036fc943f22e0631258ecbd1df5c81 # Parent 327babe7afefb1bcb75bf5c55900a2e4408568ef (svn r7172) -Fix [r6931]: The console showed '?' characters instead of colours. Now strip all colours for the console. It's a bit magicky (magic numbers) but UTF8 fixes that soon. diff -r 327babe7afef -r 88ee12d71503 console.c --- a/console.c Thu Nov 16 17:15:26 2006 +0000 +++ b/console.c Thu Nov 16 17:41:24 2006 +0000 @@ -400,6 +400,7 @@ memmove(&_iconsole_buffer[0], &_iconsole_buffer[1], sizeof(_iconsole_buffer[0]) * ICON_BUFFER); _iconsole_buffer[ICON_BUFFER] = strdup(string); + str_strip_colours(_iconsole_buffer[ICON_BUFFER]); str_validate(_iconsole_buffer[ICON_BUFFER]); memmove(&_iconsole_cbuffer[0], &_iconsole_cbuffer[1], sizeof(_iconsole_cbuffer[0]) * ICON_BUFFER); diff -r 327babe7afef -r 88ee12d71503 string.c --- a/string.c Thu Nov 16 17:15:26 2006 +0000 +++ b/string.c Thu Nov 16 17:41:24 2006 +0000 @@ -72,6 +72,19 @@ if (!IsValidAsciiChar(*str, CS_ALPHANUMERAL)) *str = '?'; } +void str_strip_colours(char *str) +{ + char *dst = str; + for (; *str != '\0';) { + if (*str >= 15 && *str <= 31) { // magic colour codes + str++; + } else { + *dst++ = *str++; + } + } + *dst = '\0'; +} + /** * Only allow certain keys. You can define the filter to be used. This makes * sure no invalid keys can get into an editbox, like BELL. diff -r 327babe7afef -r 88ee12d71503 string.h --- a/string.h Thu Nov 16 17:15:26 2006 +0000 +++ b/string.h Thu Nov 16 17:41:24 2006 +0000 @@ -29,6 +29,9 @@ * replaces them with a question mark '?' */ void str_validate(char *str); +/** Scans the string for colour codes and strips them */ +void str_strip_colours(char *str); + /** * Valid filter types for IsValidAsciiChar. */