Add print! and println! macros and a clear_screen function

This commit is contained in:
Philipp Oppermann
2017-04-12 19:35:08 +02:00
parent 40aed4fa0f
commit 59b8133396
2 changed files with 22 additions and 4 deletions

View File

@@ -123,3 +123,22 @@ impl fmt::Write for Writer {
Ok(())
}
}
macro_rules! print {
($($arg:tt)*) => ({
use core::fmt::Write;
let mut writer = $crate::vga_buffer::WRITER.lock();
writer.write_fmt(format_args!($($arg)*)).unwrap();
});
}
macro_rules! println {
($fmt:expr) => (print!(concat!($fmt, "\n")));
($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
}
pub fn clear_screen() {
for _ in 0..BUFFER_HEIGHT {
println!("");
}
}