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()
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn build(self) -> Result<Window> {
|
pub fn build(&self) -> Result<Window> {
|
||||||
Ok(Window::new(
|
Ok(Window::new(
|
||||||
self.name.unwrap_or_default(),
|
self.name.unwrap_or_default(),
|
||||||
self.width,
|
self.width,
|
||||||
@ -47,17 +47,22 @@ impl Default for WindowBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct FrameBufferFormat {
|
pub struct FrameBufferFormat {
|
||||||
pub fg: u32,
|
pub fg: u32,
|
||||||
pub bg: u32
|
pub bg: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for FrameBufferFormat {
|
impl Default for FrameBufferFormat {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
FrameBufferFormat { fg: 0x0011a434, bg: 0x001E2431 }
|
FrameBufferFormat {
|
||||||
|
fg: 0x0011a434,
|
||||||
|
bg: 0x001E2431,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct FrameBuffer {
|
pub struct FrameBuffer {
|
||||||
buffer: Vec<u32>,
|
buffer: Vec<u32>,
|
||||||
width: usize,
|
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 {
|
pub fn identify_key(key: Key) -> usize {
|
||||||
match key {
|
match key {
|
||||||
Key::Key1 => 0x1,
|
Key::Key1 => 0x1,
|
||||||
|
Loading…
Reference in New Issue
Block a user