From 8eb86d55a1d8a6fb39b734cd41903de70a6a6076 Mon Sep 17 00:00:00 2001 From: Daniel Beckwith Date: Tue, 31 Mar 2020 18:22:55 -0400 Subject: [PATCH] Add fill_screen --- src/writers/mod.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/writers/mod.rs b/src/writers/mod.rs index ed66771..499b031 100644 --- a/src/writers/mod.rs +++ b/src/writers/mod.rs @@ -87,6 +87,21 @@ pub trait TextWriter: Screen { } } + /// Fills the screen by setting all cells to `b' '` with the given color. + fn fill_screen(&self, color: TextModeColor) { + let (_vga, frame_buffer) = self.get_frame_buffer(); + let character = ScreenCharacter { + character: b' ', + color, + }; + let screen_size = self.get_width() * self.get_height(); + for i in 0..screen_size { + unsafe { + frame_buffer.add(i).write_volatile(character); + } + } + } + /// Disables the cursor in vga text modes. fn disable_cursor(&self) { let (mut vga, _frame_buffer) = self.get_frame_buffer();