mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
Merge pull request #15 from phil-opp/printing_to_screen_improvements
Add the clear_screen function from the blog post
This commit is contained in:
@@ -25,6 +25,7 @@ mod vga_buffer;
|
|||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern fn rust_main() {
|
pub extern fn rust_main() {
|
||||||
// ATTENTION: we have a very small stack and no guard page
|
// ATTENTION: we have a very small stack and no guard page
|
||||||
|
vga_buffer::clear_screen();
|
||||||
println!("Hello World{}", "!");
|
println!("Hello World{}", "!");
|
||||||
|
|
||||||
loop{}
|
loop{}
|
||||||
|
|||||||
@@ -23,6 +23,12 @@ macro_rules! print {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clear_screen() {
|
||||||
|
for _ in 0..BUFFER_HEIGHT {
|
||||||
|
println!("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum Color {
|
pub enum Color {
|
||||||
@@ -85,7 +91,7 @@ impl Writer {
|
|||||||
|
|
||||||
fn clear_row(&mut self, row: usize) {
|
fn clear_row(&mut self, row: usize) {
|
||||||
let blank = ScreenChar {
|
let blank = ScreenChar {
|
||||||
ascii_character: ' ' as u8,
|
ascii_character: b' ',
|
||||||
color_code: self.color_code,
|
color_code: self.color_code,
|
||||||
};
|
};
|
||||||
self.buffer().chars[row] = [blank; BUFFER_WIDTH];
|
self.buffer().chars[row] = [blank; BUFFER_WIDTH];
|
||||||
|
|||||||
Reference in New Issue
Block a user