forked from AbleOS/ableos
patchup
This commit is contained in:
parent
b7431ba474
commit
c49eb97397
17
ableos/assets/key_event.txt
Normal file
17
ableos/assets/key_event.txt
Normal 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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
arch::{drivers::vga::WRITER, gdt},
|
arch::{drivers::vga::WRITER, gdt},
|
||||||
kernel_state::KERNEL_STATE,
|
kernel_state::KERNEL_STATE,
|
||||||
print, println, KEYBUFF,
|
print, println,
|
||||||
|
rhai_shell::KEYBUFF,
|
||||||
};
|
};
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
|
|
@ -1,20 +1,7 @@
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
pub fn rhai_shell() {
|
pub fn rhai_shell() {
|
||||||
let mut engine = rhai::Engine::new();
|
let engine = engine_construction();
|
||||||
|
|
||||||
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 mut scope = rhai::Scope::new();
|
let mut scope = rhai::Scope::new();
|
||||||
|
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
|
@ -46,6 +33,7 @@ lazy_static::lazy_static!(
|
||||||
);
|
);
|
||||||
|
|
||||||
use alloc::string::{String, ToString};
|
use alloc::string::{String, ToString};
|
||||||
|
use rhai::Engine;
|
||||||
use x86_64::instructions::interrupts::{disable, enable};
|
use x86_64::instructions::interrupts::{disable, enable};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -74,3 +62,20 @@ pub fn set_hostname(name: String) {
|
||||||
let mut kstate = KERNEL_STATE.lock();
|
let mut kstate = KERNEL_STATE.lock();
|
||||||
kstate.hostname = name;
|
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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue