src/news_gui.cpp
changeset 6542 47e288403035
parent 6481 85ad87daf4b0
child 6624 880e29b1f25e
equal deleted inserted replaced
6541:dfa5165a5ab7 6542:47e288403035
   618 	GetString(buffer, str, lastof(buffer));
   618 	GetString(buffer, str, lastof(buffer));
   619 	/* Copy the just gotten string to another buffer to remove any formatting
   619 	/* Copy the just gotten string to another buffer to remove any formatting
   620 	 * from it such as big fonts, etc. */
   620 	 * from it such as big fonts, etc. */
   621 	ptr  = buffer;
   621 	ptr  = buffer;
   622 	dest = buffer2;
   622 	dest = buffer2;
       
   623 	WChar c_last = '\0';
   623 	for (;;) {
   624 	for (;;) {
   624 		WChar c = Utf8Consume(&ptr);
   625 		WChar c = Utf8Consume(&ptr);
   625 		if (c == 0) break;
   626 		if (c == 0) break;
   626 		if (c == '\r') {
   627 		/* Make a space from a newline, but ignore multiple newlines */
       
   628 		if (c == '\n' && c_last != '\n') {
       
   629 			dest[0] = ' ';
       
   630 			dest++;
       
   631 		} else if (c == '\r') {
   627 			dest[0] = dest[1] = dest[2] = dest[3] = ' ';
   632 			dest[0] = dest[1] = dest[2] = dest[3] = ' ';
   628 			dest += 4;
   633 			dest += 4;
   629 		} else if (IsPrintable(c)) {
   634 		} else if (IsPrintable(c)) {
   630 			dest += Utf8Encode(dest, c);
   635 			dest += Utf8Encode(dest, c);
   631 		}
   636 		}
       
   637 		c_last = c;
   632 	}
   638 	}
   633 
   639 
   634 	*dest = '\0';
   640 	*dest = '\0';
   635 	/* Truncate and show string; postfixed by '...' if neccessary */
   641 	/* Truncate and show string; postfixed by '...' if neccessary */
   636 	DoDrawStringTruncated(buffer2, x, y, color, maxw);
   642 	DoDrawStringTruncated(buffer2, x, y, color, maxw);