Add backspace functionality (without displaying) and echo command
This commit is contained in:
parent
6f09d16593
commit
71713b5e40
|
@ -1,9 +1,10 @@
|
|||
use conquer_once::spin::OnceCell;
|
||||
use crossbeam_queue::ArrayQueue;
|
||||
use crate::println;
|
||||
use crate::serial_print;
|
||||
use crate::{serial_print, serial_println};
|
||||
use alloc::string::String;
|
||||
use crate::alloc::string::ToString;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use pc_keyboard::KeyCode;
|
||||
|
||||
|
@ -95,15 +96,21 @@ pub async fn return_keychar() {
|
|||
if let Some(key) = keyboard.process_keyevent(key_event) {
|
||||
match key {
|
||||
DecodedKey::Unicode(character) => (
|
||||
if scancode == 28 { // 28 is keycode for Enter key
|
||||
match scancode {
|
||||
28 => { // 28 is keycode for Enter key
|
||||
println!();
|
||||
command_func(command);
|
||||
command = "".to_string();
|
||||
print!("> ");
|
||||
} else {
|
||||
}
|
||||
14 => { // 14 is keycode for Backspace key
|
||||
command.pop();
|
||||
}
|
||||
scancode => {
|
||||
print!("{}", character);
|
||||
command.push(character);
|
||||
}
|
||||
}
|
||||
),
|
||||
DecodedKey::RawKey(key) => serial_print!("{:?}", key),
|
||||
};
|
||||
|
@ -112,7 +119,18 @@ pub async fn return_keychar() {
|
|||
}
|
||||
}
|
||||
|
||||
fn command_func(command: String) {
|
||||
fn command_func(input_command: String) {
|
||||
let mut command = String::new();
|
||||
let mut args = String::new();
|
||||
let mut command_vec: Vec<&str> = input_command.split(" ").collect();
|
||||
command = command_vec[0].to_string();
|
||||
command_vec.remove(0);
|
||||
for i in command_vec {
|
||||
for j in i.chars() {
|
||||
args.push(j);
|
||||
}
|
||||
args.push(' ');
|
||||
}
|
||||
match command.as_str() {
|
||||
"hi" => {
|
||||
println!("hello command!!!");
|
||||
|
@ -120,6 +138,9 @@ fn command_func(command: String) {
|
|||
"wow" => {
|
||||
println!("wow!!");
|
||||
}
|
||||
"echo" => {
|
||||
println!("{} ", args);
|
||||
}
|
||||
command => {
|
||||
println!("{}: command not found", command);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue