feat(vga): add vga change color interface
continuous-integration/drone/push Build is passing

Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
juju committed 2021-12-02 20:28:15 +01:00
1 parent 70e7b48bfe
commit be8f3f2a0f
2 files changed
+12 -3

No files matched your search

+4 -2
View File
@@ -1,20 +1,22 @@
#![no_std]
#![no_main]
mod vga;
use core::panic::PanicInfo;
use vga::Color;
#[panic_handler]
fn panic_handler(info: &PanicInfo) -> ! {
vga::change_color(Color::LightRed, Color::Black);
println!("{}", info);
loop {}
}
mod vga;
#[no_mangle]
pub extern "C" fn julios_main() -> ! {
println!("Hello World!");
println!("{}", "***JuliOS***");
panic!("Test panick");
panic!("Test panic");
loop {}
}
+8 -1
View File
@@ -9,7 +9,7 @@ const BUFFER_WIDTH: usize = 80;
lazy_static! {
pub static ref WRITER: Mutex<Writer> = Mutex::new(Writer {
column: 0,
color_code: ColorCode::new(Color::Green, Color::Black),
color_code: ColorCode::new(Color::LightBlue, Color::Black),
buffer: unsafe { &mut *(0xb8000 as *mut VgaBuffer) }
});
}
@@ -30,6 +30,9 @@ pub fn _print(args: fmt::Arguments) {
use core::fmt::Write;
WRITER.lock().write_fmt(args).unwrap();
}
pub fn change_color(fg: Color, bg: Color) {
WRITER.lock().change_color(ColorCode::new(fg, bg))
}
#[allow(dead_code)]
@@ -133,6 +136,10 @@ impl Writer {
self.buffer.chars[row][col].write(blank);
}
}
fn change_color(&mut self, color: ColorCode) {
self.color_code = color;
}
}
impl fmt::Write for Writer {
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.