summaryrefslogtreecommitdiff
path: root/kernel/src/io
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/src/io')
-rw-r--r--kernel/src/io/vga_text.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/kernel/src/io/vga_text.rs b/kernel/src/io/vga_text.rs
index eef56bf..833c191 100644
--- a/kernel/src/io/vga_text.rs
+++ b/kernel/src/io/vga_text.rs
@@ -160,15 +160,12 @@ impl OStream {
pub fn print_centered(&mut self, s: &[u8]) {
let mut line_start = 0;
let mut line_len = 0;
- for (n, &c) in s.iter().enumerate() {
- if line_len >= WIDTH || c == b'\n' || n == s.len() - 1 {
- self.set_col((WIDTH - line_len) >> 1);
- self.put_bytes(&s[line_start..(line_start+line_len+1)]);
- self.new_line();
- line_start += line_len;
- line_len = 0;
+ for chunk in s.chunks(WIDTH) {
+ for line in chunk.split(|&c| c == b'\n') {
+ self.set_col((WIDTH - line.len()) >> 1);
+ self.put_bytes(line);
+ self.new_line()
}
- line_len += 1;
}
}
}