wip: big flat pt.2: extract engine crate

This commit is contained in:
🪞👃🪞 2024-12-30 17:54:30 +01:00
parent 4a3de618d0
commit a5628fb663
31 changed files with 1738 additions and 888 deletions

View file

@ -1,6 +1,20 @@
#![allow(unused)]
#![allow(clippy::unit_arg)]
pub use ::tek_engine::*;
pub(crate) use ::tek_engine::{
crossterm::{
ExecutableCommand,
EnterAlternateScreen, LeaveAlternateScreen, enable_raw_mode, disable_raw_mode};
KeyCode, KeyModifiers, KeyEvent, KeyEventKind, KeyEventState
},
ratatui::{
prelude::{Style, Buffer},
style::{Stylize, Modifier},
backend::{Backend, CrosstermBackend, ClearType}
},
};
pub(crate) use std::cmp::{Ord, Eq, PartialEq};
pub(crate) use std::collections::BTreeMap;
pub(crate) use std::error::Error;
@ -16,6 +30,7 @@ pub(crate) use std::thread::{spawn, JoinHandle};
pub(crate) use std::time::Duration;
pub mod arranger; pub use self::arranger::*;
pub mod border; pub use self::border::*;
pub mod color; pub use self::color::*;
pub mod command; pub use self::command::*;
pub mod engine; pub use self::engine::*;
@ -23,12 +38,10 @@ pub mod event; pub use self::event::*;
pub mod file; pub use self::file::*;
pub mod focus; pub use self::focus::*;
pub mod groovebox; pub use self::groovebox::*;
pub mod input; pub use self::input::*;
pub mod jack; pub use self::jack::*;
pub mod meter; pub use self::meter::*;
pub mod midi; pub use self::midi::*;
pub mod mixer; pub use self::mixer::*;
pub mod output; pub use self::output::*;
pub mod piano_h; pub use self::piano_h::*;
pub mod plugin; pub use self::plugin::*;
pub mod pool; pub use self::pool::*;
@ -36,28 +49,15 @@ pub mod sampler; pub use self::sampler::*;
pub mod sequencer; pub use self::sequencer::*;
pub mod space; pub use self::space::*;
pub mod status; pub use self::status::*;
pub mod style; pub use self::theme::*;
pub mod theme; pub use self::theme::*;
pub mod time; pub use self::time::*;
pub mod transport; pub use self::transport::*;
pub mod tui; pub use self::tui::*;
pub use ::better_panic;
pub(crate) use better_panic::{Settings, Verbosity};
pub use ::atomic_float;
pub(crate) use atomic_float::*;
pub use ::crossterm;
pub(crate) use crossterm::{ExecutableCommand};
pub(crate) use crossterm::terminal::{EnterAlternateScreen, LeaveAlternateScreen, enable_raw_mode, disable_raw_mode};
pub(crate) use crossterm::event::{KeyCode, KeyModifiers, KeyEvent, KeyEventKind, KeyEventState};
pub use ::ratatui;
pub(crate) use ratatui::{
prelude::{Style, Buffer},
style::{Stylize, Modifier},
backend::{Backend, CrosstermBackend, ClearType}
};
pub use ::midly::{self, num::u7};
pub(crate) use ::midly::{
Smf,
@ -75,12 +75,6 @@ pub(crate) use ::palette::{
testmod! { test }
/// Standard result type.
pub type Usually<T> = Result<T, Box<dyn Error>>;
/// Standard optional result type.
pub type Perhaps<T> = Result<Option<T>, Box<dyn Error>>;
/// Define test modules.
#[macro_export] macro_rules! testmod {
($($name:ident)*) => { $(#[cfg(test)] mod $name;)* };
@ -126,3 +120,29 @@ impl Gettable<usize> for AtomicUsize {
impl InteriorMutable<usize> for AtomicUsize {
fn set (&self, value: usize) -> usize { self.swap(value, Relaxed) }
}
#[derive(Default)]
pub struct BigBuffer {
pub width: usize,
pub height: usize,
pub content: Vec<Cell>
}
impl BigBuffer {
pub fn new (width: usize, height: usize) -> Self {
Self { width, height, content: vec![Cell::default(); width*height] }
}
pub fn get (&self, x: usize, y: usize) -> Option<&Cell> {
let i = self.index_of(x, y);
self.content.get(i)
}
pub fn get_mut (&mut self, x: usize, y: usize) -> Option<&mut Cell> {
let i = self.index_of(x, y);
self.content.get_mut(i)
}
pub fn index_of (&self, x: usize, y: usize) -> usize {
y * self.width + x
}
}
from!(|size:(usize, usize)| BigBuffer = Self::new(size.0, size.1));