refactor: Mode, View, Bind

This commit is contained in:
i do not exist 2026-07-02 09:21:47 +03:00
parent 51faa82d74
commit 701a651fbd
21 changed files with 901 additions and 880 deletions

View file

@ -1,92 +1,19 @@
#![allow(clippy::unit_arg)]
#![feature(adt_const_params, associated_type_defaults, anonymous_lifetime_in_impl_trait,
closure_lifetime_binder, impl_trait_in_assoc_type, trait_alias, type_alias_impl_trait,
type_changing_struct_update)]
/// CLI banner.
pub(crate) const HEADER: &'static str = r#"
~ █▀█▀█ █▀▀█ █ █ ~~~ ~ ~ ~~ ~ ~ ~ ~~ ~ ~ ~ ~
█ █▀ █▀▀▄ ~ v0.4.0, 2026 heatwave edition ~
~ ▀ █▀▀█ ▀ ▀ ~ ~~~ ~ ~ ~ ~ ~~~ ~~~ ~ ~~ "#;
#[cfg(feature = "cli")] use clap::{self, Parser, Subcommand};
#![feature(
adt_const_params,
anonymous_lifetime_in_impl_trait,
impl_trait_in_assoc_type,
trait_alias,
type_changing_struct_update
)]
pub extern crate atomic_float;
pub extern crate xdg;
pub(crate) use ::xdg::BaseDirectories;
pub extern crate midly;
pub(crate) use ::midly::{Smf, TrackEventKind, MidiMessage, Error as MidiError, num::*, live::*};
pub extern crate tengri;
pub(crate) use tengri::{
*, lang::*, exit::*, eval::*, sing::*, time::*, draw::*, term::*, color::*, task::*,
crossterm::event::{Event, KeyEvent},
ratatui::{
self,
prelude::{Rect, Style, Stylize, Buffer, Color::{self, *}},
widgets::{Widget, canvas::{Canvas, Line}},
},
};
/// Implement an arithmetic operation for a unit of time
#[macro_export] macro_rules! impl_op {
($T:ident, $Op:ident, $method:ident, |$a:ident,$b:ident|{$impl:expr}) => {
impl $Op<Self> for $T {
type Output = Self; #[inline] fn $method (self, other: Self) -> Self::Output {
let $a = self.get(); let $b = other.get(); Self($impl.into())
}
}
impl $Op<usize> for $T {
type Output = Self; #[inline] fn $method (self, other: usize) -> Self::Output {
let $a = self.get(); let $b = other as f64; Self($impl.into())
}
}
impl $Op<f64> for $T {
type Output = Self; #[inline] fn $method (self, other: f64) -> Self::Output {
let $a = self.get(); let $b = other; Self($impl.into())
}
}
}
}
#[cfg(feature = "sampler")] pub(crate) use symphonia::{
default::get_codecs,
core::{//errors::Error as SymphoniaError,
audio::SampleBuffer, formats::Packet, io::MediaSourceStream, probe::Hint,
codecs::{Decoder, CODEC_TYPE_NULL},
},
};
#[cfg(feature = "lv2_gui")] use ::winit::{
application::ApplicationHandler,
event::WindowEvent,
event_loop::{ActiveEventLoop, ControlFlow, EventLoop},
window::{Window, WindowId},
platform::x11::EventLoopBuilderExtX11
};
#[allow(unused)] pub(crate) use ::{
std::{
cmp::Ord,
collections::BTreeMap,
error::Error,
ffi::OsString,
fmt::{Write, Debug, Formatter},
fs::File,
ops::{Add, Sub, Mul, Div, Rem},
path::{Path, PathBuf},
sync::{Arc, RwLock, atomic::{AtomicBool, AtomicUsize, Ordering::Relaxed}},
time::Duration,
thread::{spawn, JoinHandle},
},
};
/// Command-line entrypoint.
#[cfg(feature = "cli")]
pub fn main () -> Usually<()> {
#[cfg(feature = "cli")] pub fn main () -> Usually<()> {
tui_setup_panic();
Config::watch(|config|{
tui_run_main(Jack::new_run("tek", move|jack|{
@ -98,8 +25,14 @@ pub fn main () -> Usually<()> {
}).map(|_|())
}
//take!(DeviceCommand|state: Arrangement, iter|state.selected_device().as_ref()
//.map(|t|Take::take(t, iter)).transpose().map(|x|x.flatten()));
pub mod deps; pub use self::deps::*;
pub mod device; pub use self::device::*;
pub mod app; pub use self::app::*;
/// CLI banner.
pub(crate) const HEADER: &'static str = r#"
~ █▀█▀█ █▀▀█ █ █ ~~~ ~ ~ ~~ ~ ~ ~ ~~ ~ ~ ~ ~
█ █▀ █▀▀▄ ~ v0.4.0, 2026 heatwave edition ~
~ ▀ █▀▀█ ▀ ▀ ~ ~~~ ~ ~ ~ ~ ~~~ ~~~ ~ ~~ "#;