mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 03:36:41 +01:00
This commit is contained in:
parent
34070de5f7
commit
1fc37a5679
4 changed files with 29 additions and 41 deletions
|
|
@ -3,7 +3,7 @@ use crate::*;
|
|||
impl<'t> DslNs<'t, Arc<str>> for App {
|
||||
dsl_exprs!(|app| -> Arc<str> {});
|
||||
dsl_words!(|app| -> Arc<str> {});
|
||||
fn from_literal <D: Dsl> (&self, dsl: &D) -> Perhaps<Arc<str>> {
|
||||
fn from_literal (&self, dsl: impl Dsl) -> Perhaps<Arc<str>> {
|
||||
Ok(dsl.src()?.map(|x|x.into()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,19 +2,15 @@ use crate::*;
|
|||
|
||||
impl Content<TuiOut> for App {
|
||||
fn content (&self) -> impl Render<TuiOut> + '_ {
|
||||
Stack::above(move|add|for dsl in self.mode.view.iter() {
|
||||
add(&Fill::xy(self.view(dsl.as_ref())));
|
||||
})
|
||||
let mode = self.mode.clone();
|
||||
Stack::above(move|add|for dsl in mode.view.iter() { add(&self.view(dsl)) })
|
||||
}
|
||||
}
|
||||
|
||||
impl App {
|
||||
fn view <'t, D: Dsl> (&'t self, index: D) -> TuiBox<'t> {
|
||||
match index.src() {
|
||||
Ok(Some(src)) => render_dsl(self, src),
|
||||
Ok(None) => Box::new(Tui::fg(Color::Rgb(192, 192, 192), "empty view")),
|
||||
Err(e) => Box::new(format!("{e}")),
|
||||
}
|
||||
fn view <'t> (&'t self, dsl: impl Dsl) -> impl Render<TuiOut> + 't {
|
||||
let view: TuiBox<'t> = self.from(dsl).unwrap().unwrap();
|
||||
view
|
||||
}
|
||||
pub fn update_clock (&self) {
|
||||
ViewCache::update_clock(&self.project.clock.view_cache, self.clock(), self.size.w() > 80)
|
||||
|
|
@ -23,28 +19,22 @@ impl App {
|
|||
|
||||
type TuiBox<'t> = Box<dyn Render<TuiOut> + 't>;
|
||||
|
||||
fn render_dsl <'t> (
|
||||
state: &'t impl DslNs<'t, TuiBox<'t>>,
|
||||
src: &str
|
||||
) -> TuiBox<'t> {
|
||||
let err: Option<Box<dyn Error>> = match state.from(&src) {
|
||||
Ok(Some(value)) => return value, Ok(None) => None, Err(e) => Some(e),
|
||||
};
|
||||
fn render_error (err: impl Error, src: &str) -> impl Render<TuiOut> {
|
||||
let (fg_1, bg_1) = (Color::Rgb(240, 160, 100), Color::Rgb(48, 0, 0));
|
||||
let (fg_2, bg_2) = (Color::Rgb(250, 200, 180), Color::Rgb(48, 0, 0));
|
||||
let (fg_3, bg_3) = (Color::Rgb(250, 200, 120), Color::Rgb(0, 0, 0));
|
||||
let bg = Color::Rgb(24, 0, 0);
|
||||
Box::new(col! {
|
||||
col! {
|
||||
Tui::fg(bg, Fixed::y(1, Fill::x(RepeatH("▄")))),
|
||||
Tui::bg(bg, col! {
|
||||
Fill::x(Bsp::e(
|
||||
Tui::bold(true, Tui::fg_bg(fg_1, bg_1, " Render error: ")),
|
||||
Tui::fg_bg(fg_2, bg_2, err.map(|e|format!(" {e} "))),
|
||||
Tui::fg_bg(fg_2, bg_2, format!(" {err} ")),
|
||||
)),
|
||||
Fill::x(Align::x(Tui::fg_bg(fg_3, bg_3, format!(" {src} ")))),
|
||||
}),
|
||||
Tui::fg(bg, Fixed::y(1, Fill::x(RepeatH("▀")))),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<'t> DslNs<'t, TuiBox<'t>> for App {
|
||||
|
|
@ -169,7 +159,7 @@ impl<'t> DslNs<'t, TuiBox<'t>> for App {
|
|||
Fill::x(Tui::bg(bg, Bsp::e(lb, Bsp::w(rb, "FIXME device name")))) }))) },
|
||||
});
|
||||
/// Resolve an expression if known.
|
||||
fn from_expr <D: Dsl> (&self, dsl: &D) -> Perhaps<TuiBox<'t>> {
|
||||
fn from_expr (&self, dsl: impl Dsl) -> Perhaps<TuiBox<'t>> {
|
||||
if let Some(head) = dsl.expr().head()? {
|
||||
for (key, value) in Self::EXPRS.0.iter() {
|
||||
if head == *key {
|
||||
|
|
@ -180,13 +170,13 @@ impl<'t> DslNs<'t, TuiBox<'t>> for App {
|
|||
return Ok(None)
|
||||
}
|
||||
/// Resolve a symbol if known.
|
||||
fn from_word <D: Dsl> (&self, dsl: &D) -> Perhaps<TuiBox<'t>> {
|
||||
fn from_word (&self, dsl: impl Dsl) -> Perhaps<TuiBox<'t>> {
|
||||
if let Some(dsl) = dsl.word()? {
|
||||
let views = self.config.views.read().unwrap();
|
||||
if let Some(view) = views.get(dsl) {
|
||||
let view = view.clone();
|
||||
std::mem::drop(views);
|
||||
return Ok(Some(render_dsl(self, view.as_ref())))
|
||||
return Ok(Some(self.view(view.as_ref())))
|
||||
}
|
||||
for (word, get) in Self::WORDS.0 {
|
||||
if dsl == *word {
|
||||
|
|
|
|||
|
|
@ -1,33 +1,31 @@
|
|||
use crate::*;
|
||||
|
||||
type Add<'a> = &'a dyn FnMut(&dyn Render<TuiOut>);
|
||||
|
||||
impl Arrangement {
|
||||
pub fn view_inputs <'a> (&'a self, _theme: ItemTheme) -> impl Content<TuiOut> + 'a {
|
||||
pub fn view_inputs (&self, _theme: ItemTheme) -> impl Content<TuiOut> + '_ {
|
||||
Stack::south(move|add|{
|
||||
add(&Fixed::y(1,
|
||||
Bsp::e(Fixed::x(20, Align::w(button_3("i", "nput ", format!("{}", self.midi_ins.len()), false))),
|
||||
Bsp::w(Fixed::x(4, button_2("I", "+", false)),
|
||||
Stack::east(move|add|{
|
||||
for (_index, track, _x1, _x2) in self.tracks_with_sizes() {
|
||||
add(&Tui::bg(track.color.dark.rgb, Align::w(Fixed::x(track.width as u16, row!(
|
||||
Either(track.sequencer.monitoring, Tui::fg(Green, "mon "), "mon "),
|
||||
Either(track.sequencer.recording, Tui::fg(Red, "rec "), "rec "),
|
||||
Either(track.sequencer.overdub, Tui::fg(Yellow, "dub "), "dub "),
|
||||
)))))
|
||||
}
|
||||
Stack::east(move|add|for (_index, track, _x1, _x2) in self.tracks_with_sizes() {
|
||||
add(&Tui::bg(track.color.dark.rgb, Align::w(Fixed::x(track.width as u16, row!(
|
||||
Either(track.sequencer.monitoring, Tui::fg(Green, "mon "), "mon "),
|
||||
Either(track.sequencer.recording, Tui::fg(Red, "rec "), "rec "),
|
||||
Either(track.sequencer.overdub, Tui::fg(Yellow, "dub "), "dub "),
|
||||
)))))
|
||||
})))));
|
||||
for (_index, port) in self.midi_ins().iter().enumerate() {
|
||||
add(&Fixed::y(1, Bsp::e(
|
||||
Fixed::x(20, Align::w(Bsp::e(" ● ",
|
||||
Tui::bold(true, Tui::fg(Rgb(255,255,255), port.port_name()))))),
|
||||
Bsp::w(Fixed::x(4, ()),
|
||||
Stack::east(move|add|{
|
||||
for (_index, track, _x1, _x2) in self.tracks_with_sizes() {
|
||||
add(&Tui::bg(track.color.darker.rgb, Align::w(Fixed::x(track.width as u16, row!(
|
||||
Either(track.sequencer.monitoring, Tui::fg(Green, " ● "), " · "),
|
||||
Either(track.sequencer.recording, Tui::fg(Red, " ● "), " · "),
|
||||
Either(track.sequencer.overdub, Tui::fg(Yellow, " ● "), " · "),
|
||||
)))))
|
||||
}
|
||||
Stack::east(move|add|for (_index, track, _x1, _x2) in self.tracks_with_sizes() {
|
||||
add(&Tui::bg(track.color.darker.rgb, Align::w(Fixed::x(track.width as u16, row!(
|
||||
Either(track.sequencer.monitoring, Tui::fg(Green, " ● "), " · "),
|
||||
Either(track.sequencer.recording, Tui::fg(Red, " ● "), " · "),
|
||||
Either(track.sequencer.overdub, Tui::fg(Yellow, " ● "), " · "),
|
||||
)))))
|
||||
})))));
|
||||
}
|
||||
})
|
||||
|
|
|
|||
2
deps/tengri
vendored
2
deps/tengri
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit b98fccd98ba13be8eabe29d66621a15d025b2042
|
||||
Subproject commit 420a40054e9322097ac8bd9a0bbb340b86ca463f
|
||||
Loading…
Add table
Add a link
Reference in a new issue