Add function to change writer color

This commit is contained in:
Yash Karandikar 2021-09-17 08:46:03 -05:00
parent 32c22fe34a
commit 84eb9b1a72
2 changed files with 8 additions and 0 deletions

View file

@ -36,7 +36,9 @@ pub extern "C" fn _start() {
#[cfg(test)]
test_main();
crate::vga_buffer::change_color(crate::vga_buffer::Color::Yellow, crate::vga_buffer::Color::Black);
println!("It did not crash!");
crate::vga_buffer::change_color(crate::vga_buffer::Color::White, crate::vga_buffer::Color::Black);
loop {
x86_64::instructions::hlt();
}

View file

@ -199,3 +199,9 @@ pub fn move_cursor(x: u16, y: u16) {
let mut cursor = CURSOR.lock();
cursor.move_cursor(pos);
}
pub fn change_color(foreground: Color, background: Color) {
let mut writer = WRITER.lock();
let color = ColorCode::new(foreground, background);
writer.color_code = color;
}