tengri 0.5.2: specify Map types/lifetimes

This commit is contained in:
🪞👃🪞 2025-04-04 01:54:20 +03:00
parent 9c95ca9613
commit d83be2ef1f
8 changed files with 36 additions and 35 deletions

20
Cargo.lock generated
View file

@ -1580,8 +1580,8 @@ dependencies = [
[[package]]
name = "tengri"
version = "0.5.1"
source = "git+https://codeberg.org/unspeaker/tengri?rev=829d35b#829d35b61fc4323273613695f02bb1e6bfde0cbd"
version = "0.5.2"
source = "git+https://codeberg.org/unspeaker/tengri?rev=86236b7#86236b76cd421a67ece0633d38436cd38c770d9e"
dependencies = [
"tengri_dsl",
"tengri_input",
@ -1591,8 +1591,8 @@ dependencies = [
[[package]]
name = "tengri_dsl"
version = "0.5.1"
source = "git+https://codeberg.org/unspeaker/tengri?rev=829d35b#829d35b61fc4323273613695f02bb1e6bfde0cbd"
version = "0.5.2"
source = "git+https://codeberg.org/unspeaker/tengri?rev=86236b7#86236b76cd421a67ece0633d38436cd38c770d9e"
dependencies = [
"itertools 0.14.0",
"konst",
@ -1601,24 +1601,24 @@ dependencies = [
[[package]]
name = "tengri_input"
version = "0.5.1"
source = "git+https://codeberg.org/unspeaker/tengri?rev=829d35b#829d35b61fc4323273613695f02bb1e6bfde0cbd"
version = "0.5.2"
source = "git+https://codeberg.org/unspeaker/tengri?rev=86236b7#86236b76cd421a67ece0633d38436cd38c770d9e"
dependencies = [
"tengri_dsl",
]
[[package]]
name = "tengri_output"
version = "0.5.1"
source = "git+https://codeberg.org/unspeaker/tengri?rev=829d35b#829d35b61fc4323273613695f02bb1e6bfde0cbd"
version = "0.5.2"
source = "git+https://codeberg.org/unspeaker/tengri?rev=86236b7#86236b76cd421a67ece0633d38436cd38c770d9e"
dependencies = [
"tengri_dsl",
]
[[package]]
name = "tengri_tui"
version = "0.5.1"
source = "git+https://codeberg.org/unspeaker/tengri?rev=829d35b#829d35b61fc4323273613695f02bb1e6bfde0cbd"
version = "0.5.2"
source = "git+https://codeberg.org/unspeaker/tengri?rev=86236b7#86236b76cd421a67ece0633d38436cd38c770d9e"
dependencies = [
"atomic_float",
"better-panic",

View file

@ -19,7 +19,7 @@ lto = false
[workspace.dependencies.tengri]
git = "https://codeberg.org/unspeaker/tengri"
rev = "829d35b"
rev = "86236b7"
features = [ "tui", "dsl" ]
[workspace.dependencies]

View file

@ -1,7 +1,7 @@
(bsp/n
(fixed/y 2 :transport)
(fixed/y 1 :transport)
(bsp/s
(fixed/y 2 :status)
(fixed/y 1 :status)
(fill/xy
(bsp/a
(fill/xy

View file

@ -53,9 +53,9 @@ pub struct TekCli {
/// Multi-track MIDI sequencer.
Arranger {
/// Number of scenes
#[arg(short = 'y', long, default_value_t = 12)] scenes: usize,
#[arg(short = 'y', long, default_value_t = 4)] scenes: usize,
/// Number of tracks
#[arg(short = 'x', long, default_value_t = 16)] tracks: usize,
#[arg(short = 'x', long, default_value_t = 4)] tracks: usize,
/// Width of tracks
#[arg(short = 'w', long, default_value_t = 12)] track_width: usize,
},

View file

@ -48,7 +48,7 @@ impl<'a> Content<TuiOut> for ArrangerView<'a> {
let bg = |x|Tui::bg(Reset, x);
let track_scroll = |x|Bsp::s(&self.track_scroll, x);
let scene_scroll = |x|Bsp::e(&self.scene_scroll, x);
ins(tracks(outs(bg(track_scroll(scene_scroll(self.scenes()))))))
ins(scene_scroll(track_scroll(tracks(outs(bg(self.scenes()))))))
}
}

View file

@ -119,21 +119,23 @@ pub(crate) 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|(index, name, connections, y, y2), _|map_south(y as u16, (y2-y) as u16, Bsp::s(
Fill::x(Tui::bold(true, Tui::fg_bg(fg, bg, Align::w(Bsp::e(" 󰣲 ", name))))),
Map::new(||connections.iter(), move|connect, index|map_south(index as u16, 1,
Fill::x(Align::w(Tui::bold(false, Tui::fg_bg(fg, bg,
&connect.info)))))))))
move|(index, name, connections, y, y2): (usize, &'a Arc<str>, &'a [PortConnect], usize, usize), _|
map_south(y as u16, (y2-y) as u16, Bsp::s(
Fill::x(Tui::bold(true, Tui::fg_bg(fg, bg, Align::w(Bsp::e(" 󰣲 ", name))))),
Map::new(||connections.iter(), move|connect: &'a PortConnect, index|map_south(index as u16, 1,
Fill::x(Align::w(Tui::bold(false, Tui::fg_bg(fg, bg,
&connect.info)))))))))
}
pub(crate) fn io_conns <'a, T: PortsSizes<'a>> (
fg: Color, bg: Color, iter: impl Fn()->T + Send + Sync + 'a
) -> impl Content<TuiOut> + 'a {
Map::new(iter,
move|(index, name, connections, y, y2), _|map_south(y as u16, (y2-y) as u16, Bsp::s(
Fill::x(Tui::bold(true, wrap(bg, fg, Fill::x(Align::w("▞▞▞▞ ▞▞▞▞"))))),
Map::new(||connections.iter(), move|connect, index|map_south(index as u16, 1,
Fill::x(Align::w(Tui::bold(false, wrap(bg, fg, Fill::x(""))))))))))
move|(index, name, connections, y, y2): (usize, &'a Arc<str>, &'a [PortConnect], usize, usize), _|
map_south(y as u16, (y2-y) as u16, Bsp::s(
Fill::x(Tui::bold(true, wrap(bg, fg, Fill::x(Align::w("▞▞▞▞ ▞▞▞▞"))))),
Map::new(||connections.iter(), move|connect, index|map_south(index as u16, 1,
Fill::x(Align::w(Tui::bold(false, wrap(bg, fg, Fill::x(""))))))))))
}
pub(crate) fn per_track_top <'a, T: Content<TuiOut> + 'a, U: TracksSizes<'a>> (
@ -141,14 +143,13 @@ pub(crate) fn per_track_top <'a, T: Content<TuiOut> + 'a, U: TracksSizes<'a>> (
tracks: impl Fn() -> U + Send + Sync + 'a,
callback: impl Fn(usize, &'a Track)->T + Send + Sync + 'a
) -> impl Content<TuiOut> + 'a {
Align::x(Tui::bg(Reset, Map::new(tracks, move|(index, track, x1, x2), _|{
let width = (x2 - x1) as u16;
map_east(x1 as u16, width, Fixed::x(width, Tui::fg_bg(
track.color.lightest.rgb,
track.color.base.rgb,
callback(index, track)
)))
})))
Align::x(Tui::bg(Reset, Map::new(tracks,
move|(index, track, x1, x2): (usize, &'a Track, usize, usize), _|{
let width = (x2 - x1) as u16;
map_east(x1 as u16, width, Fixed::x(width, Tui::fg_bg(
track.color.lightest.rgb,
track.color.base.rgb,
callback(index, track))))})))
}
pub(crate) fn per_track <'a, T: Content<TuiOut> + 'a, U: TracksSizes<'a>> (

View file

@ -41,7 +41,7 @@ impl Tek {
}
/// Height available to display tracks.
pub(crate) fn h_tracks_area (&self) -> u16 {
self.h().saturating_sub(self.h_inputs() + self.h_outputs() + 10)
self.h().saturating_sub(self.h_inputs() + self.h_outputs())
}
/// Height available to display tracks.
pub(crate) fn h_scenes_area (&self) -> u16 {

View file

@ -35,7 +35,7 @@ impl<'a> ArrangerView<'a> {
||self.tracks_with_sizes_scrolled(),
move|track_index, track|Map::new(
||self.scenes_with_track_colors(),
move|(scene_index, scene, y1, y2, prev_scene): SceneWithColor, _|
move|(scene_index, scene, y1, y2, prev_scene): SceneWithColor<'a>, _|
view_scene_clip(
self.width_mid,
(1 + y2 - y1) as u16,