mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
140 lines
3.9 KiB
Rust
140 lines
3.9 KiB
Rust
#![allow(unused)]
|
|
#![allow(clippy::unit_arg)]
|
|
#![feature(adt_const_params)]
|
|
#![feature(type_alias_impl_trait)]
|
|
#![feature(impl_trait_in_assoc_type)]
|
|
#![feature(associated_type_defaults)]
|
|
|
|
pub use ::tek_tui::{self, tek_engine, tek_layout};
|
|
pub(crate) use ::tek_tui::{
|
|
*,
|
|
tek_edn::*,
|
|
tek_layout::*,
|
|
tek_engine::{
|
|
from,
|
|
Usually, Perhaps,
|
|
Output, Content, Render, RenderBox, Thunk, render, Engine, Size, Area,
|
|
Input, handle, Handle, command, Command, input_to_command, InputToCommand, keymap, EventMap,
|
|
},
|
|
Tui,
|
|
TuiIn, key, ctrl, shift, alt, kexp, kpat,
|
|
TuiOut,
|
|
crossterm::{
|
|
self,
|
|
event::{
|
|
Event, KeyEvent, KeyEventKind, KeyEventState, KeyModifiers,
|
|
KeyCode::{self, *},
|
|
}
|
|
},
|
|
ratatui::{
|
|
self,
|
|
prelude::{Color, Style, Stylize, Buffer, Modifier},
|
|
buffer::Cell,
|
|
}
|
|
};
|
|
|
|
pub(crate) use std::cmp::{Ord, Eq, PartialEq};
|
|
pub(crate) use std::collections::BTreeMap;
|
|
pub(crate) use std::error::Error;
|
|
pub(crate) use std::ffi::OsString;
|
|
pub(crate) use std::fmt::{Debug, Display, Formatter};
|
|
pub(crate) use std::io::{Stdout, stdout};
|
|
pub(crate) use std::marker::PhantomData;
|
|
pub(crate) use std::ops::{Add, Sub, Mul, Div, Rem};
|
|
pub(crate) use std::path::PathBuf;
|
|
pub(crate) use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering::{self, *}};
|
|
pub(crate) use std::sync::{Arc, Mutex, RwLock};
|
|
pub(crate) use std::thread::{spawn, JoinHandle};
|
|
pub(crate) use std::time::Duration;
|
|
|
|
pub mod arranger; pub use self::arranger::*;
|
|
pub mod clock; pub use self::clock::*;
|
|
pub mod field; pub use self::field::*;
|
|
pub mod file; pub use self::file::*;
|
|
pub mod focus; pub use self::focus::*;
|
|
pub mod groovebox; pub use self::groovebox::*;
|
|
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 piano; pub use self::piano::*;
|
|
pub mod plugin; pub use self::plugin::*;
|
|
pub mod pool; pub use self::pool::*;
|
|
pub mod sampler; pub use self::sampler::*;
|
|
pub mod sequencer; pub use self::sequencer::*;
|
|
pub mod status; pub use self::status::*;
|
|
|
|
pub use ::atomic_float;
|
|
pub(crate) use atomic_float::*;
|
|
|
|
pub use ::midly::{self, num::u7};
|
|
pub(crate) use ::midly::{
|
|
Smf,
|
|
MidiMessage,
|
|
TrackEventKind,
|
|
live::LiveEvent,
|
|
};
|
|
|
|
testmod! { test }
|
|
|
|
/// Define test modules.
|
|
#[macro_export] macro_rules! testmod {
|
|
($($name:ident)*) => { $(#[cfg(test)] mod $name;)* };
|
|
}
|
|
|
|
pub trait Gettable<T> {
|
|
/// Returns current value
|
|
fn get (&self) -> T;
|
|
}
|
|
|
|
pub trait Mutable<T>: Gettable<T> {
|
|
/// Sets new value, returns old
|
|
fn set (&mut self, value: T) -> T;
|
|
}
|
|
|
|
pub trait InteriorMutable<T>: Gettable<T> {
|
|
/// Sets new value, returns old
|
|
fn set (&self, value: T) -> T;
|
|
}
|
|
|
|
impl Gettable<bool> for AtomicBool {
|
|
fn get (&self) -> bool { self.load(Relaxed) }
|
|
}
|
|
|
|
impl InteriorMutable<bool> for AtomicBool {
|
|
fn set (&self, value: bool) -> bool { self.swap(value, Relaxed) }
|
|
}
|
|
|
|
impl Gettable<usize> for AtomicUsize {
|
|
fn get (&self) -> usize { self.load(Relaxed) }
|
|
}
|
|
|
|
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));
|