mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-09-18 04:46:43 +02:00
finally adequate performance
This commit is contained in:
parent
d495d97516
commit
7eef0cfb62
7 changed files with 36 additions and 31 deletions
2
Justfile
2
Justfile
|
|
@ -53,7 +53,7 @@ prof +ARGS="new":
|
||||||
tracy +ARGS="new":
|
tracy +ARGS="new":
|
||||||
{{release}} -F prof {{ARGS}}
|
{{release}} -F prof {{ARGS}}
|
||||||
samply +ARGS="new":
|
samply +ARGS="new":
|
||||||
samply record target/release/tek {{ARGS}}
|
samply record -r 8987 target/release/tek {{ARGS}}
|
||||||
|
|
||||||
release := "reset && cargo run --release"
|
release := "reset && cargo run --release"
|
||||||
release +ARGS="new":
|
release +ARGS="new":
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,8 @@ pub fn config_load_kind <C: AsRef<Config>, L: Language> (config: C, src: L) -> U
|
||||||
//if let Some(tail) = src.tail()? {
|
//if let Some(tail) = src.tail()? {
|
||||||
match src.head()? {
|
match src.head()? {
|
||||||
Some("mode") => modes_add(&config.as_ref().modes, src.tail()),
|
Some("mode") => modes_add(&config.as_ref().modes, src.tail()),
|
||||||
Some("keys") => load_bind(&config.as_ref().binds, src.tail()),
|
Some("keys") => binds_add(&config.as_ref().binds, src.tail()),
|
||||||
Some("view") => load_view(&config.as_ref().views, src.tail()),
|
Some("view") => views_add(&config.as_ref().views, src.tail()),
|
||||||
_ => return Err(format!("Config::load: expected view/keys/mode expr, got: {src:?}").into())
|
_ => return Err(format!("Config::load: expected view/keys/mode expr, got: {src:?}").into())
|
||||||
}?;
|
}?;
|
||||||
//}
|
//}
|
||||||
|
|
@ -140,8 +140,8 @@ pub fn mode_add <T: AsMut<Mode>> (mut mode: T, dsl: impl Language) -> Usually<T>
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_bind <'a> (binds: &Binds, expr: impl Language) -> UsuallyRef<'a, ()> {
|
pub fn binds_add <'a> (binds: &Binds, expr: impl Language) -> UsuallyRef<'a, ()> {
|
||||||
//println!("\n\rload_bind: {expr:?}");
|
//println!("\n\rbinds_add: {expr:?}");
|
||||||
let name = expr.head()?.ok_or("bind: missing name")?;
|
let name = expr.head()?.ok_or("bind: missing name")?;
|
||||||
let body = expr.tail()?.unwrap_or("");
|
let body = expr.tail()?.unwrap_or("");
|
||||||
binds.try_write().unwrap().insert(name.into(), {
|
binds.try_write().unwrap().insert(name.into(), {
|
||||||
|
|
@ -164,10 +164,10 @@ pub fn load_bind <'a> (binds: &Binds, expr: impl Language) -> UsuallyRef<'a, ()>
|
||||||
// TODO
|
// TODO
|
||||||
return Ok(())
|
return Ok(())
|
||||||
} else {
|
} else {
|
||||||
return Err(format!("load_bind: invalid key: {:?}", item.expr()?.head()?).into())
|
return Err(format!("binds_add: invalid key: {:?}", item.expr()?.head()?).into())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Err(format!("load_bind: unexpected: {item:?}").into())
|
return Err(format!("binds_add: unexpected: {item:?}").into())
|
||||||
})?;
|
})?;
|
||||||
map
|
map
|
||||||
});
|
});
|
||||||
|
|
@ -177,15 +177,16 @@ pub fn load_bind <'a> (binds: &Binds, expr: impl Language) -> UsuallyRef<'a, ()>
|
||||||
/// Configuration: mode, view, and bind definitions.
|
/// Configuration: mode, view, and bind definitions.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// let source = stringify!(
|
/// use ::{std::sync::Arc, tek::{Config, modes_add, Mode}};
|
||||||
|
/// let config: Config = Default::default();
|
||||||
|
/// modes_add(&config.modes, stringify!(
|
||||||
/// (mode :menu (name Menu)
|
/// (mode :menu (name Menu)
|
||||||
/// (info Mode selector.) (keys :axis/y :confirm)
|
/// (info Mode selector.) (keys :axis/y :confirm)
|
||||||
/// (view (bg (g 0) (bsp/s :ports/out
|
/// (view (bg (g 0) (bsp/s :ports/out
|
||||||
/// (bsp/n :ports/in
|
/// (bsp/n :ports/in
|
||||||
/// (bg (g 30) (bsp/s (fixed/y 7 :logo)
|
/// (bg (g 30) (bsp/s (fixed/y 7 :logo)
|
||||||
/// (fill :dialog/menu)))))))));
|
/// (fill :dialog/menu)))))))))).unwrap();
|
||||||
/// let config: tek::Config = tek::modes_add(tek::Config::default(), source).unwrap();
|
/// let mode: Arc<Mode> = config.get_mode(":menu").unwrap();
|
||||||
/// let mode: tek::Mode = config.get_mode(":menu").unwrap();
|
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
|
|
@ -526,7 +527,7 @@ impl View<Tui, App> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Load custom view definition.
|
/// Load custom view definition.
|
||||||
pub fn load_view <'a> (views: &Views, expr: impl Language) -> UsuallyRef<'a, ()> {
|
pub fn views_add <'a> (views: &Views, expr: impl Language) -> UsuallyRef<'a, ()> {
|
||||||
views.try_write().unwrap().insert(
|
views.try_write().unwrap().insert(
|
||||||
expr.head()?.ok_or("view: missing name")?.into(),
|
expr.head()?.ok_or("view: missing name")?.into(),
|
||||||
View::new(expr.tail()?.ok_or("view: missing body")?)?.into()
|
View::new(expr.tail()?.ok_or("view: missing body")?)?.into()
|
||||||
|
|
@ -637,10 +638,10 @@ mod bind {
|
||||||
/// An map of input events (e.g. [TuiEvent]) to [Binding]s.
|
/// An map of input events (e.g. [TuiEvent]) to [Binding]s.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// let lang = stringify!(
|
/// use ::{std::sync::Arc, tek::{Bind, tengri::TuiEvent}};
|
||||||
|
/// let bind = Bind::<TuiEvent, Arc<str>>::load(&stringify!(
|
||||||
/// (@x (nop))
|
/// (@x (nop))
|
||||||
/// (@y (nop) (nop)));
|
/// (@y (nop) (nop)))).unwrap();
|
||||||
/// let bind = tek::Bind::<tek::tengri::TuiEvent, std::sync::Arc<str>>::load(&lang).unwrap();
|
|
||||||
/// assert_eq!(bind.query(&'x'.into()).map(|x|x.len()), Some(1));
|
/// assert_eq!(bind.query(&'x'.into()).map(|x|x.len()), Some(1));
|
||||||
/// //assert_eq!(bind.query(&'y'.into()).map(|x|x.len()), Some(2));
|
/// //assert_eq!(bind.query(&'y'.into()).map(|x|x.len()), Some(2));
|
||||||
/// ```
|
/// ```
|
||||||
|
|
|
||||||
|
|
@ -89,8 +89,12 @@ fn view_scene_name_theme (scene: &Scene, track_index: usize) -> (Arc<str>, ItemT
|
||||||
}
|
}
|
||||||
|
|
||||||
fn with_clips_size (show: bool, size: &Sizer, content: impl Draw<Tui>) -> impl Draw<Tui> {
|
fn with_clips_size (show: bool, size: &Sizer, content: impl Draw<Tui>) -> impl Draw<Tui> {
|
||||||
let wh = east!(size.w() as usize, "x", size.h() as usize);
|
size.of(above(
|
||||||
size.of(above(when(show, fg(Green, wh).align_se().full_wh()), content))
|
when(show, fg(Green, east!(
|
||||||
|
size.w() as usize, "x", size.h() as usize
|
||||||
|
)).align_se()),
|
||||||
|
content.align_c().full_wh()
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn view_scene_bg (
|
fn view_scene_bg (
|
||||||
|
|
|
||||||
|
|
@ -139,12 +139,12 @@ impl PianoHorizontal {
|
||||||
let buffer = self.buffer.clone();
|
let buffer = self.buffer.clone();
|
||||||
draw(move|to: &mut Tui|{
|
draw(move|to: &mut Tui|{
|
||||||
let xywh = to.area().into();
|
let xywh = to.area().into();
|
||||||
|
to.buffer().map(|to|{
|
||||||
let XYWH(x0, y0, w, _h) = xywh;
|
let XYWH(x0, y0, w, _h) = xywh;
|
||||||
let source = buffer.try_read().unwrap();
|
let source = buffer.try_read().unwrap();
|
||||||
//if h as usize != note_axis {
|
//if h as usize != note_axis {
|
||||||
//panic!("area height mismatch: {h} <> {note_axis}");
|
//panic!("area height mismatch: {h} <> {note_axis}");
|
||||||
//}
|
//}
|
||||||
if let Tui::Draw(to, ..) = to {
|
|
||||||
for (area_x, screen_x) in (x0..x0+w).enumerate() {
|
for (area_x, screen_x) in (x0..x0+w).enumerate() {
|
||||||
for (area_y, screen_y, _note) in note_y_iter(note_lo, note_hi, y0) {
|
for (area_y, screen_y, _note) in note_y_iter(note_lo, note_hi, y0) {
|
||||||
let source_x = time_start + area_x;
|
let source_x = time_start + area_x;
|
||||||
|
|
@ -163,7 +163,7 @@ impl PianoHorizontal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
Ok(Some(xywh))
|
Ok(Some(xywh))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -354,7 +354,7 @@ fn draw_viewer (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<Tui> + use<'_
|
||||||
lines.push(Line::new(x, min_db, x, y, Color::Green));
|
lines.push(Line::new(x, min_db, x, y, Color::Green));
|
||||||
t += step / 2.;
|
t += step / 2.;
|
||||||
}
|
}
|
||||||
if let Tui::Draw(buf, ..) = to {
|
to.buffer().map(|buf|{
|
||||||
Canvas::default()
|
Canvas::default()
|
||||||
.x_bounds([sample.start as f64, sample.end as f64])
|
.x_bounds([sample.start as f64, sample.end as f64])
|
||||||
.y_bounds([min_db, 0.])
|
.y_bounds([min_db, 0.])
|
||||||
|
|
@ -371,9 +371,9 @@ fn draw_viewer (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<Tui> + use<'_
|
||||||
//);
|
//);
|
||||||
})
|
})
|
||||||
.render(area, buf);
|
.render(area, buf);
|
||||||
}
|
});
|
||||||
} else {
|
} else {
|
||||||
if let Tui::Draw(buf, ..) = to {
|
to.buffer().map(|buf|{
|
||||||
Canvas::default()
|
Canvas::default()
|
||||||
.x_bounds([0.0, width as f64])
|
.x_bounds([0.0, width as f64])
|
||||||
.y_bounds([0.0, height as f64])
|
.y_bounds([0.0, height as f64])
|
||||||
|
|
@ -386,7 +386,7 @@ fn draw_viewer (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<Tui> + use<'_
|
||||||
//);
|
//);
|
||||||
})
|
})
|
||||||
.render(area, buf);
|
.render(area, buf);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
Ok(Some(xywh))
|
Ok(Some(xywh))
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
(mode :scene (keys :scene))
|
(mode :scene (keys :scene))
|
||||||
(mode :mix (keys :mix))
|
(mode :mix (keys :mix))
|
||||||
(view
|
(view
|
||||||
(bsp/n (bsp/e :transport :status)
|
(bar/n 2 (bsp/e :transport :status)
|
||||||
(bar/w 2 (align/ne :meters/output)
|
(bar/w 2 (align/ne :meters/output)
|
||||||
(bar/e 2 (align/nw :meters/input)
|
(bar/e 2 (align/nw :meters/input)
|
||||||
(full/xy (pad/xy 2 1 (align/c
|
(full/xy (pad/xy 2 1 (align/c
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
(bar/s 2 :tracks/devices
|
(bar/s 2 :tracks/devices
|
||||||
(bar/s 2 :tracks/names
|
(bar/s 2 :tracks/names
|
||||||
(bar/n 2 :tracks/inputs
|
(bar/n 2 :tracks/inputs
|
||||||
(bar/e 16 (bg (g 50) :scenes/names)
|
(bar/e 12 (bg (g 50) :scenes/names)
|
||||||
(align/c :scenes/clips))))))))))))))
|
(align/c :scenes/clips))))))))))))))
|
||||||
|
|
||||||
(keys :clock (@space clock/toggle 0)
|
(keys :clock (@space clock/toggle 0)
|
||||||
|
|
|
||||||
2
tengri
2
tengri
|
|
@ -1 +1 @@
|
||||||
Subproject commit b318d498e544fa65bbf3a3ff4dabde166352b045
|
Subproject commit 48aaa3933aadd2d795b6652a244fce179d7072bf
|
||||||
Loading…
Add table
Add a link
Reference in a new issue