idk
idk
This commit is contained in:
@@ -380,7 +380,7 @@ impl Application for Calculator {
|
||||
if args.len() == 0 {
|
||||
loop {
|
||||
print!("enter equation > ");
|
||||
let inp = std::io::stdin().await;
|
||||
let inp = std::io::Stdin::readline().await;
|
||||
println!("{}", inp);
|
||||
if inp == String::from("exit\n") {
|
||||
return Ok(());
|
||||
|
||||
@@ -31,7 +31,7 @@ impl Application for GameLoop {
|
||||
}
|
||||
async fn run(&mut self, _args: Vec<String>) -> Result<(), Error> {
|
||||
|
||||
let mut username: String = io::stdin().await;
|
||||
let mut username: String = io::Stdin::readline().await;
|
||||
username = username.trim().to_string();
|
||||
|
||||
let mut player = Player::new(username);
|
||||
@@ -101,7 +101,7 @@ impl Application for GameLoop {
|
||||
|
||||
|
||||
loop {
|
||||
println!("{}", io::stdchar().await)
|
||||
println!("{}", io::Stdin::keystroke().await)
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -2,7 +2,7 @@ use async_trait::async_trait;
|
||||
use alloc::{boxed::Box, format, string::String, vec::Vec};
|
||||
use log::info;
|
||||
|
||||
use crate::{std::os::OS, std::io::{Color, write, clear}, println, std::application::{
|
||||
use crate::{std::os::OS, std::io::{Color, write, Screen}, println, std::application::{
|
||||
Application,
|
||||
Error,
|
||||
}, std};
|
||||
@@ -39,7 +39,6 @@ pub struct CrystalFetch {}
|
||||
|
||||
#[async_trait]
|
||||
impl Application for CrystalFetch {
|
||||
|
||||
fn new() -> Self {
|
||||
Self {}
|
||||
}
|
||||
@@ -49,7 +48,7 @@ impl Application for CrystalFetch {
|
||||
let os = OS.lock().os.clone();
|
||||
let version = OS.lock().version.clone();
|
||||
|
||||
clear();
|
||||
Screen::clear();
|
||||
|
||||
let logo_string = CRYSTAL_LOGO;
|
||||
let info_string = format!(
|
||||
@@ -59,15 +58,14 @@ impl Application for CrystalFetch {
|
||||
[ Github » https://github.com/FantasyPvP/CrystalOS-Restructured
|
||||
[ Author » FantasyPvP / ZXQ5", os, version);
|
||||
|
||||
// write to output
|
||||
let spacer = "\n".repeat(24 - logo_string.lines().count() - 4 - info_string.lines().count());
|
||||
|
||||
// write values to console
|
||||
write(format_args!("{}", logo_string), (Color::Cyan, Color::Black));
|
||||
println!("\n\n");
|
||||
println!("{}", info_string);
|
||||
println!("{}", spacer);
|
||||
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -6,3 +6,4 @@ pub mod shell;
|
||||
//pub mod shellrewrite;
|
||||
pub mod tasks;
|
||||
mod gigachad_detector;
|
||||
mod shellrewrite;
|
||||
|
||||
@@ -14,7 +14,7 @@ use crate::{
|
||||
std::application::{Application, Error},
|
||||
user::bin::*,
|
||||
};
|
||||
use crate::std::io::{Color, write};
|
||||
use crate::std::io::{Color, write, Screen};
|
||||
use crate::user::bin::gigachad_detector::GigachadDetector;
|
||||
|
||||
lazy_static! {
|
||||
@@ -41,7 +41,7 @@ pub async fn eventloop() {
|
||||
CMD.lock().prompt();
|
||||
|
||||
loop {
|
||||
let string = crate::std::io::stdin().await;
|
||||
let string = crate::std::io::Stdin::readline().await;
|
||||
CMD.lock().current.push_str(&string);
|
||||
match exec().await {
|
||||
Ok(_) => {
|
||||
@@ -112,9 +112,9 @@ async fn exec() -> Result<(), Error> {
|
||||
}
|
||||
|
||||
"clear" => {
|
||||
interrupts::without_interrupts(|| {
|
||||
crate::std::io::clear();
|
||||
});
|
||||
Screen::clear();
|
||||
// not sure why this code was here but leaving it in case weird bugs happen so i remember to add it back if so
|
||||
//interrupts::without_interrupts(|| {});
|
||||
}
|
||||
|
||||
"print" => {
|
||||
@@ -123,7 +123,7 @@ async fn exec() -> Result<(), Error> {
|
||||
println!("{}", x);
|
||||
}
|
||||
"switch" => {
|
||||
crate::std::io::switch_mode();
|
||||
Screen::switch();
|
||||
}
|
||||
"gigachad?" => {
|
||||
let mut gigachad_detector = GigachadDetector::new();
|
||||
|
||||
@@ -13,7 +13,7 @@ use alloc::{
|
||||
use crate::{
|
||||
kernel::tasks::{executor::Executor, Task},
|
||||
std::application::{Application, Error},
|
||||
std::io::{print, println, stdin},
|
||||
std::io::{print, println, Stdin, Screen},
|
||||
user::bin::*,
|
||||
};
|
||||
|
||||
@@ -30,33 +30,40 @@ use super::*;
|
||||
// - chained execution ( multiple commands linked together) eg: '5 + 5 | echo' which calculates
|
||||
// the result of 5 + 5 and then sends the result to an echo command which prints it to console
|
||||
|
||||
/// initialises a global tasks struct, this can be accessed from anywhere in the program;
|
||||
lazy_static! {
|
||||
pub static ref TASKS: Mutex<Vec<Task>> = Mutex::new(Vec::new());
|
||||
}
|
||||
|
||||
/// starts the shell
|
||||
/// this function should be directly called by main.rs or by an init system
|
||||
pub fn init_sh(args: Option<Vec<String>>) -> Result<(), String> {
|
||||
|
||||
fn new_function() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
pub fn userspace() -> Result<(), String> {
|
||||
let mut executor = Executor::new();
|
||||
|
||||
loop {
|
||||
executor.spawn(Task::new(next()));
|
||||
|
||||
let tasks = TASKS.lock();
|
||||
while tasks.len() > 0 {
|
||||
let next = tasks[0].clone();
|
||||
tasks.remove(0);
|
||||
executor.spawn(next);
|
||||
}
|
||||
drop(tasks);
|
||||
|
||||
executor.try_run();
|
||||
}
|
||||
|
||||
//
|
||||
// executor.spawn(Task::new(new_function()));
|
||||
// loop {
|
||||
// executor.try_run()
|
||||
// }
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// struct Shell {}
|
||||
//
|
||||
// impl Application for Shell {
|
||||
// fn new() -> Shell {
|
||||
// Shell {}
|
||||
// }
|
||||
// async fn run(&mut self, _: Vec<String>) -> Result<(), Error> {
|
||||
// Ok(())
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
fn parse_args(command: String) -> Result<(String, Vec<String>), String> {
|
||||
let mut args: Vec<String> = Vec::new();
|
||||
|
||||
@@ -83,19 +90,3 @@ fn parse_args(command: String) -> Result<(String, Vec<String>), String> {
|
||||
// Ok(Vec::<String::new()>)
|
||||
//}
|
||||
|
||||
async fn next() {
|
||||
let command: String = stdin();
|
||||
let parsed = match parse_args(command) {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
println!("Error Parsing Command: Invalid Syntax")
|
||||
}
|
||||
};
|
||||
// tokens will eventually be parsed here
|
||||
|
||||
/*
|
||||
- PARSER
|
||||
- this will allow the use of more complex commands later down the line
|
||||
*/
|
||||
TASKS.lock().push(Task::new(parsed));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user