well, 55 errors until up to date

and then we fix
This commit is contained in:
okay stopped screaming 2026-03-21 20:33:51 +02:00
parent 0577309b19
commit 7ff1d989a9
5 changed files with 333 additions and 344 deletions

View file

@ -22,10 +22,13 @@ pub(crate) use tengri::{
*,
lang::*,
play::*,
keys::*,
sing::*,
time::*,
draw::*,
tui::*,
term::*,
color::*,
space::*,
crossterm::event::{Event, KeyEvent},
ratatui::{
self,
@ -953,13 +956,13 @@ mod view {
/// ```
/// let _ = tek::view_logo();
/// ```
pub fn view_logo () -> impl Content<TuiOut> {
Fixed::XY(32, 7, Tui::bold(true, Tui::fg(Rgb(240,200,180), col!{
Fixed::Y(1, ""),
Fixed::Y(1, ""),
Fixed::Y(1, "~~ ╓─╥─╖ ╓──╖ ╥ ╖ ~~~~~~~~~~~~"),
Fixed::Y(1, Bsp::e("~~~~ ║ ~ ╟─╌ ~╟─< ~~ ", Bsp::e(Tui::fg(Rgb(230,100,40), "v0.3.0"), " ~~"))),
Fixed::Y(1, "~~~~ ╨ ~ ╙──╜ ╨ ╜ ~~~~~~~~~~~~"),
pub fn view_logo () -> impl Draw<Tui> {
wh_exact(32, 7, Tui::bold(true, Tui::fg(Rgb(240,200,180), south!{
h_exact(1, ""),
h_exact(1, ""),
h_exact(1, "~~ ╓─╥─╖ ╓──╖ ╥ ╖ ~~~~~~~~~~~~"),
h_exact(1, east("~~~~ ║ ~ ╟─╌ ~╟─< ~~ ", east(Tui::fg(Rgb(230,100,40), "v0.3.0"), " ~~"))),
h_exact(1, "~~~~ ╨ ~ ╙──╜ ╨ ╜ ~~~~~~~~~~~~"),
})))
}
@ -973,14 +976,14 @@ mod view {
bpm: Arc<RwLock<String>>,
beat: Arc<RwLock<String>>,
time: Arc<RwLock<String>>,
) -> impl Content<TuiOut> {
) -> impl Draw<Tui> {
let theme = ItemTheme::G[96];
Tui::bg(Black, row!(Bsp::a(
Fill::XY(Align::w(button_play_pause(play))),
Fill::XY(Align::e(row!(
FieldH(theme, "BPM", bpm),
FieldH(theme, "Beat", beat),
FieldH(theme, "Time", time),
Tui::bg(Black, east!(above(
wh_full(origin_w(button_play_pause(play))),
wh_full(origin_e(east!(
field_h(theme, "BPM", bpm),
field_h(theme, "Beat", beat),
field_h(theme, "Time", time),
)))
)))
}
@ -995,14 +998,14 @@ mod view {
sr: Arc<RwLock<String>>,
buf: Arc<RwLock<String>>,
lat: Arc<RwLock<String>>,
) -> impl Content<TuiOut> {
) -> impl Draw<Tui> {
let theme = ItemTheme::G[96];
Tui::bg(Black, row!(Bsp::a(
Fill::XY(Align::w(sel.map(|sel|FieldH(theme, "Selected", sel)))),
Fill::XY(Align::e(row!(
FieldH(theme, "SR", sr),
FieldH(theme, "Buf", buf),
FieldH(theme, "Lat", lat),
Tui::bg(Black, east!(above(
wh_full(origin_w(sel.map(|sel|field_h(theme, "Selected", sel)))),
wh_full(origin_e(east!(
field_h(theme, "SR", sr),
field_h(theme, "Buf", buf),
field_h(theme, "Lat", lat),
)))
)))
}
@ -1010,17 +1013,17 @@ mod view {
/// ```
/// let _ = tek::button_play_pause(true);
/// ```
pub fn button_play_pause (playing: bool) -> impl Content<TuiOut> {
pub fn button_play_pause (playing: bool) -> impl Draw<Tui> {
let compact = true;//self.is_editing();
Tui::bg(if playing { Rgb(0, 128, 0) } else { Rgb(128, 64, 0) },
Either::new(compact,
Thunk::new(move|to: &mut TuiOut|to.place(&Fixed::X(9, Either::new(playing,
either(compact,
Thunk::new(move|to: &mut Tui|to.place(&w_exact(9, either(playing,
Tui::fg(Rgb(0, 255, 0), " PLAYING "),
Tui::fg(Rgb(255, 128, 0), " STOPPED ")))
)),
Thunk::new(move|to: &mut TuiOut|to.place(&Fixed::X(5, Either::new(playing,
Tui::fg(Rgb(0, 255, 0), Bsp::s(" 🭍🭑🬽 ", " 🭞🭜🭘 ",)),
Tui::fg(Rgb(255, 128, 0), Bsp::s(" ▗▄▖ ", " ▝▀▘ ",))))
Thunk::new(move|to: &mut Tui|to.place(&w_exact(5, either(playing,
Tui::fg(Rgb(0, 255, 0), south(" 🭍🭑🬽 ", " 🭞🭜🭘 ",)),
Tui::fg(Rgb(255, 128, 0), south(" ▗▄▖ ", " ▝▀▘ ",))))
))
)
)
@ -1028,12 +1031,12 @@ mod view {
#[cfg(feature = "track")] pub fn view_track_row_section (
_theme: ItemTheme,
button: impl Content<TuiOut>,
button_add: impl Content<TuiOut>,
content: impl Content<TuiOut>,
) -> impl Content<TuiOut> {
Bsp::w(Fill::Y(Fixed::X(4, Align::nw(button_add))),
Bsp::e(Fixed::X(20, Fill::Y(Align::nw(button))), Fill::XY(Align::c(content))))
button: impl Draw<Tui>,
button_add: impl Draw<Tui>,
content: impl Draw<Tui>,
) -> impl Draw<Tui> {
west(h_full(w_exact(4, origin_nw(button_add))),
east(w_exact(20, h_full(origin_nw(button))), wh_full(origin_c(content))))
}
/// ```
@ -1041,20 +1044,20 @@ mod view {
/// let fg = tengri::ratatui::style::Color::Green;
/// let _ = tek::view_wrap(bg, fg, "and then blue, too!");
/// ```
pub fn view_wrap (bg: Color, fg: Color, content: impl Content<TuiOut>) -> impl Content<TuiOut> {
let left = Tui::fg_bg(bg, Reset, Fixed::X(1, Repeat::Y("")));
let right = Tui::fg_bg(bg, Reset, Fixed::X(1, Repeat::Y("")));
Bsp::e(left, Bsp::w(right, Tui::fg_bg(fg, bg, content)))
pub fn view_wrap (bg: Color, fg: Color, content: impl Draw<Tui>) -> impl Draw<Tui> {
let left = Tui::fg_bg(bg, Reset, w_exact(1, y_repeat("")));
let right = Tui::fg_bg(bg, Reset, w_exact(1, y_repeat("")));
east(left, west(right, Tui::fg_bg(fg, bg, content)))
}
/// ```
/// let _ = tek::view_meter("", 0.0);
/// let _ = tek::view_meters(&[0.0, 0.0]);
/// ```
pub fn view_meter <'a> (label: &'a str, value: f32) -> impl Content<TuiOut> + 'a {
col!(
FieldH(ItemTheme::G[128], label, format!("{:>+9.3}", value)),
Fixed::XY(if value >= 0.0 { 13 }
pub fn view_meter <'a> (label: &'a str, value: f32) -> impl Draw<Tui> + 'a {
south!(
field_h(ItemTheme::G[128], label, format!("{:>+9.3}", value)),
wh_exact(if value >= 0.0 { 13 }
else if value >= -1.0 { 12 }
else if value >= -2.0 { 11 }
else if value >= -3.0 { 10 }
@ -1072,47 +1075,47 @@ mod view {
else { Green }, ())))
}
pub fn view_meters (values: &[f32;2]) -> impl Content<TuiOut> + use<'_> {
pub fn view_meters (values: &[f32;2]) -> impl Draw<Tui> + use<'_> {
let left = format!("L/{:>+9.3}", values[0]);
let right = format!("R/{:>+9.3}", values[1]);
Bsp::s(left, right)
south(left, right)
}
pub fn draw_info (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> + use<'_> {
When::new(sample.is_some(), Thunk::new(move|to: &mut TuiOut|{
pub fn draw_info (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<Tui> + use<'_> {
when(sample.is_some(), Thunk::new(move|to: &mut Tui|{
let sample = sample.unwrap().read().unwrap();
let theme = sample.color;
to.place(&row!(
FieldH(theme, "Name", format!("{:<10}", sample.name.clone())),
FieldH(theme, "Length", format!("{:<8}", sample.channels[0].len())),
FieldH(theme, "Start", format!("{:<8}", sample.start)),
FieldH(theme, "End", format!("{:<8}", sample.end)),
FieldH(theme, "Trans", "0"),
FieldH(theme, "Gain", format!("{}", sample.gain)),
to.place(&east!(
field_h(theme, "Name", format!("{:<10}", sample.name.clone())),
field_h(theme, "Length", format!("{:<8}", sample.channels[0].len())),
field_h(theme, "Start", format!("{:<8}", sample.start)),
field_h(theme, "End", format!("{:<8}", sample.end)),
field_h(theme, "Trans", "0"),
field_h(theme, "Gain", format!("{}", sample.gain)),
))
}))
}
pub fn draw_info_v (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> + use<'_> {
Either::new(sample.is_some(), Thunk::new(move|to: &mut TuiOut|{
pub fn draw_info_v (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<Tui> + use<'_> {
either(sample.is_some(), Thunk::new(move|to: &mut Tui|{
let sample = sample.unwrap().read().unwrap();
let theme = sample.color;
to.place(&Fixed::X(20, col!(
Fill::X(Align::w(FieldH(theme, "Name ", format!("{:<10}", sample.name.clone())))),
Fill::X(Align::w(FieldH(theme, "Length", format!("{:<8}", sample.channels[0].len())))),
Fill::X(Align::w(FieldH(theme, "Start ", format!("{:<8}", sample.start)))),
Fill::X(Align::w(FieldH(theme, "End ", format!("{:<8}", sample.end)))),
Fill::X(Align::w(FieldH(theme, "Trans ", "0"))),
Fill::X(Align::w(FieldH(theme, "Gain ", format!("{}", sample.gain)))),
to.place(&w_exact(20, south!(
w_full(origin_w(field_h(theme, "Name ", format!("{:<10}", sample.name.clone())))),
w_full(origin_w(field_h(theme, "Length", format!("{:<8}", sample.channels[0].len())))),
w_full(origin_w(field_h(theme, "Start ", format!("{:<8}", sample.start)))),
w_full(origin_w(field_h(theme, "End ", format!("{:<8}", sample.end)))),
w_full(origin_w(field_h(theme, "Trans ", "0"))),
w_full(origin_w(field_h(theme, "Gain ", format!("{}", sample.gain)))),
)))
}), Thunk::new(|to: &mut TuiOut|to.place(&Tui::fg(Red, col!(
}), Thunk::new(|to: &mut Tui|to.place(&Tui::fg(Red, south!(
Tui::bold(true, "× No sample."),
"[r] record",
"[Shift-F9] import",
)))))
}
pub fn draw_status (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> {
pub fn draw_status (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<Tui> {
Tui::bold(true, Tui::fg(Tui::g(224), sample
.map(|sample|{
let sample = sample.read().unwrap();
@ -1121,31 +1124,31 @@ mod view {
.unwrap_or_else(||"No sample".to_string())))
}
pub fn view_track_header (theme: ItemTheme, content: impl Content<TuiOut>) -> impl Content<TuiOut> {
Fixed::X(12, Tui::bg(theme.darker.rgb, Fill::X(Align::e(content))))
pub fn view_track_header (theme: ItemTheme, content: impl Draw<Tui>) -> impl Draw<Tui> {
w_exact(12, Tui::bg(theme.darker.rgb, w_full(origin_e(content))))
}
pub fn view_ports_status <'a, T: JackPort> (theme: ItemTheme, title: &'a str, ports: &'a [T])
-> impl Content<TuiOut> + use<'a, T>
-> impl Draw<Tui> + use<'a, T>
{
let ins = ports.len() as u16;
let frame = Outer(true, Style::default().fg(Tui::g(96)));
let iter = move||ports.iter();
let names = Map::south(1, iter, move|port, index|Fill::Y(Align::w(format!(" {index} {}", port.port_name()))));
let field = FieldV(theme, title, names);
Fixed::XY(20, 1 + ins, frame.enclose(Fixed::XY(20, 1 + ins, field)))
let names = iter_south(1, iter, move|port, index|h_full(origin_w(format!(" {index} {}", port.port_name()))));
let field = field_v(theme, title, names);
wh_exact(20, 1 + ins, frame.enclose(wh_exact(20, 1 + ins, field)))
}
pub fn io_ports <'a, T: PortsSizes<'a>> (
fg: Color, bg: Color, iter: impl Fn()->T + Send + Sync + 'a
) -> impl Content<TuiOut> + 'a {
Map::new(iter, move|(
fg: Color, bg: Color, items: impl Fn()->T + Send + Sync + 'a
) -> impl Draw<Tui> + 'a {
iter(items, move|(
_index, name, connections, y, y2
): (usize, &'a Arc<str>, &'a [Connect], usize, usize), _|
map_south(y as u16, (y2-y) as u16, Bsp::s(
Fill::Y(Tui::bold(true, Tui::fg_bg(fg, bg, Align::w(Bsp::e(&" 󰣲 ", name))))),
Map::new(||connections.iter(), move|connect: &'a Connect, index|map_south(index as u16, 1,
Fill::Y(Align::w(Tui::bold(false, Tui::fg_bg(fg, bg,
iter_south(y as u16, (y2-y) as u16, south(
h_full(Tui::bold(true, Tui::fg_bg(fg, bg, origin_w(east(&" 󰣲 ", name))))),
iter(||connections.iter(), move|connect: &'a Connect, index|iter_south(index as u16, 1,
h_full(origin_w(Tui::bold(false, Tui::fg_bg(fg, bg,
&connect.info)))))))))
}
}
@ -1210,5 +1213,5 @@ pub const NOTE_NAMES: [&str; 128] = [
pub(crate) const HEADER: &'static str = r#"
~ ~~~ ~ ~ ~~ ~ ~ ~ ~~ ~ ~ ~ ~
~ v0.4.0, 2026 winter (or is it) ~
term ~ v0.4.0, 2026 winter (or is it) ~
~ ~ ~~~ ~ ~ ~ ~ ~~~ ~~~ ~ ~~ "#;