merge commit. probably broken tbh
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
use super::{
|
||||
render::{ColouredChar, RenderError},
|
||||
window::Window,
|
||||
};
|
||||
use alloc::vec::Vec;
|
||||
|
||||
pub struct Frame<'f> {
|
||||
data: Vec<Vec<ColouredChar>>,
|
||||
window: &'f Window,
|
||||
}
|
||||
|
||||
impl Frame<'_> {
|
||||
pub fn render(&self) -> Result<(), RenderError> {
|
||||
let data: Vec<&[ColouredChar]> = self.data.iter().map(|v| v.as_slice()).collect::<Vec<_>>();
|
||||
self.window
|
||||
.render(data.as_slice())
|
||||
.map_err(|_| RenderError::Generic)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
use core::fmt::Display;
|
||||
|
||||
use crate::drivers::io::framebuffer::colour::Colour;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum RenderError {
|
||||
Generic,
|
||||
}
|
||||
|
||||
impl Display for RenderError {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
match self {
|
||||
Self::Generic => write!(f, "Generic render error"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl core::error::Error for RenderError {}
|
||||
|
||||
pub struct ColouredChar {
|
||||
ch: u8,
|
||||
colour: Colour,
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
use crate::{prelude::*, std::maths::geometry::Vec2};
|
||||
|
||||
use super::render::{ColouredChar, RenderError};
|
||||
|
||||
pub struct Window {
|
||||
dimensions: Vec2<usize>,
|
||||
position: Vec2<usize>,
|
||||
@@ -19,6 +21,10 @@ impl Window {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render(&self, _data: &[&[ColouredChar]]) -> Result<(), RenderError> {
|
||||
todo!();
|
||||
}
|
||||
|
||||
pub const fn is_bordered(&self) -> bool {
|
||||
self.bordered
|
||||
}
|
||||
@@ -78,3 +84,9 @@ impl Drop for Window {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Window {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user