From 2f08835d69787e6787d0bb98dbf2975347ef2183 Mon Sep 17 00:00:00 2001 From: zxq5 Date: Mon, 24 Feb 2025 15:10:58 +0000 Subject: [PATCH] merge commit. probably broken tbh --- libk/src/drivers/io/keyboard.rs | 2 ++ libk/src/drivers/scheduling/task.rs | 6 ++++++ libk/src/resources/font/mod.rs | 1 + libk/src/std/application/frame.rs | 19 +++++++++++++++++++ libk/src/std/application/render.rs | 23 +++++++++++++++++++++++ libk/src/std/application/window.rs | 12 ++++++++++++ 6 files changed, 63 insertions(+) create mode 100644 libk/src/std/application/frame.rs create mode 100644 libk/src/std/application/render.rs diff --git a/libk/src/drivers/io/keyboard.rs b/libk/src/drivers/io/keyboard.rs index 8c0354c..6851123 100644 --- a/libk/src/drivers/io/keyboard.rs +++ b/libk/src/drivers/io/keyboard.rs @@ -17,6 +17,7 @@ static WAKER: AtomicWaker = AtomicWaker::new(); pub fn add_scancode(scancode: u8) { if let Some(queue) = KBD_QUEUE.get() { + if queue.push(scancode).is_err() { if queue.push(scancode).is_err() { println!("WARNING: scancode queue full; dropping keyboard input"); } else { @@ -54,6 +55,7 @@ impl Stream for ScancodeStream { return Poll::Ready(Some(scancode)); } + WAKER.register(cx.waker()); WAKER.register(cx.waker()); queue.pop().map_or(Poll::Pending, |scancode| { diff --git a/libk/src/drivers/scheduling/task.rs b/libk/src/drivers/scheduling/task.rs index cb84b1e..503c107 100644 --- a/libk/src/drivers/scheduling/task.rs +++ b/libk/src/drivers/scheduling/task.rs @@ -127,6 +127,12 @@ impl TaskWaker { } } +impl Default for Executor { + fn default() -> Self { + Self::new() + } +} + impl Wake for TaskWaker { fn wake(self: Arc) { self.wake_task(); diff --git a/libk/src/resources/font/mod.rs b/libk/src/resources/font/mod.rs index 71f5ba0..e6d8246 100644 --- a/libk/src/resources/font/mod.rs +++ b/libk/src/resources/font/mod.rs @@ -5,6 +5,7 @@ pub mod ibm_vga_8x16; pub static FONT_SPLEEN_8X16: Font = Font(include_font!( "./libk/resources/font/spleen-8x16.psf" )); + pub static FONT_CP850_8X16: Font = Font(include_font!( "./libk/resources/font/cp850-8x16.psf" )); diff --git a/libk/src/std/application/frame.rs b/libk/src/std/application/frame.rs new file mode 100644 index 0000000..6cd2405 --- /dev/null +++ b/libk/src/std/application/frame.rs @@ -0,0 +1,19 @@ +use super::{ + render::{ColouredChar, RenderError}, + window::Window, +}; +use alloc::vec::Vec; + +pub struct Frame<'f> { + data: Vec>, + window: &'f Window, +} + +impl Frame<'_> { + pub fn render(&self) -> Result<(), RenderError> { + let data: Vec<&[ColouredChar]> = self.data.iter().map(|v| v.as_slice()).collect::>(); + self.window + .render(data.as_slice()) + .map_err(|_| RenderError::Generic) + } +} diff --git a/libk/src/std/application/render.rs b/libk/src/std/application/render.rs new file mode 100644 index 0000000..15be9bf --- /dev/null +++ b/libk/src/std/application/render.rs @@ -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, +} diff --git a/libk/src/std/application/window.rs b/libk/src/std/application/window.rs index 329b521..e84ce01 100644 --- a/libk/src/std/application/window.rs +++ b/libk/src/std/application/window.rs @@ -1,5 +1,7 @@ use crate::{prelude::*, std::maths::geometry::Vec2}; +use super::render::{ColouredChar, RenderError}; + pub struct Window { dimensions: Vec2, position: Vec2, @@ -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() + } +}