mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-22 08:06:17 +04:00
Implement the new_line
method
This commit is contained in:
parent
5e0ccd5aa5
commit
f24c7bc322
@ -85,7 +85,27 @@ impl Writer {
|
||||
unsafe{ self.buffer.as_mut() }
|
||||
}
|
||||
|
||||
fn new_line(&mut self) {/* TODO */}
|
||||
fn new_line(&mut self) {
|
||||
for row in 1..BUFFER_HEIGHT {
|
||||
for col in 0..BUFFER_WIDTH {
|
||||
let buffer = self.buffer();
|
||||
let character = buffer.chars[row][col].read();
|
||||
buffer.chars[row - 1][col].write(character);
|
||||
}
|
||||
}
|
||||
self.clear_row(BUFFER_HEIGHT-1);
|
||||
self.column_position = 0;
|
||||
}
|
||||
|
||||
fn clear_row(&mut self, row: usize) {
|
||||
let blank = ScreenChar {
|
||||
ascii_character: b' ',
|
||||
color_code: self.color_code,
|
||||
};
|
||||
for col in 0..BUFFER_WIDTH {
|
||||
self.buffer().chars[row][col].write(blank);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Write for Writer {
|
||||
@ -107,7 +127,6 @@ pub fn print_something() {
|
||||
buffer: unsafe { Unique::new(0xb8000 as *mut _) },
|
||||
};
|
||||
|
||||
writer.write_byte(b'H');
|
||||
writer.write_str("ello! ");
|
||||
write!(writer, "The numbers are {} and {}", 42, 1.0/3.0);
|
||||
writeln!(writer, "Hello!");
|
||||
writeln!(writer, "The numbers are {} and {}", 42, 1.0/3.0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user