From c7c2905b407b446978d63fb500a4f1780dbc1d3c Mon Sep 17 00:00:00 2001 From: ami-chuu Date: Mon, 30 Mar 2026 18:23:08 +0300 Subject: [PATCH] Added Backspace Support --- src/interrupts.rs | 11 +++++++++-- src/vga_buffer.rs | 8 ++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) 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 {