diff --git a/src/interrupts.rs b/src/interrupts.rs index 956b7d0..b9e1ba9 100644 --- a/src/interrupts.rs +++ b/src/interrupts.rs @@ -72,8 +72,15 @@ 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) => match character { + '\x08' => { + use crate::vga_buffer::WRITER; + WRITER.lock().backspace(); + } + _ => print!("{}", character), + }, + //DecodedKey::RawKey(key) => print!("{:?}", key), + DecodedKey::RawKey(_) => {} // ignoring raw keys } } } diff --git a/src/vga_buffer.rs b/src/vga_buffer.rs index 0366321..8f28833 100644 --- a/src/vga_buffer.rs +++ b/src/vga_buffer.rs @@ -109,6 +109,14 @@ impl Writer { } } } + + pub fn backspace(&mut self) { + if self.column_position > 0 { + self.column_position -= 1; + self.write_byte(b' '); + self.column_position -= 1; + } + } } impl fmt::Write for Writer {