io.rs: QOL fixups; Reuse WindowBuilder, #[derive(...)] FrameBufferFormat
This commit is contained in:
parent
c7447a26a3
commit
f3badf41e8
17
src/io.rs
17
src/io.rs
@ -19,7 +19,7 @@ impl WindowBuilder {
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
pub fn build(self) -> Result<Window> {
|
||||
pub fn build(&self) -> Result<Window> {
|
||||
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<u32>,
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user