Fix bugs in Console, repr(C) is TOO EVILgit add src/!

Signed-off-by: Harry Chen <i@harrychen.xyz>
master
Harry Chen 6 years ago
parent 59c1746491
commit 378daa6c9b

@ -18,7 +18,6 @@ use self::fonts::{Font, Font8x16};
mod color;
mod fonts;
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct ConsoleChar {
ascii_char: u8,
@ -28,7 +27,7 @@ pub struct ConsoleChar {
impl Default for ConsoleChar {
fn default() -> Self {
ConsoleChar {
ascii_char: 0,
ascii_char: 0x20,
attr: CharacterAttribute::default(),
}
}
@ -67,7 +66,9 @@ impl<F: Font> ConsoleBuffer<F> {
ch.attr.background.pack32(fb.color_config),
);
if ch.attr.reverse {
core::mem::swap(&mut foreground, &mut background);
let temp = background;
background = foreground;
foreground = temp;
}
let underline_y = if ch.attr.underline {
F::UNDERLINE
@ -152,8 +153,9 @@ impl<F: Font> Console<F> {
fn new_line(&mut self) {
let attr_blank = ConsoleChar {
ascii_char: 0,
attr: self.parser.char_attribute(),
// use space as blank char, or Console shows it as '?'
ascii_char: 0x20,
attr: CharacterAttribute::default(),
};
for j in self.col..self.buf.num_col {
self.buf.write(self.row, j, attr_blank);

@ -7,7 +7,7 @@ use super::color::ConsoleColor;
use heapless::consts::U8;
use heapless::Vec;
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct CharacterAttribute {
/// foreground color

Loading…
Cancel
Save