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

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

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

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

Loading…
Cancel
Save