From f3badf41e8b64df1cfc4c760d53908647f9fc3c0 Mon Sep 17 00:00:00 2001 From: John Breaux Date: Sat, 25 Mar 2023 17:39:03 -0500 Subject: [PATCH] io.rs: QOL fixups; Reuse WindowBuilder, #[derive(...)] FrameBufferFormat --- src/io.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/io.rs b/src/io.rs index d62dc47..8b69481 100644 --- a/src/io.rs +++ b/src/io.rs @@ -19,7 +19,7 @@ impl WindowBuilder { ..Default::default() } } - pub fn build(self) -> Result { + pub fn build(&self) -> Result { Ok(Window::new( self.name.unwrap_or_default(), self.width, @@ -47,17 +47,22 @@ impl Default for WindowBuilder { } } +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct FrameBufferFormat { pub fg: u32, - pub bg: u32 + pub bg: u32, } impl Default for FrameBufferFormat { fn default() -> Self { - FrameBufferFormat { fg: 0x0011a434, bg: 0x001E2431 } + FrameBufferFormat { + fg: 0x0011a434, + bg: 0x001E2431, + } } } +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct FrameBuffer { buffer: Vec, width: usize, @@ -93,6 +98,12 @@ impl FrameBuffer { } } +impl Default for FrameBuffer { + fn default() -> Self { + Self::new(64, 32) + } +} + pub fn identify_key(key: Key) -> usize { match key { Key::Key1 => 0x1,