Merge remote-tracking branch 'origin/main'
# Conflicts: # rickroll.txt
This commit is contained in:
@@ -12,6 +12,25 @@ while I'm waiting for the third edition to release, I guess I'm gonna just have
|
|||||||
|
|
||||||
- for more details on this project read the wiki ^^^
|
- for more details on this project read the wiki ^^^
|
||||||
|
|
||||||
|
# Building
|
||||||
|
- this project unfortunately does not build on the latest rust versions and requires an older nightly build.
|
||||||
|
the version below (rust v1.68.0-nightly) works:
|
||||||
|
> rustup override set nightly-2023-01-01
|
||||||
|
(you may need to install this first)
|
||||||
|
> rustup install nightly-2023-01-01
|
||||||
|
- you will need the bare metal x86 target installed:
|
||||||
|
> rustup target add x86_64-unknown-none
|
||||||
|
- you will also need several extra rustup components to build the project
|
||||||
|
> rustup component add llvm-tools-preview
|
||||||
|
> rustup component add rust-src
|
||||||
|
(ensure that you are installing the components for the correct nightly build)
|
||||||
|
- you will also need the bootimage crate which can be installed with the below command:
|
||||||
|
> cargo install bootimage
|
||||||
|
- the final requirement is having QEMU desktop installed for your system. on linux this comes in the default repositories of most major distributions.
|
||||||
|
- finally:
|
||||||
|
> cargo run
|
||||||
|
|
||||||
|
|
||||||
# Features as of Nov 2023
|
# Features as of Nov 2023
|
||||||
|
|
||||||
### barebones standard library with the following general features
|
### barebones standard library with the following general features
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
never gonna give you up
|
||||||
|
|
||||||
|
|
||||||
|
// "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
never gonna give you up
|
|
||||||
never gonna give you up
|
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use alloc::{string::String, vec::Vec, boxed::Box};
|
use alloc::{string::String, vec::Vec, boxed::Box};
|
||||||
|
|
||||||
|
use super::render::Window;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait Application {
|
pub trait Application {
|
||||||
fn new() -> Self;
|
fn new() -> Self;
|
||||||
|
|
||||||
async fn run(&mut self, _: Vec<String>) -> Result<(), Error> {
|
async fn run(&mut self, _window: Option<Window>, _args: Vec<String>) -> Result<(), Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-37
@@ -48,46 +48,10 @@ impl Serial {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// enum with a terminal and application mode
|
|
||||||
pub enum Screen {
|
|
||||||
Terminal,
|
|
||||||
Application,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// DEPRECATED - STOP USING THIS SOON
|
|
||||||
impl Screen {
|
|
||||||
/// mode can be set for the kernel using this method
|
|
||||||
// pub fn set_mode(&self) -> Result<(), RenderError> {
|
|
||||||
// Ok(match self {
|
|
||||||
// Screen::Terminal => RENDERER.lock().terminal_mode(),
|
|
||||||
// Screen::Application => RENDERER.lock().application_mode(),
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
||||||
/// returns the current display mode
|
|
||||||
pub fn get_mode() -> Screen {
|
|
||||||
match RENDERER.lock().mode_is_app() {
|
|
||||||
true => Screen::Application,
|
|
||||||
false => Screen::Terminal,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// switches between modes
|
|
||||||
pub fn switch(&self) {
|
|
||||||
if RENDERER.lock().mode_is_app() == true {
|
|
||||||
RENDERER.lock().terminal_mode();
|
|
||||||
} else {
|
|
||||||
RENDERER.lock().application_mode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn clear() {
|
|
||||||
RENDERER.lock().clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// An interface that tells the kernel what rendering mode to use
|
/// An interface that tells the kernel what rendering mode to use
|
||||||
/// Creating an instance of this struct will enable application rendering mode
|
/// Creating an instance of this struct will enable application rendering mode
|
||||||
/// Dropping the instance will return the display to focus on the terminal.
|
/// Dropping the instance will return the display to focus on the terminal.
|
||||||
|
/// this will be deprecated in the near future !!
|
||||||
pub struct Display;
|
pub struct Display;
|
||||||
|
|
||||||
impl Display {
|
impl Display {
|
||||||
@@ -99,6 +63,10 @@ impl Display {
|
|||||||
pub fn mv_cursor(&self, x: u8, y: u8) -> Result<(), RenderError> {
|
pub fn mv_cursor(&self, x: u8, y: u8) -> Result<(), RenderError> {
|
||||||
RENDERER.lock().cursor_position(x, y)
|
RENDERER.lock().cursor_position(x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clear() {
|
||||||
|
RENDERER.lock().clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Display {
|
impl Drop for Display {
|
||||||
|
|||||||
@@ -21,6 +21,53 @@ pub use crate::system::kernel::render::{
|
|||||||
BUFFER_HEIGHT
|
BUFFER_HEIGHT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub struct Window {
|
||||||
|
width: u32,
|
||||||
|
height: u32,
|
||||||
|
x: u32,
|
||||||
|
y: u32,
|
||||||
|
bordered: bool,
|
||||||
|
open: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Window {
|
||||||
|
pub fn new() -> Window {
|
||||||
|
Window {
|
||||||
|
width: BUFFER_WIDTH as u32,
|
||||||
|
height: BUFFER_HEIGHT as u32,
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
bordered: true,
|
||||||
|
open: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn open(&mut self) -> Result<(), RenderError> {
|
||||||
|
if self.open {
|
||||||
|
return Err(RenderError::InvalidRenderMode);
|
||||||
|
}
|
||||||
|
self.open = true;
|
||||||
|
|
||||||
|
let mut frame: [[ScreenChar; BUFFER_WIDTH]; BUFFER_HEIGHT] = [[ScreenChar::null(); BUFFER_WIDTH]; BUFFER_HEIGHT];
|
||||||
|
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
// pub fn render(&self, f: &Frame) -> Result<(), RenderError> {
|
||||||
|
// let mut frame: &[[ScreenChar; self.width]; self.height] = &[[ScreenChar::null(); self.width]; self.height];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// for (i, row) in f.frame.iter().enumerate() {
|
||||||
|
// for (j, col) in row.iter().enumerate() {
|
||||||
|
// frame[i + f.position.y][j + f.position.x] = col.as_screen_char();
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
// RENDERER.lock().render_frame(frame);
|
||||||
|
// Ok(())
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
pub struct ColouredChar {
|
pub struct ColouredChar {
|
||||||
@@ -117,6 +164,14 @@ impl Frame {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn from_window(window: &Window) -> Frame {
|
||||||
|
Frame {
|
||||||
|
dimensions: Dimensions::new(window.width as usize, window.height as usize),
|
||||||
|
position: Position::new(window.x as usize, window.y as usize),
|
||||||
|
frame: vec![vec![ColouredChar::null(); window.width as usize]; window.height as usize],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn from_str(elemstr: String) -> Self {
|
pub fn from_str(elemstr: String) -> Self {
|
||||||
let mut element = Frame { frame: Vec::<Vec<ColouredChar>>::new(), dimensions: Dimensions::new(0, 0), position: Position::new(0, 0) };
|
let mut element = Frame { frame: Vec::<Vec<ColouredChar>>::new(), dimensions: Dimensions::new(0, 0), position: Position::new(0, 0) };
|
||||||
|
|
||||||
@@ -141,6 +196,7 @@ impl Frame {
|
|||||||
self.frame.clone()
|
self.frame.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// DEPRECATED. Use Window::render(&Frame) instead !!
|
||||||
pub fn write_to_screen(&self) -> Result<(), RenderError> {
|
pub fn write_to_screen(&self) -> Result<(), RenderError> {
|
||||||
let mut frame: [[ScreenChar; BUFFER_WIDTH]; BUFFER_HEIGHT] = [[ScreenChar::null(); BUFFER_WIDTH]; BUFFER_HEIGHT];
|
let mut frame: [[ScreenChar; BUFFER_WIDTH]; BUFFER_HEIGHT] = [[ScreenChar::null(); BUFFER_WIDTH]; BUFFER_HEIGHT];
|
||||||
for (i, row) in self.frame.iter().enumerate() {
|
for (i, row) in self.frame.iter().enumerate() {
|
||||||
@@ -151,6 +207,7 @@ impl Frame {
|
|||||||
RENDERER.lock().render_frame(frame);
|
RENDERER.lock().render_frame(frame);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_position(&self) -> Position<usize> {
|
pub fn get_position(&self) -> Position<usize> {
|
||||||
self.position
|
self.position
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ use core::fmt;
|
|||||||
use alloc::{boxed::Box, format, string::String, vec::Vec};
|
use alloc::{boxed::Box, format, string::String, vec::Vec};
|
||||||
use alloc::string::ToString;
|
use alloc::string::ToString;
|
||||||
use alloc::borrow::ToOwned;
|
use alloc::borrow::ToOwned;
|
||||||
|
use crate::std::render::Window;
|
||||||
use crate::{println, print, mknode, std, serial_println};
|
use crate::{println, print, mknode, std, serial_println};
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
@@ -361,7 +362,7 @@ impl Application for Calculator {
|
|||||||
Self {}
|
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 {
|
if args.len() == 0 {
|
||||||
loop {
|
loop {
|
||||||
print!("enter equation > ");
|
print!("enter equation > ");
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use crate::{serial_println, std};
|
use crate::{serial_println, std};
|
||||||
use crate::std::application::{self, Application};
|
use crate::std::application::{self, Application};
|
||||||
use crate::std::io::{Color, ColorCode, Display, KeyStroke};
|
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;
|
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) {
|
// if let Some(s) = args.get(0) {
|
||||||
// self.buffer = s.lines().map(|l| l.chars().collect()).collect::<Vec<Vec<char>>>()
|
// self.buffer = s.lines().map(|l| l.chars().collect()).collect::<Vec<Vec<char>>>()
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use alloc::boxed::Box;
|
|||||||
use core::any::Any;
|
use core::any::Any;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use crate::std::application::{Application, Error};
|
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::std::io::{Display, KeyStroke, Stdin};
|
||||||
|
|
||||||
use crate::user::lib::libgui::{
|
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()
|
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();
|
let _d = Display::borrow();
|
||||||
|
|
||||||
self.frame.frame = vec![vec![ColouredChar::new(' '); self.frame.dimensions.x]; self.frame.dimensions.y];
|
self.frame.frame = vec![vec![ColouredChar::new(' '); self.frame.dimensions.x]; self.frame.dimensions.y];
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
pub mod calc;
|
pub mod calc;
|
||||||
pub mod editor;
|
pub mod editor;
|
||||||
pub mod grapher;
|
pub mod grapher;
|
||||||
pub mod tasks;
|
pub mod tasks;
|
||||||
|
pub mod zxqsh;
|
||||||
@@ -4,6 +4,7 @@ use crate::std::application::{
|
|||||||
Error
|
Error
|
||||||
};
|
};
|
||||||
use crate::println;
|
use crate::println;
|
||||||
|
use crate::std::render::Window;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use spin::Mutex;
|
use spin::Mutex;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
@@ -27,7 +28,7 @@ pub struct Tasks;
|
|||||||
impl Application for Tasks {
|
impl Application for Tasks {
|
||||||
fn new() -> Self { Self {} }
|
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") {
|
if args[0].clone() == String::from("add") {
|
||||||
|
|
||||||
|
|||||||
@@ -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(())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::std::application::Error;
|
use crate::std::application::Error;
|
||||||
use crate::std::application::Error::ApplicationError;
|
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::io::{Color, ColorCode, Display, KeyStroke, Stdin};
|
||||||
use crate::std::random::Random;
|
use crate::std::random::Random;
|
||||||
use crate::system::std::application::Application;
|
use crate::system::std::application::Application;
|
||||||
@@ -52,7 +52,7 @@ impl Application for Game {
|
|||||||
timer: GameTimer::new(),
|
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 _d = Display::borrow();
|
||||||
|
|
||||||
let mut container_data =
|
let mut container_data =
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use alloc::{string::String, vec::Vec, boxed::Box};
|
use alloc::{string::String, vec::Vec, boxed::Box};
|
||||||
use async_trait::async_trait;
|
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 struct Game {
|
||||||
pub board: [[Cell; 7]; 6],
|
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();
|
let _display = Display::borrow();
|
||||||
|
|
||||||
self.get_next_mode().await;
|
self.get_next_mode().await;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use alloc::vec::Vec;
|
|||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
use crate::std::application::{Application, Error};
|
use crate::std::application::{Application, Error};
|
||||||
use async_trait::async_trait;
|
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::io::{KeyStroke, Stdin, Color, ColorCode, Display};
|
||||||
use crate::std::time::wait;
|
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()
|
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:
|
// setup:
|
||||||
let _d = Display::borrow();
|
let _d = Display::borrow();
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use crate::{
|
|||||||
self,
|
self,
|
||||||
application::{Application, Error},
|
application::{Application, Error},
|
||||||
io::{Color, ColorCode, Display, KeyStroke, Stdin},
|
io::{Color, ColorCode, Display, KeyStroke, Stdin},
|
||||||
render::{ColouredChar, Dimensions, Frame, Position, RenderError},
|
render::{ColouredChar, Dimensions, Frame, Position, RenderError, Window},
|
||||||
time
|
time
|
||||||
},
|
},
|
||||||
user::lib::libgui::cg_core::CgComponent
|
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();
|
let _display = Display::borrow();
|
||||||
|
|
||||||
'outer: loop {
|
'outer: loop {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use alloc::vec::Vec;
|
|||||||
use core::any::Any;
|
use core::any::Any;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use crate::std::application::{Application, Error};
|
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::io::{Color, Display, KeyStroke, Stdin};
|
||||||
use crate::std::time::Timer;
|
use crate::std::time::Timer;
|
||||||
use crate::user::lib::libgui::cg_core::CgComponent;
|
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 _d = Display::borrow();
|
||||||
|
|
||||||
let mut update_time = Timer::new(0.1);
|
let mut update_time = Timer::new(0.1);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use async_trait::async_trait;
|
|||||||
use crate::std::io::{Color, Display, KeyStroke, Stdin};
|
use crate::std::io::{Color, Display, KeyStroke, Stdin};
|
||||||
use crate::std::time;
|
use crate::std::time;
|
||||||
use crate::std::application::{Application, Error};
|
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::std::random::Random;
|
||||||
use crate::system::std::render;
|
use crate::system::std::render;
|
||||||
use super::super::super::lib::geometry::{Position, Direction};
|
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
|
let _settings = [0, 0, 0]; // ai_count, snake_len, poi_count
|
||||||
|
|
||||||
|
|||||||
+24
-23
@@ -18,15 +18,9 @@ use crate::{
|
|||||||
printerr,
|
printerr,
|
||||||
println,
|
println,
|
||||||
std::{
|
std::{
|
||||||
application::{Application, Error, Exit},
|
application::{Application, Error, Exit}, io::{write, Color, Display, KeyStroke, Serial, Stdin}, render::Window, time::timer
|
||||||
time::{timer},
|
|
||||||
io::{Color, write, Screen, Stdin, Serial, KeyStroke, Display},
|
|
||||||
},
|
},
|
||||||
user::{
|
user::{
|
||||||
lib::libgui::{
|
|
||||||
cg_core::{CgComponent, CgKeyboardCapture},
|
|
||||||
cg_widgets::CgDialog,
|
|
||||||
},
|
|
||||||
bin::{
|
bin::{
|
||||||
apps::{
|
apps::{
|
||||||
calc::Calculator,
|
calc::Calculator,
|
||||||
@@ -48,7 +42,10 @@ use crate::{
|
|||||||
gigachad_detector::GigachadDetector,
|
gigachad_detector::GigachadDetector,
|
||||||
rickroll::Rickroll,
|
rickroll::Rickroll,
|
||||||
},
|
},
|
||||||
},
|
}, lib::libgui::{
|
||||||
|
cg_core::{CgComponent, CgKeyboardCapture},
|
||||||
|
cg_widgets::CgDialog,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -67,11 +64,13 @@ pub async fn command_handler() {
|
|||||||
pub async fn eventloop() {
|
pub async fn eventloop() {
|
||||||
println!("running!");
|
println!("running!");
|
||||||
|
|
||||||
|
let window = Window::new();
|
||||||
|
|
||||||
let mut fetch = CrystalFetch::new();
|
let mut fetch = CrystalFetch::new();
|
||||||
let string = String::from(" ");
|
let string = String::from(" ");
|
||||||
let mut vec: Vec<String> = Vec::new();
|
let mut vec: Vec<String> = Vec::new();
|
||||||
vec.push(string);
|
vec.push(string);
|
||||||
fetch.run(vec).await.unwrap();
|
fetch.run(Some(window), vec).await.unwrap();
|
||||||
|
|
||||||
CMD.lock().prompt();
|
CMD.lock().prompt();
|
||||||
|
|
||||||
@@ -122,29 +121,31 @@ async fn exec() -> Result<(), Error> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let window = Window::new();
|
||||||
|
|
||||||
match cmd.as_str() {
|
match cmd.as_str() {
|
||||||
"calculate" | "calc" | "solve" => {
|
"calculate" | "calc" | "solve" => {
|
||||||
let mut cmd = Calculator::new();
|
let mut cmd = Calculator::new();
|
||||||
cmd.run(args).await?;
|
cmd.run(Some(window), args).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
"games/connect4" => {
|
"games/connect4" => {
|
||||||
let mut cmd = Connect4Game::new();
|
let mut cmd = Connect4Game::new();
|
||||||
cmd.run(args).await?;
|
cmd.run(Some(window), args).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
"rickroll" => {
|
"rickroll" => {
|
||||||
let mut cmd = Rickroll::new();
|
let mut cmd = Rickroll::new();
|
||||||
cmd.run(args).await?;
|
cmd.run(Some(window), args).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
"crystalfetch" => {
|
"crystalfetch" => {
|
||||||
let mut cmd = CrystalFetch::new();
|
let mut cmd = CrystalFetch::new();
|
||||||
cmd.run(args).await?;
|
cmd.run(Some(window), args).await?;
|
||||||
}
|
}
|
||||||
"tasks" => {
|
"tasks" => {
|
||||||
let mut cmd = Tasks::new();
|
let mut cmd = Tasks::new();
|
||||||
cmd.run(args).await?;
|
cmd.run(Some(window), args).await?;
|
||||||
}
|
}
|
||||||
"VGA" => {
|
"VGA" => {
|
||||||
use vga::colors::Color16;
|
use vga::colors::Color16;
|
||||||
@@ -156,21 +157,21 @@ async fn exec() -> Result<(), Error> {
|
|||||||
mode.draw_line((80, 60), (120, 420), Color16::Cyan);
|
mode.draw_line((80, 60), (120, 420), Color16::Cyan);
|
||||||
}
|
}
|
||||||
"graph" => {
|
"graph" => {
|
||||||
Grapher::new().run(args).await?;
|
Grapher::new().run(Some(window), args).await?;
|
||||||
}
|
}
|
||||||
"games/snake" => {
|
"games/snake" => {
|
||||||
SnakeGame::new().run(args).await?;
|
SnakeGame::new().run(Some(window), args).await?;
|
||||||
}
|
}
|
||||||
"games/asteroids" => {
|
"games/asteroids" => {
|
||||||
let mut asteroid_game = AsteroidsGame::new();
|
let mut asteroid_game = AsteroidsGame::new();
|
||||||
asteroid_game.run(args).await?;
|
asteroid_game.run(Some(window), args).await?;
|
||||||
}
|
}
|
||||||
"games/pong" => {
|
"games/pong" => {
|
||||||
PongGame::new().run(args).await?;
|
PongGame::new().run(Some(window), args).await?;
|
||||||
}
|
}
|
||||||
"games/paper.rs" => {
|
"games/paper.rs" => {
|
||||||
let mut game = GameBoard::new();
|
let mut game = GameBoard::new();
|
||||||
game.run(args).await?;
|
game.run(Some(window), args).await?;
|
||||||
}
|
}
|
||||||
"serial" => {
|
"serial" => {
|
||||||
let c = Serial::reply_char('e');
|
let c = Serial::reply_char('e');
|
||||||
@@ -178,7 +179,7 @@ async fn exec() -> Result<(), Error> {
|
|||||||
}
|
}
|
||||||
"games/gameoflife" => {
|
"games/gameoflife" => {
|
||||||
let mut game = GameOfLife::new();
|
let mut game = GameOfLife::new();
|
||||||
game.run(Vec::new()).await?;
|
game.run(Some(window), Vec::new()).await?;
|
||||||
}
|
}
|
||||||
"games/tetris" => {
|
"games/tetris" => {
|
||||||
// let mut game = TetrisEngine::new();
|
// let mut game = TetrisEngine::new();
|
||||||
@@ -187,12 +188,12 @@ async fn exec() -> Result<(), Error> {
|
|||||||
|
|
||||||
"gigachad?" => {
|
"gigachad?" => {
|
||||||
let mut detector = GigachadDetector::new();
|
let mut detector = GigachadDetector::new();
|
||||||
detector.run(args).await?;
|
detector.run(Some(window), args).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
"editor" => {
|
"editor" => {
|
||||||
let mut editor = Editor::new();
|
let mut editor = Editor::new();
|
||||||
editor.run(args).await?;
|
editor.run(Some(window), args).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// direct OS functions (not applications)
|
// direct OS functions (not applications)
|
||||||
@@ -208,7 +209,7 @@ async fn exec() -> Result<(), Error> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
"clear" => {
|
"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
|
// 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(|| {});
|
//interrupts::without_interrupts(|| {});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +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 crate::std::{
|
use crate::std::{
|
||||||
os::OS,
|
application::{Application, Error}, io::{write, Color, Display}, os::OS, render::Window
|
||||||
io::{Color, write, Screen},
|
|
||||||
application::{Application, Error},
|
|
||||||
};
|
};
|
||||||
use crate::println;
|
use crate::println;
|
||||||
|
|
||||||
@@ -55,12 +53,15 @@ impl Application for CrystalFetch {
|
|||||||
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> {
|
||||||
|
|
||||||
|
let ds = Display::borrow();
|
||||||
|
|
||||||
let os = OS.lock().os.clone();
|
let os = OS.lock().os.clone();
|
||||||
let version = OS.lock().version.clone();
|
let version = OS.lock().version.clone();
|
||||||
|
|
||||||
Screen::clear();
|
// clear screen
|
||||||
|
Display::clear();
|
||||||
|
|
||||||
let logo_string = ZXQ5_LOGO;
|
let logo_string = ZXQ5_LOGO;
|
||||||
let info_string = format!(
|
let info_string = format!(
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ use alloc::{boxed::Box, string::String, vec::Vec};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
println,
|
println,
|
||||||
std::application::{
|
std::{application::{
|
||||||
Application,
|
Application,
|
||||||
Error,
|
Error,
|
||||||
},
|
}, render::Window},
|
||||||
};
|
};
|
||||||
|
|
||||||
const GIGACHAD: [&'static str; 3] = ["fantasypvp", "zxq5", "ZXQ5"];
|
const GIGACHAD: [&'static str; 3] = ["fantasypvp", "zxq5", "ZXQ5"];
|
||||||
@@ -19,7 +19,7 @@ impl Application for GigachadDetector {
|
|||||||
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> {
|
||||||
for arg in args {
|
for arg in args {
|
||||||
self.detect_gigachad_by_username(&arg)
|
self.detect_gigachad_by_username(&arg)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ const RICKROLL2: &str = "
|
|||||||
`--'";
|
`--'";
|
||||||
|
|
||||||
use crate::println;
|
use crate::println;
|
||||||
|
use crate::std::render::Window;
|
||||||
use alloc::{string::String, boxed::Box, vec::Vec};
|
use alloc::{string::String, boxed::Box, vec::Vec};
|
||||||
|
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ impl Application for Rickroll {
|
|||||||
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> {
|
||||||
println!("{}", RICKROLL2);
|
println!("{}", RICKROLL2);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
// pub mod libgui_old_archive;
|
// pub mod libgui_old_archive;
|
||||||
pub mod geometry;
|
pub mod geometry;
|
||||||
pub mod libgui;
|
pub mod libgui;
|
||||||
|
pub mod termui;
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
pub async fn idk() {}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
pub mod components;
|
||||||
Reference in New Issue
Block a user