From ec977ccd0526de19e53f401d6be88d06a907952e Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Tue, 1 Dec 2015 17:28:22 -0800 Subject: [PATCH] Implement console "\n" -> crlf() behavior. --- firmware/application/ui_console.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/firmware/application/ui_console.cpp b/firmware/application/ui_console.cpp index 0c299acd..48c0daeb 100644 --- a/firmware/application/ui_console.cpp +++ b/firmware/application/ui_console.cpp @@ -40,17 +40,21 @@ void Console::write(const std::string message) { const Font& font = s.font; const auto rect = screen_rect(); for(const auto c : message) { - const auto glyph = font.glyph(c); - const auto advance = glyph.advance(); - if( (pos.x + advance.x) > rect.width() ) { + if( c == '\n' ) { crlf(); + } else { + const auto glyph = font.glyph(c); + const auto advance = glyph.advance(); + if( (pos.x + advance.x) > rect.width() ) { + crlf(); + } + const Point pos_glyph { + static_cast(rect.pos.x + pos.x), + display.scroll_area_y(pos.y) + }; + display.draw_glyph(pos_glyph, glyph, s.foreground, s.background); + pos.x += advance.x; } - const Point pos_glyph { - static_cast(rect.pos.x + pos.x), - display.scroll_area_y(pos.y) - }; - display.draw_glyph(pos_glyph, glyph, s.foreground, s.background); - pos.x += advance.x; } }