Implement console "\n" -> crlf() behavior.

This commit is contained in:
Jared Boone 2015-12-01 17:28:22 -08:00
parent 32319ddf9f
commit ec977ccd05

View File

@ -40,6 +40,9 @@ void Console::write(const std::string message) {
const Font& font = s.font; const Font& font = s.font;
const auto rect = screen_rect(); const auto rect = screen_rect();
for(const auto c : message) { for(const auto c : message) {
if( c == '\n' ) {
crlf();
} else {
const auto glyph = font.glyph(c); const auto glyph = font.glyph(c);
const auto advance = glyph.advance(); const auto advance = glyph.advance();
if( (pos.x + advance.x) > rect.width() ) { if( (pos.x + advance.x) > rect.width() ) {
@ -52,6 +55,7 @@ void Console::write(const std::string message) {
display.draw_glyph(pos_glyph, glyph, s.foreground, s.background); display.draw_glyph(pos_glyph, glyph, s.foreground, s.background);
pos.x += advance.x; pos.x += advance.x;
} }
}
} }
void Console::writeln(const std::string message) { void Console::writeln(const std::string message) {