idk
idk
This commit is contained in:
Generated
+10
@@ -11,6 +11,7 @@ dependencies = [
|
|||||||
"bootloader",
|
"bootloader",
|
||||||
"cmos-rtc",
|
"cmos-rtc",
|
||||||
"conquer-once",
|
"conquer-once",
|
||||||
|
"crossbeam-channel",
|
||||||
"crossbeam-queue",
|
"crossbeam-queue",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
@@ -131,6 +132,15 @@ version = "0.3.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e763eef8846b13b380f37dfecda401770b0ca4e56e95170237bd7c25c7db3582"
|
checksum = "e763eef8846b13b380f37dfecda401770b0ca4e56e95170237bd7c25c7db3582"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-channel"
|
||||||
|
version = "0.5.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 1.0.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-queue"
|
name = "crossbeam-queue"
|
||||||
version = "0.2.3"
|
version = "0.2.3"
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ version = "0.2.1"
|
|||||||
default-features = false
|
default-features = false
|
||||||
features = ["alloc"]
|
features = ["alloc"]
|
||||||
|
|
||||||
|
[dependencies.crossbeam-channel]
|
||||||
|
version = "0.5.8"
|
||||||
|
default-features = false
|
||||||
|
|
||||||
[dependencies.conquer-once]
|
[dependencies.conquer-once]
|
||||||
version = "0.3.2"
|
version = "0.3.2"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ lazy_static! {
|
|||||||
buffer: unsafe { &mut *(0xb8000 as *mut Buffer) },
|
buffer: unsafe { &mut *(0xb8000 as *mut Buffer) },
|
||||||
userspace: BufferSwap {
|
userspace: BufferSwap {
|
||||||
chars: [[ScreenChar {
|
chars: [[ScreenChar {
|
||||||
character: 179u8,
|
character: 178u8,
|
||||||
colour: ColorCode::new(Color::White, Color::Black),
|
colour: ColorCode::new(Color::White, Color::Black),
|
||||||
}; BUFFER_WIDTH]; BUFFER_HEIGHT]
|
}; BUFFER_WIDTH]; BUFFER_HEIGHT]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -20,26 +20,6 @@ static WAKER: AtomicWaker = AtomicWaker::new();
|
|||||||
static SCANCODE_QUEUE: OnceCell<ArrayQueue<u8>> = OnceCell::uninit();
|
static SCANCODE_QUEUE: OnceCell<ArrayQueue<u8>> = OnceCell::uninit();
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
pub async fn print_keypresses() {
|
|
||||||
let mut scancodes = ScanCodeStream::new();
|
|
||||||
let mut keyboard = Keyboard::new(layouts::Uk105Key, ScancodeSet1, HandleControl::Ignore);
|
|
||||||
while let Some(scancode) = scancodes.next().await {
|
|
||||||
if let Ok(Some(key_event)) = keyboard.add_byte(scancode) {
|
|
||||||
if let Some(key) = keyboard.process_keyevent(key_event) {
|
|
||||||
match key {
|
|
||||||
DecodedKey::Unicode(character) => {
|
|
||||||
let mut cmd = CMD.lock();
|
|
||||||
cmd.input(character).await;
|
|
||||||
}
|
|
||||||
DecodedKey::RawKey(key) => print!("{:?}", key),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref KEYBOARD: Mutex<KeyboardHandler> = Mutex::new(KeyboardHandler::new());
|
pub static ref KEYBOARD: Mutex<KeyboardHandler> = Mutex::new(KeyboardHandler::new());
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-22
@@ -11,40 +11,55 @@ pub use crate::{print, println, serial_print, serial_println};
|
|||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use spin::Mutex;
|
use spin::Mutex;
|
||||||
|
|
||||||
pub async fn stdin() -> String {
|
pub struct Stdin {}
|
||||||
|
impl Stdin {
|
||||||
|
pub async fn readline() -> String {
|
||||||
let string = KEYBOARD.lock().get_string().await;
|
let string = KEYBOARD.lock().get_string().await;
|
||||||
string
|
string
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn stdchar() -> char {
|
pub async fn keystroke() -> char {
|
||||||
let chr = KEYBOARD.lock().get_keystroke().await;
|
let chr = KEYBOARD.lock().get_keystroke().await;
|
||||||
chr
|
chr
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn text_mode() {
|
pub struct Screen {}
|
||||||
|
impl Screen {
|
||||||
|
pub fn terminal_mode() {
|
||||||
RENDERER.lock().text_mode().unwrap();
|
RENDERER.lock().text_mode().unwrap();
|
||||||
}
|
}
|
||||||
|
pub fn application_mode() {
|
||||||
pub fn sandbox_mode() {
|
|
||||||
RENDERER.lock().sandbox_mode().unwrap();
|
RENDERER.lock().sandbox_mode().unwrap();
|
||||||
}
|
}
|
||||||
|
pub fn switch() {
|
||||||
pub fn switch_mode() {
|
|
||||||
if RENDERER.lock().sandbox == true {
|
if RENDERER.lock().sandbox == true {
|
||||||
RENDERER.lock().text_mode().unwrap();
|
RENDERER.lock().text_mode().unwrap();
|
||||||
} else {
|
} else {
|
||||||
RENDERER.lock().sandbox_mode().unwrap();
|
RENDERER.lock().sandbox_mode().unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clear() {
|
pub fn clear() {
|
||||||
RENDERER.lock().clear();
|
RENDERER.lock().clear();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// TODO: get a working implementation for CLI apps
|
||||||
|
/// elements can be created using their from_str() method
|
||||||
|
/// you can then render the element to the current frame using the render() method
|
||||||
|
/// the position of the element by passing a tuple (x,y) to render()
|
||||||
|
///
|
||||||
|
/// nothing will appear on the screen until the frame is actually rendered by
|
||||||
|
/// the render_frame method on the renderer
|
||||||
|
///
|
||||||
pub type Frame = [ [ char; BUFFER_WIDTH ]; BUFFER_HEIGHT];
|
pub type Frame = [ [ char; BUFFER_WIDTH ]; BUFFER_HEIGHT];
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@@ -53,13 +68,6 @@ pub struct Element {
|
|||||||
dimensions: (u8, u8)
|
dimensions: (u8, u8)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// elements can be created using their from_str() method
|
|
||||||
/// you can then render the element to the current frame using the render() method
|
|
||||||
/// the position of the element by passing a tuple (x,y) to render()
|
|
||||||
///
|
|
||||||
/// nothing will appear on the screen until the frame is actually rendered by
|
|
||||||
/// the render_frame method on the renderer
|
|
||||||
|
|
||||||
impl Element {
|
impl Element {
|
||||||
pub fn from_str(elemstr: String) -> Self {
|
pub fn from_str(elemstr: String) -> Self {
|
||||||
let mut element = Element { frame: Vec::<Vec<char>>::new(), dimensions: (0, 0) };
|
let mut element = Element { frame: Vec::<Vec<char>>::new(), dimensions: (0, 0) };
|
||||||
@@ -143,8 +151,6 @@ impl core::fmt::Display for FrameGen {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! println_log {
|
macro_rules! println_log {
|
||||||
() => ($crate::print_log!("/n"));
|
() => ($crate::print_log!("/n"));
|
||||||
@@ -156,7 +162,6 @@ macro_rules! print_log {
|
|||||||
($($arg:tt)*) => ($crate::std::io::_log(format_args!($($arg)*)));
|
($($arg:tt)*) => ($crate::std::io::_log(format_args!($($arg)*)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! println {
|
macro_rules! println {
|
||||||
() => ($crate::print!("/n"));
|
() => ($crate::print!("/n"));
|
||||||
@@ -170,7 +175,6 @@ macro_rules! print {
|
|||||||
|
|
||||||
pub use crate::kernel::render::Color;
|
pub use crate::kernel::render::Color;
|
||||||
|
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub fn _print(args: core::fmt::Arguments) {
|
pub fn _print(args: core::fmt::Arguments) {
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
@@ -203,9 +207,6 @@ pub fn write(args: core::fmt::Arguments, cols: (Color, Color)) {
|
|||||||
crate::kernel::render::write(args, cols);
|
crate::kernel::render::write(args, cols);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pub fn mkfs() {
|
pub fn mkfs() {
|
||||||
use crate::kernel::fs;
|
use crate::kernel::fs;
|
||||||
fs::mkfs();
|
fs::mkfs();
|
||||||
|
|||||||
@@ -380,7 +380,7 @@ impl Application for Calculator {
|
|||||||
if args.len() == 0 {
|
if args.len() == 0 {
|
||||||
loop {
|
loop {
|
||||||
print!("enter equation > ");
|
print!("enter equation > ");
|
||||||
let inp = std::io::stdin().await;
|
let inp = std::io::Stdin::readline().await;
|
||||||
println!("{}", inp);
|
println!("{}", inp);
|
||||||
if inp == String::from("exit\n") {
|
if inp == String::from("exit\n") {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ impl Application for GameLoop {
|
|||||||
}
|
}
|
||||||
async fn run(&mut self, _args: Vec<String>) -> Result<(), Error> {
|
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();
|
username = username.trim().to_string();
|
||||||
|
|
||||||
let mut player = Player::new(username);
|
let mut player = Player::new(username);
|
||||||
@@ -101,7 +101,7 @@ impl Application for GameLoop {
|
|||||||
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
println!("{}", io::stdchar().await)
|
println!("{}", io::Stdin::keystroke().await)
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use async_trait::async_trait;
|
|||||||
use alloc::{boxed::Box, format, string::String, vec::Vec};
|
use alloc::{boxed::Box, format, string::String, vec::Vec};
|
||||||
use log::info;
|
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,
|
Application,
|
||||||
Error,
|
Error,
|
||||||
}, std};
|
}, std};
|
||||||
@@ -39,7 +39,6 @@ pub struct CrystalFetch {}
|
|||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Application for CrystalFetch {
|
impl Application for CrystalFetch {
|
||||||
|
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Self {}
|
Self {}
|
||||||
}
|
}
|
||||||
@@ -49,7 +48,7 @@ impl Application for CrystalFetch {
|
|||||||
let os = OS.lock().os.clone();
|
let os = OS.lock().os.clone();
|
||||||
let version = OS.lock().version.clone();
|
let version = OS.lock().version.clone();
|
||||||
|
|
||||||
clear();
|
Screen::clear();
|
||||||
|
|
||||||
let logo_string = CRYSTAL_LOGO;
|
let logo_string = CRYSTAL_LOGO;
|
||||||
let info_string = format!(
|
let info_string = format!(
|
||||||
@@ -59,15 +58,14 @@ impl Application for CrystalFetch {
|
|||||||
[ Github » https://github.com/FantasyPvP/CrystalOS-Restructured
|
[ Github » https://github.com/FantasyPvP/CrystalOS-Restructured
|
||||||
[ Author » FantasyPvP / ZXQ5", os, version);
|
[ Author » FantasyPvP / ZXQ5", os, version);
|
||||||
|
|
||||||
|
// write to output
|
||||||
let spacer = "\n".repeat(24 - logo_string.lines().count() - 4 - info_string.lines().count());
|
let spacer = "\n".repeat(24 - logo_string.lines().count() - 4 - info_string.lines().count());
|
||||||
|
|
||||||
// write values to console
|
// write values to console
|
||||||
write(format_args!("{}", logo_string), (Color::Cyan, Color::Black));
|
write(format_args!("{}", logo_string), (Color::Cyan, Color::Black));
|
||||||
println!("\n\n");
|
println!("\n\n");
|
||||||
println!("{}", info_string);
|
println!("{}", info_string);
|
||||||
println!("{}", spacer);
|
println!("{}", spacer);
|
||||||
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,3 +6,4 @@ pub mod shell;
|
|||||||
//pub mod shellrewrite;
|
//pub mod shellrewrite;
|
||||||
pub mod tasks;
|
pub mod tasks;
|
||||||
mod gigachad_detector;
|
mod gigachad_detector;
|
||||||
|
mod shellrewrite;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use crate::{
|
|||||||
std::application::{Application, Error},
|
std::application::{Application, Error},
|
||||||
user::bin::*,
|
user::bin::*,
|
||||||
};
|
};
|
||||||
use crate::std::io::{Color, write};
|
use crate::std::io::{Color, write, Screen};
|
||||||
use crate::user::bin::gigachad_detector::GigachadDetector;
|
use crate::user::bin::gigachad_detector::GigachadDetector;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
@@ -41,7 +41,7 @@ pub async fn eventloop() {
|
|||||||
CMD.lock().prompt();
|
CMD.lock().prompt();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let string = crate::std::io::stdin().await;
|
let string = crate::std::io::Stdin::readline().await;
|
||||||
CMD.lock().current.push_str(&string);
|
CMD.lock().current.push_str(&string);
|
||||||
match exec().await {
|
match exec().await {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
@@ -112,9 +112,9 @@ async fn exec() -> Result<(), Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
"clear" => {
|
"clear" => {
|
||||||
interrupts::without_interrupts(|| {
|
Screen::clear();
|
||||||
crate::std::io::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" => {
|
"print" => {
|
||||||
@@ -123,7 +123,7 @@ async fn exec() -> Result<(), Error> {
|
|||||||
println!("{}", x);
|
println!("{}", x);
|
||||||
}
|
}
|
||||||
"switch" => {
|
"switch" => {
|
||||||
crate::std::io::switch_mode();
|
Screen::switch();
|
||||||
}
|
}
|
||||||
"gigachad?" => {
|
"gigachad?" => {
|
||||||
let mut gigachad_detector = GigachadDetector::new();
|
let mut gigachad_detector = GigachadDetector::new();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use alloc::{
|
|||||||
use crate::{
|
use crate::{
|
||||||
kernel::tasks::{executor::Executor, Task},
|
kernel::tasks::{executor::Executor, Task},
|
||||||
std::application::{Application, Error},
|
std::application::{Application, Error},
|
||||||
std::io::{print, println, stdin},
|
std::io::{print, println, Stdin, Screen},
|
||||||
user::bin::*,
|
user::bin::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -30,33 +30,40 @@ use super::*;
|
|||||||
// - chained execution ( multiple commands linked together) eg: '5 + 5 | echo' which calculates
|
// - 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
|
// 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
|
/// starts the shell
|
||||||
/// this function should be directly called by main.rs or by an init system
|
/// 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();
|
let mut executor = Executor::new();
|
||||||
|
|
||||||
loop {
|
//
|
||||||
executor.spawn(Task::new(next()));
|
// executor.spawn(Task::new(new_function()));
|
||||||
|
// loop {
|
||||||
let tasks = TASKS.lock();
|
// executor.try_run()
|
||||||
while tasks.len() > 0 {
|
// }
|
||||||
let next = tasks[0].clone();
|
|
||||||
tasks.remove(0);
|
|
||||||
executor.spawn(next);
|
|
||||||
}
|
|
||||||
drop(tasks);
|
|
||||||
|
|
||||||
executor.try_run();
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
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> {
|
fn parse_args(command: String) -> Result<(String, Vec<String>), String> {
|
||||||
let mut args: Vec<String> = Vec::new();
|
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()>)
|
// 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