- added a new API for switching between terminal and application mode

- removed unneeded imports to reduce the dumb amount of warnings from the compiler
- added a bounds check in frame.rs to avoid a panic when a frame tries to render a character out of bounds, instead returning an error
This commit is contained in:
FantasyPvP
2024-03-22 00:12:15 +00:00
parent 5c6ec299ee
commit d5d9e031d5
29 changed files with 439 additions and 436 deletions
+9 -23
View File
@@ -3,12 +3,8 @@ use lazy_static::lazy_static;
use spin::Mutex;
use volatile::Volatile;
use alloc::borrow::ToOwned;
use alloc::vec;
use alloc::vec::Vec;
use crate::system::kernel::render::RenderError::InvalidRenderMode;
use crate::serial_println;
use crate::std::io::Screen;
#[allow(dead_code)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -137,24 +133,14 @@ impl Renderer {
self.internal_render();
}
pub fn application_mode(&mut self) -> Result<(), RenderError> {
if self.application_mode {
return Err(InvalidRenderMode);
} else {
self.application_mode = true;
self.internal_render();
Ok(())
}
pub fn application_mode(&mut self) {
self.application_mode = true;
self.internal_render();
}
pub fn terminal_mode(&mut self) -> Result<(), RenderError> {
if !self.application_mode {
return Err(InvalidRenderMode);
} else {
self.application_mode = false;
self.internal_render();
Ok(())
}
pub fn terminal_mode(&mut self) {
self.application_mode = false;
self.internal_render();
}
pub fn mode_is_app(&self) -> bool {
@@ -210,10 +196,10 @@ impl Renderer {
pub fn cursor_position(&mut self, x: u8, y: u8) -> Result<(), RenderError> {
// check that x and y are within bounds
if x >= 80 || x < 0 || y >= 25 || y < 0 {
if x >= 80 || y >= 25 {
return Err(RenderError::OutOfBounds(
x >= 80 || x < 0,
y >= 25 || y < 0
x >= 80,
y >= 25
))
}
self.internal_set_cursor_position(x, y);