1
0
Fork 0

(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time

release/0.6
truelight 2007-04-28 10:41:00 +00:00
parent 889f2ab48c
commit 57ad2dd0fb
1 changed files with 7 additions and 1 deletions

View File

@ -620,15 +620,21 @@ static void DrawNewsString(int x, int y, uint16 color, const NewsItem *ni, uint
* from it such as big fonts, etc. */ * from it such as big fonts, etc. */
ptr = buffer; ptr = buffer;
dest = buffer2; dest = buffer2;
WChar c_last = '\0';
for (;;) { for (;;) {
WChar c = Utf8Consume(&ptr); WChar c = Utf8Consume(&ptr);
if (c == 0) break; if (c == 0) break;
if (c == '\r') { /* Make a space from a newline, but ignore multiple newlines */
if (c == '\n' && c_last != '\n') {
dest[0] = ' ';
dest++;
} else if (c == '\r') {
dest[0] = dest[1] = dest[2] = dest[3] = ' '; dest[0] = dest[1] = dest[2] = dest[3] = ' ';
dest += 4; dest += 4;
} else if (IsPrintable(c)) { } else if (IsPrintable(c)) {
dest += Utf8Encode(dest, c); dest += Utf8Encode(dest, c);
} }
c_last = c;
} }
*dest = '\0'; *dest = '\0';