Skip to content

Commit 2425f9e

Browse files
pbrinkmeieroli-obk
authored andcommitted
Don't print two newline at end of line.
After printing a character, the code would previously automatically start a new line when the right side of the screen was reached. Thus, printing a newline at the end of a line resulted in two newlines being printed. The new code prints starts a new line only *before* printing non-CRLF characters.
1 parent 9ca2d7b commit 2425f9e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/lcd/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,9 @@ impl<'a, T: Framebuffer> fmt::Write for TextWriter<'a, T> {
330330
}
331331
match c {
332332
' '..='~' => {
333+
if self.x_pos >= WIDTH {
334+
self.newline();
335+
}
333336
let rendered = font8x8::BASIC_FONTS
334337
.get(c)
335338
.expect("character not found in basic font");
@@ -350,9 +353,6 @@ impl<'a, T: Framebuffer> fmt::Write for TextWriter<'a, T> {
350353
_ => panic!("unprintable character"),
351354
}
352355
self.x_pos += 8;
353-
if self.x_pos >= WIDTH {
354-
self.newline();
355-
}
356356
}
357357
Ok(())
358358
}

0 commit comments

Comments
 (0)