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 {
|
impl<'t> DslNs<'t, Arc<str>> for App {
|
||||||
dsl_exprs!(|app| -> Arc<str> {});
|
dsl_exprs!(|app| -> Arc<str> {});
|
||||||
dsl_words!(|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()))
|
Ok(dsl.src()?.map(|x|x.into()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,15 @@ use crate::*;
|
||||||
|
|
||||||
impl Content<TuiOut> for App {
|
impl Content<TuiOut> for App {
|
||||||
fn content (&self) -> impl Render<TuiOut> + '_ {
|
fn content (&self) -> impl Render<TuiOut> + '_ {
|
||||||
Stack::above(move|add|for dsl in self.mode.view.iter() {
|
let mode = self.mode.clone();
|
||||||
add(&Fill::xy(self.view(dsl.as_ref())));
|
Stack::above(move|add|for dsl in mode.view.iter() { add(&self.view(dsl)) })
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
fn view <'t, D: Dsl> (&'t self, index: D) -> TuiBox<'t> {
|
fn view <'t> (&'t self, dsl: impl Dsl) -> impl Render<TuiOut> + 't {
|
||||||
match index.src() {
|
let view: TuiBox<'t> = self.from(dsl).unwrap().unwrap();
|
||||||
Ok(Some(src)) => render_dsl(self, src),
|
view
|
||||||
Ok(None) => Box::new(Tui::fg(Color::Rgb(192, 192, 192), "empty view")),
|
|
||||||
Err(e) => Box::new(format!("{e}")),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
pub fn update_clock (&self) {
|
pub fn update_clock (&self) {
|
||||||
ViewCache::update_clock(&self.project.clock.view_cache, self.clock(), self.size.w() > 80)
|
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>;
|
type TuiBox<'t> = Box<dyn Render<TuiOut> + 't>;
|
||||||
|
|
||||||
fn render_dsl <'t> (
|
fn render_error (err: impl Error, src: &str) -> impl Render<TuiOut> {
|
||||||
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),
|
|
||||||
};
|
|
||||||
let (fg_1, bg_1) = (Color::Rgb(240, 160, 100), Color::Rgb(48, 0, 0));
|
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_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 (fg_3, bg_3) = (Color::Rgb(250, 200, 120), Color::Rgb(0, 0, 0));
|
||||||
let bg = Color::Rgb(24, 0, 0);
|
let bg = Color::Rgb(24, 0, 0);
|
||||||
Box::new(col! {
|
col! {
|
||||||
Tui::fg(bg, Fixed::y(1, Fill::x(RepeatH("▄")))),
|
Tui::fg(bg, Fixed::y(1, Fill::x(RepeatH("▄")))),
|
||||||
Tui::bg(bg, col! {
|
Tui::bg(bg, col! {
|
||||||
Fill::x(Bsp::e(
|
Fill::x(Bsp::e(
|
||||||
Tui::bold(true, Tui::fg_bg(fg_1, bg_1, " Render error: ")),
|
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} ")))),
|
Fill::x(Align::x(Tui::fg_bg(fg_3, bg_3, format!(" {src} ")))),
|
||||||
}),
|
}),
|
||||||
Tui::fg(bg, Fixed::y(1, Fill::x(RepeatH("▀")))),
|
Tui::fg(bg, Fixed::y(1, Fill::x(RepeatH("▀")))),
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'t> DslNs<'t, TuiBox<'t>> for App {
|
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")))) }))) },
|
Fill::x(Tui::bg(bg, Bsp::e(lb, Bsp::w(rb, "FIXME device name")))) }))) },
|
||||||
});
|
});
|
||||||
/// Resolve an expression if known.
|
/// 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()? {
|
if let Some(head) = dsl.expr().head()? {
|
||||||
for (key, value) in Self::EXPRS.0.iter() {
|
for (key, value) in Self::EXPRS.0.iter() {
|
||||||
if head == *key {
|
if head == *key {
|
||||||
|
|
@ -180,13 +170,13 @@ impl<'t> DslNs<'t, TuiBox<'t>> for App {
|
||||||
return Ok(None)
|
return Ok(None)
|
||||||
}
|
}
|
||||||
/// Resolve a symbol if known.
|
/// 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()? {
|
if let Some(dsl) = dsl.word()? {
|
||||||
let views = self.config.views.read().unwrap();
|
let views = self.config.views.read().unwrap();
|
||||||
if let Some(view) = views.get(dsl) {
|
if let Some(view) = views.get(dsl) {
|
||||||
let view = view.clone();
|
let view = view.clone();
|
||||||
std::mem::drop(views);
|
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 {
|
for (word, get) in Self::WORDS.0 {
|
||||||
if dsl == *word {
|
if dsl == *word {
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,31 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
|
type Add<'a> = &'a dyn FnMut(&dyn Render<TuiOut>);
|
||||||
|
|
||||||
impl Arrangement {
|
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|{
|
Stack::south(move|add|{
|
||||||
add(&Fixed::y(1,
|
add(&Fixed::y(1,
|
||||||
Bsp::e(Fixed::x(20, Align::w(button_3("i", "nput ", format!("{}", self.midi_ins.len()), false))),
|
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)),
|
Bsp::w(Fixed::x(4, button_2("I", "+", false)),
|
||||||
Stack::east(move|add|{
|
Stack::east(move|add|for (_index, track, _x1, _x2) in self.tracks_with_sizes() {
|
||||||
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!(
|
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.monitoring, Tui::fg(Green, "mon "), "mon "),
|
||||||
Either(track.sequencer.recording, Tui::fg(Red, "rec "), "rec "),
|
Either(track.sequencer.recording, Tui::fg(Red, "rec "), "rec "),
|
||||||
Either(track.sequencer.overdub, Tui::fg(Yellow, "dub "), "dub "),
|
Either(track.sequencer.overdub, Tui::fg(Yellow, "dub "), "dub "),
|
||||||
)))))
|
)))))
|
||||||
}
|
|
||||||
})))));
|
})))));
|
||||||
for (_index, port) in self.midi_ins().iter().enumerate() {
|
for (_index, port) in self.midi_ins().iter().enumerate() {
|
||||||
add(&Fixed::y(1, Bsp::e(
|
add(&Fixed::y(1, Bsp::e(
|
||||||
Fixed::x(20, Align::w(Bsp::e(" ● ",
|
Fixed::x(20, Align::w(Bsp::e(" ● ",
|
||||||
Tui::bold(true, Tui::fg(Rgb(255,255,255), port.port_name()))))),
|
Tui::bold(true, Tui::fg(Rgb(255,255,255), port.port_name()))))),
|
||||||
Bsp::w(Fixed::x(4, ()),
|
Bsp::w(Fixed::x(4, ()),
|
||||||
Stack::east(move|add|{
|
Stack::east(move|add|for (_index, track, _x1, _x2) in self.tracks_with_sizes() {
|
||||||
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!(
|
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.monitoring, Tui::fg(Green, " ● "), " · "),
|
||||||
Either(track.sequencer.recording, Tui::fg(Red, " ● "), " · "),
|
Either(track.sequencer.recording, Tui::fg(Red, " ● "), " · "),
|
||||||
Either(track.sequencer.overdub, Tui::fg(Yellow, " ● "), " · "),
|
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