This commit is contained in:
Able 2022-02-19 09:07:33 -06:00
parent b7431ba474
commit c49eb97397
3 changed files with 38 additions and 15 deletions

View file

@ -0,0 +1,17 @@
pub struct KeyEvent{
lctrl 1
rctrl 2
lalt 3
ralt 4
lsup 5
rsup 6
lshift 7
rshift 8
caps 9
down 10
# Keycodes
key 11-32
}

View file

@ -1,7 +1,8 @@
use crate::{
arch::{drivers::vga::WRITER, gdt},
kernel_state::KERNEL_STATE,
print, println, KEYBUFF,
print, println,
rhai_shell::KEYBUFF,
};
use lazy_static::lazy_static;

View file

@ -1,20 +1,7 @@
use alloc::vec::Vec;
pub fn rhai_shell() {
let mut engine = rhai::Engine::new();
engine.on_print(|x| println!("{}", x));
engine.on_debug(|x, src, pos| {
let src = src.unwrap_or("unknown");
println!("DEBUG: {} at {:?}: {}", src, pos, x);
debug!("{} at {:?}: {}", src, pos, x);
});
engine.register_fn("afetch", afetch);
engine.register_fn("set_hostname", set_hostname);
engine.register_fn("shutdown", shutdown);
let engine = engine_construction();
let mut scope = rhai::Scope::new();
let mut buf = String::new();
@ -46,6 +33,7 @@ lazy_static::lazy_static!(
);
use alloc::string::{String, ToString};
use rhai::Engine;
use x86_64::instructions::interrupts::{disable, enable};
use crate::{
@ -74,3 +62,20 @@ pub fn set_hostname(name: String) {
let mut kstate = KERNEL_STATE.lock();
kstate.hostname = name;
}
fn engine_construction() -> Engine {
let mut engine = rhai::Engine::new();
engine.on_print(|x| println!("{}", x));
engine.on_debug(|x, src, pos| {
let src = src.unwrap_or("unknown");
println!("DEBUG: {} at {:?}: {}", src, pos, x);
debug!("{} at {:?}: {}", src, pos, x);
});
engine.register_fn("afetch", afetch);
engine.register_fn("set_hostname", set_hostname);
engine.register_fn("shutdown", shutdown);
engine
}