Add clear command
This commit is contained in:
parent
9cef3e7732
commit
c201ddd35a
17
src/shell.rs
17
src/shell.rs
|
@ -1,5 +1,6 @@
|
||||||
use crate::println;
|
use crate::println;
|
||||||
use crate::print;
|
use crate::print;
|
||||||
|
use crate::vga_buffer::ScreenChar;
|
||||||
use crate::vga_buffer::{change_color, Color};
|
use crate::vga_buffer::{change_color, Color};
|
||||||
use arrayvec::{ArrayVec, ArrayString};
|
use arrayvec::{ArrayVec, ArrayString};
|
||||||
|
|
||||||
|
@ -14,6 +15,7 @@ pub fn evaluate(command: &str) {
|
||||||
"info" => info,
|
"info" => info,
|
||||||
"echo" => echo,
|
"echo" => echo,
|
||||||
"shutdown" => shutdown,
|
"shutdown" => shutdown,
|
||||||
|
"clear" => clear,
|
||||||
_ => default
|
_ => default
|
||||||
};
|
};
|
||||||
selected(&parts[..]);
|
selected(&parts[..]);
|
||||||
|
@ -67,3 +69,18 @@ fn shutdown(_arguments: &[&str]) {
|
||||||
shutdown_port.write(0x2000);
|
shutdown_port.write(0x2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn clear(_arguments: &[&str]) {
|
||||||
|
let mut writer = crate::vga_buffer::WRITER.lock();
|
||||||
|
|
||||||
|
for row in 0..crate::vga_buffer::BUFFER_HEIGHT {
|
||||||
|
for col in 0..crate::vga_buffer::BUFFER_WIDTH {
|
||||||
|
let blank = ScreenChar {
|
||||||
|
ascii_character: b' ',
|
||||||
|
color_code: crate::vga_buffer::ColorCode::new(crate::vga_buffer::Color::White, crate::vga_buffer::Color::Black)
|
||||||
|
};
|
||||||
|
|
||||||
|
writer.buffer.chars[row][col].write(blank);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -28,10 +28,10 @@ pub enum Color {
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct ColorCode(u8);
|
pub(crate) struct ColorCode(u8);
|
||||||
|
|
||||||
impl ColorCode {
|
impl ColorCode {
|
||||||
fn new(foreground: Color, background: Color) -> ColorCode {
|
pub fn new(foreground: Color, background: Color) -> ColorCode {
|
||||||
ColorCode((background as u8) << 4 | (foreground as u8))
|
ColorCode((background as u8) << 4 | (foreground as u8))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ impl ColorCode {
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct ScreenChar {
|
pub struct ScreenChar {
|
||||||
pub ascii_character: u8,
|
pub ascii_character: u8,
|
||||||
color_code: ColorCode
|
pub(crate) color_code: ColorCode
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) const BUFFER_HEIGHT: usize = 25;
|
pub(crate) const BUFFER_HEIGHT: usize = 25;
|
||||||
|
|
Loading…
Reference in a new issue