diff --git a/ableos/src/arch/x86_64/interrupts.rs b/ableos/src/arch/x86_64/interrupts.rs index 1429a9b8..1dca10a0 100644 --- a/ableos/src/arch/x86_64/interrupts.rs +++ b/ableos/src/arch/x86_64/interrupts.rs @@ -90,6 +90,7 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStac // Backspace 8 => { WRITER.lock().backspace(); + KEYBUFF.lock().push(8_u8 as _); // print!(" "); // WRITER.lock().backspace(); } diff --git a/ableos/src/scratchpad.rs b/ableos/src/scratchpad.rs index c0e7a605..6d7f4b5e 100644 --- a/ableos/src/scratchpad.rs +++ b/ableos/src/scratchpad.rs @@ -36,7 +36,7 @@ pub fn scratchpad() { */ // interp(); - // rhai_shell(); + rhai_shell(); } pub struct PciIO {} @@ -94,16 +94,28 @@ impl ProcessMessage { */ pub fn rhai_shell() { - let mut engine = rhai::Engine::new(); + let engine = rhai::Engine::new(); + let mut buf = String::new(); + print!("> "); - let ret = engine.eval::("1 + 2"); + loop { + match x86_64::instructions::interrupts::without_interrupts(|| KEYBUFF.lock().pop()) { + Some('\n') => { + match engine.eval::(&buf) { + Ok(o) => println!("{o}"), + Err(e) => println!("Eval error: {e}"), + }; - match ret { - Ok(x) => println!("{}", x), - Err(e) => println!("{}", e), + buf.clear(); + print!("> "); + } + Some('\u{0008}') => { + buf.pop(); + } + Some(chr) => buf.push(chr), + None => (), + } } - - loop {} } lazy_static::lazy_static!( pub static ref KEYBUFF: spin::Mutex> = spin::Mutex::new(