This commit is contained in:
2025-02-18 01:39:26 +00:00
parent 65b0367487
commit ebab50f2c1
24 changed files with 184 additions and 90 deletions
+2 -1
View File
@@ -2,6 +2,7 @@ use core::fmt;
use alloc::{boxed::Box, format, string::String, vec::Vec};
use alloc::string::ToString;
use alloc::borrow::ToOwned;
use crate::std::render::Window;
use crate::{println, print, mknode, std, serial_println};
use async_trait::async_trait;
@@ -361,7 +362,7 @@ impl Application for Calculator {
Self {}
}
async fn run(&mut self, args: Vec<String>) -> Result<(), ShellError> {
async fn run(&mut self, window: Option<Window>, args: Vec<String>) -> Result<(), ShellError> {
if args.len() == 0 {
loop {
print!("enter equation > ");
+2 -2
View File
@@ -1,7 +1,7 @@
use crate::{serial_println, std};
use crate::std::application::{self, Application};
use crate::std::io::{Color, ColorCode, Display, KeyStroke};
use crate::std::render::{ColouredChar, Frame, Position, RenderError};
use crate::std::render::{ColouredChar, Frame, Position, RenderError, Window};
use crate::user::lib::libgui::cg_core::CgComponent;
@@ -169,7 +169,7 @@ impl Application for Editor {
}
}
async fn run(&mut self, _args: Vec<String>) -> Result<(), application::Error> {
async fn run(&mut self, window: Option<Window>, _args: Vec<String>) -> Result<(), application::Error> {
// if let Some(s) = args.get(0) {
// self.buffer = s.lines().map(|l| l.chars().collect()).collect::<Vec<Vec<char>>>()
+2 -2
View File
@@ -5,7 +5,7 @@ use alloc::boxed::Box;
use core::any::Any;
use async_trait::async_trait;
use crate::std::application::{Application, Error};
use crate::std::render::{Frame, Position, Dimensions, ColouredChar, RenderError};
use crate::std::render::{ColouredChar, Dimensions, Frame, Position, RenderError, Window};
use crate::std::io::{Display, KeyStroke, Stdin};
use crate::user::lib::libgui::{
@@ -49,7 +49,7 @@ impl Application for Grapher {
frame: Frame::new(Position::new(1, 1), Dimensions::new(78, 22)).unwrap()
}
}
async fn run(&mut self, args: Vec<String>) -> Result<(), Error> {
async fn run(&mut self, window: Option<Window>, args: Vec<String>) -> Result<(), Error> {
let _d = Display::borrow();
self.frame.frame = vec![vec![ColouredChar::new(' '); self.frame.dimensions.x]; self.frame.dimensions.y];
+2 -1
View File
@@ -1,4 +1,5 @@
pub mod calc;
pub mod editor;
pub mod grapher;
pub mod tasks;
pub mod tasks;
pub mod zxqsh;
+2 -1
View File
@@ -4,6 +4,7 @@ use crate::std::application::{
Error
};
use crate::println;
use crate::std::render::Window;
use lazy_static::lazy_static;
use spin::Mutex;
use async_trait::async_trait;
@@ -27,7 +28,7 @@ pub struct Tasks;
impl Application for Tasks {
fn new() -> Self { Self {} }
async fn run(&mut self, args: Vec<String>) -> Result<(), Error> {
async fn run(&mut self, window: Option<Window>, args: Vec<String>) -> Result<(), Error> {
if args[0].clone() == String::from("add") {
+50
View File
@@ -0,0 +1,50 @@
use alloc::{string::String, vec::Vec, boxed::Box};
use crate::std::{application::{Application, Error}, render::Window};
use async_trait::async_trait;
pub struct ZxqSH {
history: Vec<String>,
idx: u32,
window: Window,
}
#[async_trait]
impl Application for ZxqSH {
fn new() -> Self {
todo!()
}
async fn run(&mut self, window: Option<Window>, _args: Vec<String>) -> Result<(), Error> {
loop {
if let Ok(exit) = self.next().await {
if exit { return Ok(()) }
}
}
}
}
impl ZxqSH {
async fn next(&mut self) -> Result<bool, Error> {
// update cycle for the shell
// TOOD: prompt
// TODO: exit if necessar
// TODO: execute command
// return
Ok(false)
}
async fn execute(&self, command: String) -> Result<(), Error> {
Ok(())
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
use crate::std::application::Error;
use crate::std::application::Error::ApplicationError;
use crate::std::render::{ColouredChar, Dimensions, Frame, Position, RenderError};
use crate::std::render::{ColouredChar, Dimensions, Frame, Position, RenderError, Window};
use crate::std::io::{Color, ColorCode, Display, KeyStroke, Stdin};
use crate::std::random::Random;
use crate::system::std::application::Application;
@@ -52,7 +52,7 @@ impl Application for Game {
timer: GameTimer::new(),
}
}
async fn run(&mut self, _args: Vec<String>) -> Result<(), Error> {
async fn run(&mut self, window: Option<Window>, _args: Vec<String>) -> Result<(), Error> {
let _d = Display::borrow();
let mut container_data =
+2 -2
View File
@@ -1,7 +1,7 @@
use alloc::{string::String, vec::Vec, boxed::Box};
use async_trait::async_trait;
use crate::{std::{application::{Application, Error}, io::{Color, Display, KeyStroke, Stdin}, random::Random, render::{ColorCode, ColouredChar, Dimensions, Frame, Position, RenderError}, time}, user::lib::libgui::cg_core::CgComponent};
use crate::{std::{application::{Application, Error}, io::{Color, Display, KeyStroke, Stdin}, random::Random, render::{ColorCode, ColouredChar, Dimensions, Frame, Position, RenderError, Window}, time}, user::lib::libgui::cg_core::CgComponent};
pub struct Game {
pub board: [[Cell; 7]; 6],
@@ -31,7 +31,7 @@ impl Application for Game {
}
}
async fn run(&mut self, _: Vec<String>) -> Result<(), Error> {
async fn run(&mut self, window: Option<Window>, _: Vec<String>) -> Result<(), Error> {
let _display = Display::borrow();
self.get_next_mode().await;
+2 -2
View File
@@ -4,7 +4,7 @@ use alloc::vec::Vec;
use alloc::boxed::Box;
use crate::std::application::{Application, Error};
use async_trait::async_trait;
use crate::std::render::{ColouredChar, Frame, Position, Dimensions, RenderError};
use crate::std::render::{ColouredChar, Dimensions, Frame, Position, RenderError, Window};
use crate::std::io::{KeyStroke, Stdin, Color, ColorCode, Display};
use crate::std::time::wait;
@@ -21,7 +21,7 @@ impl Application for GameOfLife {
frame: Frame::new(Position::new(0, 0), Dimensions::new(80, 25)).unwrap()
}
}
async fn run(&mut self, _args: Vec<String>) -> Result<(), Error> {
async fn run(&mut self, window: Option<Window>, _args: Vec<String>) -> Result<(), Error> {
// setup:
let _d = Display::borrow();
+2 -2
View File
@@ -8,7 +8,7 @@ use crate::{
self,
application::{Application, Error},
io::{Color, ColorCode, Display, KeyStroke, Stdin},
render::{ColouredChar, Dimensions, Frame, Position, RenderError},
render::{ColouredChar, Dimensions, Frame, Position, RenderError, Window},
time
},
user::lib::libgui::cg_core::CgComponent
@@ -49,7 +49,7 @@ impl Application for GameBoard {
}
}
async fn run(&mut self, _args: Vec<String>) -> Result<(), Error> {
async fn run(&mut self, window: Option<Window>, _args: Vec<String>) -> Result<(), Error> {
let _display = Display::borrow();
'outer: loop {
+2 -2
View File
@@ -4,7 +4,7 @@ use alloc::vec::Vec;
use core::any::Any;
use async_trait::async_trait;
use crate::std::application::{Application, Error};
use crate::std::render::{BUFFER_HEIGHT, BUFFER_WIDTH, ColorCode, ColouredChar, Dimensions, Frame, Position, RenderError};
use crate::std::render::{ColorCode, ColouredChar, Dimensions, Frame, Position, RenderError, Window, BUFFER_HEIGHT, BUFFER_WIDTH};
use crate::std::io::{Color, Display, KeyStroke, Stdin};
use crate::std::time::Timer;
use crate::user::lib::libgui::cg_core::CgComponent;
@@ -25,7 +25,7 @@ impl Application for Game {
}
}
async fn run(&mut self, _: Vec<String>) -> Result<(), Error> {
async fn run(&mut self, window: Option<Window>, _: Vec<String>) -> Result<(), Error> {
let _d = Display::borrow();
let mut update_time = Timer::new(0.1);
+2 -2
View File
@@ -4,7 +4,7 @@ use async_trait::async_trait;
use crate::std::io::{Color, Display, KeyStroke, Stdin};
use crate::std::time;
use crate::std::application::{Application, Error};
use crate::std::render::{ColouredChar, Dimensions, Frame, RenderError, ColorCode};
use crate::std::render::{ColorCode, ColouredChar, Dimensions, Frame, RenderError, Window};
use crate::std::random::Random;
use crate::system::std::render;
use super::super::super::lib::geometry::{Position, Direction};
@@ -45,7 +45,7 @@ impl Application for Game {
}
}
async fn run(&mut self, args: Vec<String>) -> Result<(), Error> {
async fn run(&mut self, window: Option<Window>, args: Vec<String>) -> Result<(), Error> {
let _settings = [0, 0, 0]; // ai_count, snake_len, poi_count
+24 -23
View File
@@ -18,15 +18,9 @@ use crate::{
printerr,
println,
std::{
application::{Application, Error, Exit},
time::{timer},
io::{Color, write, Screen, Stdin, Serial, KeyStroke, Display},
application::{Application, Error, Exit}, io::{write, Color, Display, KeyStroke, Serial, Stdin}, render::Window, time::timer
},
user::{
lib::libgui::{
cg_core::{CgComponent, CgKeyboardCapture},
cg_widgets::CgDialog,
},
bin::{
apps::{
calc::Calculator,
@@ -48,7 +42,10 @@ use crate::{
gigachad_detector::GigachadDetector,
rickroll::Rickroll,
},
},
}, lib::libgui::{
cg_core::{CgComponent, CgKeyboardCapture},
cg_widgets::CgDialog,
}
},
};
@@ -67,11 +64,13 @@ pub async fn command_handler() {
pub async fn eventloop() {
println!("running!");
let window = Window::new();
let mut fetch = CrystalFetch::new();
let string = String::from(" ");
let mut vec: Vec<String> = Vec::new();
vec.push(string);
fetch.run(vec).await.unwrap();
fetch.run(Some(window), vec).await.unwrap();
CMD.lock().prompt();
@@ -122,29 +121,31 @@ async fn exec() -> Result<(), Error> {
}
};
let window = Window::new();
match cmd.as_str() {
"calculate" | "calc" | "solve" => {
let mut cmd = Calculator::new();
cmd.run(args).await?;
cmd.run(Some(window), args).await?;
}
"games/connect4" => {
let mut cmd = Connect4Game::new();
cmd.run(args).await?;
cmd.run(Some(window), args).await?;
}
"rickroll" => {
let mut cmd = Rickroll::new();
cmd.run(args).await?;
cmd.run(Some(window), args).await?;
}
"crystalfetch" => {
let mut cmd = CrystalFetch::new();
cmd.run(args).await?;
cmd.run(Some(window), args).await?;
}
"tasks" => {
let mut cmd = Tasks::new();
cmd.run(args).await?;
cmd.run(Some(window), args).await?;
}
"VGA" => {
use vga::colors::Color16;
@@ -156,21 +157,21 @@ async fn exec() -> Result<(), Error> {
mode.draw_line((80, 60), (120, 420), Color16::Cyan);
}
"graph" => {
Grapher::new().run(args).await?;
Grapher::new().run(Some(window), args).await?;
}
"games/snake" => {
SnakeGame::new().run(args).await?;
SnakeGame::new().run(Some(window), args).await?;
}
"games/asteroids" => {
let mut asteroid_game = AsteroidsGame::new();
asteroid_game.run(args).await?;
asteroid_game.run(Some(window), args).await?;
}
"games/pong" => {
PongGame::new().run(args).await?;
PongGame::new().run(Some(window), args).await?;
}
"games/paper.rs" => {
let mut game = GameBoard::new();
game.run(args).await?;
game.run(Some(window), args).await?;
}
"serial" => {
let c = Serial::reply_char('e');
@@ -178,7 +179,7 @@ async fn exec() -> Result<(), Error> {
}
"games/gameoflife" => {
let mut game = GameOfLife::new();
game.run(Vec::new()).await?;
game.run(Some(window), Vec::new()).await?;
}
"games/tetris" => {
// let mut game = TetrisEngine::new();
@@ -187,12 +188,12 @@ async fn exec() -> Result<(), Error> {
"gigachad?" => {
let mut detector = GigachadDetector::new();
detector.run(args).await?;
detector.run(Some(window), args).await?;
}
"editor" => {
let mut editor = Editor::new();
editor.run(args).await?;
editor.run(Some(window), args).await?;
}
// direct OS functions (not applications)
@@ -208,7 +209,7 @@ async fn exec() -> Result<(), Error> {
)
}
"clear" => {
Screen::clear();
Display::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(|| {});
}
+6 -5
View File
@@ -2,9 +2,7 @@ use async_trait::async_trait;
use alloc::{boxed::Box, format, string::String, vec::Vec};
use crate::std::{
os::OS,
io::{Color, write, Screen},
application::{Application, Error},
application::{Application, Error}, io::{write, Color, Display}, os::OS, render::Window
};
use crate::println;
@@ -55,12 +53,15 @@ impl Application for CrystalFetch {
Self {}
}
async fn run(&mut self, _args: Vec<String>) -> Result<(), Error> {
async fn run(&mut self, window: Option<Window>, _args: Vec<String>) -> Result<(), Error> {
let ds = Display::borrow();
let os = OS.lock().os.clone();
let version = OS.lock().version.clone();
Screen::clear();
// clear screen
Display::clear();
let logo_string = ZXQ5_LOGO;
let info_string = format!(
+3 -3
View File
@@ -3,10 +3,10 @@ use alloc::{boxed::Box, string::String, vec::Vec};
use crate::{
println,
std::application::{
std::{application::{
Application,
Error,
},
}, render::Window},
};
const GIGACHAD: [&'static str; 3] = ["fantasypvp", "zxq5", "ZXQ5"];
@@ -19,7 +19,7 @@ impl Application for GigachadDetector {
Self {}
}
async fn run(&mut self, args: Vec<String>) -> Result<(), Error> {
async fn run(&mut self, window: Option<Window>, args: Vec<String>) -> Result<(), Error> {
for arg in args {
self.detect_gigachad_by_username(&arg)
}
+2 -1
View File
@@ -44,6 +44,7 @@ const RICKROLL2: &str = "
`--'";
use crate::println;
use crate::std::render::Window;
use alloc::{string::String, boxed::Box, vec::Vec};
@@ -55,7 +56,7 @@ impl Application for Rickroll {
Self {}
}
async fn run(&mut self, _args: Vec<String>) -> Result<(), Error> {
async fn run(&mut self, window: Option<Window>, _args: Vec<String>) -> Result<(), Error> {
println!("{}", RICKROLL2);
Ok(())
}