From 578717a9b85c9b4be8c51af1c31ec863789fa664 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Wed, 12 Apr 2017 19:25:48 +0200 Subject: [PATCH] =?UTF-8?q?Add=20a=20`write=5Fstr`=20method=20and=20print?= =?UTF-8?q?=20=E2=80=9CHello!=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/vga_buffer.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/vga_buffer.rs b/src/vga_buffer.rs index 1a76527..522f535 100644 --- a/src/vga_buffer.rs +++ b/src/vga_buffer.rs @@ -74,6 +74,12 @@ impl Writer { } } + pub fn write_str(&mut self, s: &str) { + for byte in s.bytes() { + self.write_byte(byte) + } + } + fn buffer(&mut self) -> &mut Buffer { unsafe{ self.buffer.as_mut() } } @@ -88,5 +94,5 @@ pub fn print_something() { buffer: unsafe { Unique::new(0xb8000 as *mut _) }, }; - writer.write_byte(b'H'); + writer.write_str("Hello!"); }