Implement backspace
This commit is contained in:
parent
3f946b95b2
commit
fd306dae01
|
@ -59,9 +59,14 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStac
|
|||
if let Ok(Some(key_event)) = keyboard.add_byte(scancode) {
|
||||
if let Some(key) = keyboard.process_keyevent(key_event) {
|
||||
match key {
|
||||
DecodedKey::Unicode(character) => print!("{}", character),
|
||||
DecodedKey::RawKey(key) => print!("{:?}", key),
|
||||
}
|
||||
DecodedKey::Unicode(character) => {
|
||||
if character == '\u{8}' {
|
||||
crate::vga_buffer::backspace();
|
||||
} else {
|
||||
print!("{}", character)
|
||||
}
|
||||
},
|
||||
DecodedKey::RawKey(key) => print!("{:#?}", key), }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -150,4 +150,14 @@ pub fn _print(args: fmt::Arguments) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
pub fn backspace() {
|
||||
let mut writer = WRITER.lock();
|
||||
let row = BUFFER_HEIGHT - 1;
|
||||
let col = writer.column_position;
|
||||
let color_code = writer.color_code;
|
||||
writer.buffer.chars[row][col - 1].write(ScreenChar {
|
||||
ascii_character: b' ',
|
||||
color_code
|
||||
});
|
||||
writer.column_position -= 1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue