print[ln] macros in place

This commit is contained in:
Jack Halford 2018-02-12 16:16:42 +01:00
parent 2503fdb96d
commit 3f2068de99
3 changed files with 31 additions and 32 deletions

View file

@ -19,6 +19,7 @@ pub fn kbd_callback() {
}
Some(ascii) => {
CONTEXT.current_term().keypress(*ascii);
CONTEXT.current_term().flush();
},
None =>{},
// None => println!("nokey ctrl {:x}", control),

View file

@ -22,24 +22,21 @@ pub extern fn kmain() -> ! {
// use vga::color::Color;
// use vga::color::ColorCode;
// WRITER.lock().reset_screen();
// WRITER.lock().color_code = ColorCode::new(Color::Yellow, Color::Black);
// println!(r#" ,--, "#);
// println!(r#" ,--.'| ,----, "#);
// println!(r#" ,--, | : .' .' \ "#);
// println!(r#",---.'| : ' ,----,' | "#);
// println!(r#"; : | | ; | : . ; "#);
// println!(r#"| | : _' | ; |.' / "#);
// println!(r#": : |.' | `----'/ ; "#);
// println!(r#"| ' ' ; : / ; / "#);
// println!(r#"\ \ .'. | ; / /-, "#);
// println!(r#" `---`: | ' / / /.`| "#);
// println!(r#" ' ; |./__; : "#);
// println!(r#" | : ;| : .' "#);
// println!(r#" ' ,/ ; | .' "#);
// println!(r#" '--' `---' "#);
// WRITER.lock().color_code = ColorCode::new(Color::White, Color::Black);
// println!(">> Kernel startup...");
println!(r#" ,--, "#);
println!(r#" ,--.'| ,----, "#);
println!(r#" ,--, | : .' .' \ "#);
println!(r#",---.'| : ' ,----,' | "#);
println!(r#"; : | | ; | : . ; "#);
println!(r#"| | : _' | ; |.' / "#);
println!(r#": : |.' | `----'/ ; "#);
println!(r#"| ' ' ; : / ; / "#);
println!(r#"\ \ .'. | ; / /-, "#);
println!(r#" `---`: | ' / / /.`| "#);
println!(r#" ' ; |./__; : "#);
println!(r#" | : ;| : .' "#);
println!(r#" ' ,/ ; | .' "#);
println!(r#" '--' `---' "#);
println!(">> Kernel startup...");
loop {
keyboard::kbd_callback();

View file

@ -8,6 +8,7 @@
// except according to those terms.
use super::{Color, ColorCode};
use ::context::CONTEXT;
#[derive(Debug, Clone, Copy)]
#[repr(C)]
@ -16,21 +17,21 @@ struct ScreenChar {
color_code: ColorCode,
}
// macro_rules! print {
// ($($arg:tt)*) => ({
// $crate::vga_buffer::print(format_args!($($arg)*));
// });
// }
macro_rules! print {
($($arg:tt)*) => ({
$crate::vga::buffer::print(format_args!($($arg)*));
});
}
// macro_rules! println {
// ($fmt:expr) => (print!(concat!($fmt, "\n")));
// ($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
// }
macro_rules! println {
($fmt:expr) => (print!(concat!($fmt, "\n")));
($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
}
// pub fn print(args: fmt::Arguments) {
// use core::fmt::Write;
// context.current_screen().write_fmt(args).unwrap();
// }
pub fn print(args: fmt::Arguments) {
use core::fmt::Write;
unsafe { CONTEXT.current_term().write_fmt(args).unwrap() };
}
extern crate core;
@ -87,7 +88,6 @@ impl Writer {
self.buffer[self.position] = b' ';
self.buffer[self.position + 1] = ColorCode::new(Color::LightGray, Color::LightGray).0;
self.flush();
}
pub fn flush(&mut self) {
@ -119,6 +119,7 @@ impl fmt::Write for Writer {
for byte in s.bytes() {
self.write_byte(byte)
}
self.flush();
Ok(())
}
}