wip: fix: 425e->243e
Some checks failed
/ build (push) Has been cancelled

This commit is contained in:
okay stopped screaming 2026-03-25 22:39:47 +02:00
parent 54ab1d8ba1
commit c72fe8ab23
5 changed files with 112 additions and 110 deletions

View file

@ -183,7 +183,7 @@ fn tek_inc (state: &mut App, axis: &ControlAxis) -> Perhaps<AppCommand> {
Ok(match (&state.dialog, axis) {
(Dialog::None, _) => todo!(),
(Dialog::Menu(_, _), ControlAxis::Y) => AppCommand::SetDialog { dialog: state.dialog.menu_next() }
.execute(state)?,
.act(state)?,
_ => todo!()
})
}
@ -192,7 +192,7 @@ fn tek_dec (state: &mut App, axis: &ControlAxis) -> Perhaps<AppCommand> {
Ok(match (&state.dialog, axis) {
(Dialog::None, _) => None,
(Dialog::Menu(_, _), ControlAxis::Y) => AppCommand::SetDialog { dialog: state.dialog.menu_prev() }
.execute(state)?,
.act(state)?,
_ => todo!()
})
}
@ -219,7 +219,7 @@ fn execute_commands (
) -> Usually<Vec<(AppCommand, Option<AppCommand>)>> {
let mut history = vec![];
for command in commands.into_iter() {
let result = command.execute(app);
let result = command.act(app);
match result { Err(err) => { history.push((command, None)); return Err(err) }
Ok(undo) => { history.push((command, undo)); } };
}
@ -358,11 +358,11 @@ def_sizes_iter!(TracksSizes => Track);
/// let _ = tek::view_logo();
/// ```
pub fn view_logo () -> impl Draw<Tui> {
wh_exact(32, 7, Tui::bold(true, Tui::fg(Rgb(240,200,180), south!{
wh_exact(32, 7, bold(true, 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, east("~~~~ ║ ~ ╟─╌ ~╟─< ~~ ", east(fg(Rgb(230,100,40), "v0.3.0"), " ~~"))),
h_exact(1, "~~~~ ╨ ~ ╙──╜ ╨ ╜ ~~~~~~~~~~~~"),
})))
}
@ -379,7 +379,7 @@ pub fn view_transport (
time: Arc<RwLock<String>>,
) -> impl Draw<Tui> {
let theme = ItemTheme::G[96];
Tui::bg(Black, east!(above(
bg(Black, east!(above(
wh_full(origin_w(button_play_pause(play))),
wh_full(origin_e(east!(
field_h(theme, "BPM", bpm),
@ -401,7 +401,7 @@ pub fn view_status (
lat: Arc<RwLock<String>>,
) -> impl Draw<Tui> {
let theme = ItemTheme::G[96];
Tui::bg(Black, east!(above(
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),
@ -416,15 +416,15 @@ pub fn view_status (
/// ```
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) },
bg(if playing { Rgb(0, 128, 0) } else { Rgb(128, 64, 0) },
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 ")))
fg(Rgb(0, 255, 0), " PLAYING "),
fg(Rgb(255, 128, 0), " STOPPED ")))
)),
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(" ▗▄▖ ", " ▝▀▘ ",))))
fg(Rgb(0, 255, 0), south(" 🭍🭑🬽 ", " 🭞🭜🭘 ",)),
fg(Rgb(255, 128, 0), south(" ▗▄▖ ", " ▝▀▘ ",))))
))
)
)
@ -446,9 +446,9 @@ pub fn button_play_pause (playing: bool) -> impl Draw<Tui> {
/// let _ = tek::view_wrap(bg, fg, "and then blue, too!");
/// ```
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 left = fg_bg(bg, Reset, w_exact(1, y_repeat("")));
let right = fg_bg(bg, Reset, w_exact(1, y_repeat("")));
east(left, west(right, fg_bg(fg, bg, content)))
}
/// ```
@ -471,7 +471,7 @@ pub fn view_meter <'a> (label: &'a str, value: f32) -> impl Draw<Tui> + 'a {
else if value >= -25.0 { 3 }
else if value >= -30.0 { 2 }
else if value >= -40.0 { 1 }
else { 0 }, 1, Tui::bg(if value >= 0.0 { Red }
else { 0 }, 1, bg(if value >= 0.0 { Red }
else if value >= -3.0 { Yellow }
else { Green }, ())))
}
@ -509,15 +509,15 @@ pub fn draw_info_v (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<Tui> + us
w_full(origin_w(field_h(theme, "Trans ", "0"))),
w_full(origin_w(field_h(theme, "Gain ", format!("{}", sample.gain)))),
)))
}), Thunk::new(|to: &mut Tui|to.place(&Tui::fg(Red, south!(
Tui::bold(true, "× No sample."),
}), Thunk::new(|to: &mut Tui|to.place(&fg(Red, south!(
bold(true, "× No sample."),
"[r] record",
"[Shift-F9] import",
)))))
}
pub fn draw_status (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<Tui> {
Tui::bold(true, Tui::fg(Tui::g(224), sample
bold(true, fg(g(224), sample
.map(|sample|{
let sample = sample.read().unwrap();
format!("Sample {}-{}", sample.start, sample.end)
@ -526,14 +526,14 @@ pub fn draw_status (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<Tui> {
}
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))))
w_exact(12, bg(theme.darker.term, w_full(origin_e(content))))
}
pub fn view_ports_status <'a, T: JackPort> (theme: ItemTheme, title: &'a str, ports: &'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 frame = Outer(true, Style::default().fg(g(96)));
let iter = move||ports.iter();
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);
@ -547,9 +547,9 @@ pub fn io_ports <'a, T: PortsSizes<'a>> (
_index, name, connections, y, y2
): (usize, &'a Arc<str>, &'a [Connect], usize, usize), _|
iter_south(y as u16, (y2-y) as u16, south(
h_full(Tui::bold(true, Tui::fg_bg(fg, bg, origin_w(east(&" 󰣲 ", name))))),
h_full(bold(true, 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,
h_full(origin_w(bold(false, fg_bg(fg, bg,
&connect.info)))))))))
}
@ -735,16 +735,16 @@ fn app_understand_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usu
Some(":logo") => to.place(&view_logo()),
Some(":status") => to.place(&h_exact(1, "TODO: Status Bar")),
Some(":meters") => match frags.next() {
Some("input") => to.place(&Tui::bg(Rgb(30, 30, 30), h_full(origin_s("Input Meters")))),
Some("output") => to.place(&Tui::bg(Rgb(30, 30, 30), h_full(origin_s("Output Meters")))),
Some("input") => to.place(&bg(Rgb(30, 30, 30), h_full(origin_s("Input Meters")))),
Some("output") => to.place(&bg(Rgb(30, 30, 30), h_full(origin_s("Output Meters")))),
_ => panic!()
},
Some(":tracks") => match frags.next() {
None => to.place(&"TODO tracks"),
Some("names") => to.place(&state.project.view_track_names(state.color.clone())),//Tui::bg(Rgb(40, 40, 40), w_full(origin_w("Track Names")))),
Some("inputs") => to.place(&Tui::bg(Rgb(40, 40, 40), w_full(origin_w("Track Inputs")))),
Some("devices") => to.place(&Tui::bg(Rgb(40, 40, 40), w_full(origin_w("Track Devices")))),
Some("outputs") => to.place(&Tui::bg(Rgb(40, 40, 40), w_full(origin_w("Track Outputs")))),
Some("names") => to.place(&state.project.view_track_names(state.color.clone())),//bg(Rgb(40, 40, 40), w_full(origin_w("Track Names")))),
Some("inputs") => to.place(&bg(Rgb(40, 40, 40), w_full(origin_w("Track Inputs")))),
Some("devices") => to.place(&bg(Rgb(40, 40, 40), w_full(origin_w("Track Devices")))),
Some("outputs") => to.place(&bg(Rgb(40, 40, 40), w_full(origin_w("Track Outputs")))),
_ => panic!()
},
Some(":scenes") => match frags.next() {
@ -760,7 +760,7 @@ fn app_understand_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usu
Some(wh_full(Thunk::new(move|to: &mut Tui|{
for (index, MenuItem(item, _)) in items.0.iter().enumerate() {
to.place(&y_push((2 * index) as u16,
Tui::fg_bg(
fg_bg(
if *selected == index { Rgb(240,200,180) } else { Rgb(200, 200, 200) },
if *selected == index { Rgb(80, 80, 50) } else { Rgb(30, 30, 30) },
h_exact(2, origin_n(w_full(item)))
@ -782,11 +782,11 @@ fn app_understand_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usu
let info = profile.info.get(0).map(|x|x.as_ref()).unwrap_or("<no info>");
let fg1 = Rgb(224, 192, 128);
let fg2 = Rgb(224, 128, 32);
let field_name = w_full(origin_w(Tui::fg(fg1, name)));
let field_id = w_full(origin_e(Tui::fg(fg2, id)));
let field_name = w_full(origin_w(fg(fg1, name)));
let field_id = w_full(origin_e(fg(fg2, id)));
let field_info = w_full(origin_w(info));
to.place(&y_push((2 * index) as u16,
h_exact(2, w_full(Tui::bg(bg, south(
h_exact(2, w_full(bg(bg, south(
above(field_name, field_id), field_info))))));
}
})))
@ -796,7 +796,7 @@ fn app_understand_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usu
for (index, name) in ["session1", "session2", "session3"].iter().enumerate() {
let bg = if index == 0 { Rgb(50,50,50) } else { Rgb(40,40,40) };
to.place(&y_push((2 * index) as u16,
&h_exact(2, w_full(Tui::bg(bg, origin_w(Tui::fg(fg, name)))))));
&h_exact(2, w_full(bg(bg, origin_w(fg(fg, name)))))));
}
})))),
Some(":browse/title") => to.place(&w_full(origin_w(field_v(ItemColor::default(),
@ -807,16 +807,16 @@ fn app_understand_word (state: &App, to: &mut Tui, dsl: &impl Expression) -> Usu
BrowseTarget::ExportSample(_) => "Export sample:",
BrowseTarget::ImportClip(_) => "Import clip:",
BrowseTarget::ExportClip(_) => "Export clip:",
}, w_shrink(3, h_exact(1, Tui::fg(Tui::g(96), x_repeat("🭻")))))))),
}, w_shrink(3, h_exact(1, fg(g(96), x_repeat("🭻")))))))),
Some(":device") => {
let selected = state.dialog.device_kind().unwrap();
to.place(&south(Tui::bold(true, "Add device"), iter_south(1,
to.place(&south(bold(true, "Add device"), iter_south(1,
move||device_kinds().iter(),
move|_label: &&'static str, i|{
let bg = if i == selected { Rgb(64,128,32) } else { Rgb(0,0,0) };
let lb = if i == selected { "[ " } else { " " };
let rb = if i == selected { " ]" } else { " " };
w_full(Tui::bg(bg, east(lb, west(rb, "FIXME device name")))) })))
w_full(bg(bg, east(lb, west(rb, "FIXME device name")))) })))
},
Some(":debug") => to.place(&h_exact(1, format!("[{:?}]", to.area()))),
Some(_) => {
@ -956,7 +956,7 @@ impl App {
impl Draw<Tui> for App {
fn draw (self, to: &mut Tui) -> Usually<XYWH<u16>> {
if let Some(e) = self.error.read().unwrap().as_ref() {
to.show(to.area(), e);
to.place_at(to.area(), e);
}
for (index, dsl) in self.mode.view.iter().enumerate() {
if let Err(e) = self.understand(to, dsl) {