mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
This commit is contained in:
parent
34070de5f7
commit
fd26b12955
18 changed files with 243 additions and 194 deletions
|
|
@ -133,7 +133,7 @@ impl App {
|
|||
}
|
||||
}
|
||||
|
||||
fn wrap_dialog (dialog: impl Content<TuiOut>) -> impl Content<TuiOut> {
|
||||
fn wrap_dialog (dialog: impl Render<TuiOut>) -> impl Render<TuiOut> {
|
||||
Fixed::xy(70, 23, Tui::fg_bg(Rgb(255,255,255), Rgb(16,16,16), Bsp::b(
|
||||
Repeat(" "), Outer(true, Style::default().fg(Tui::g(96))).enclose(dialog))))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,9 +33,10 @@ handle!(TuiIn:|self: App, input|{
|
|||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum Axis { X, Y, Z, I }
|
||||
|
||||
impl<'t> DslNs<'t, AppCommand> for App {
|
||||
dsl_exprs!(|app| -> AppCommand { /* TODO */ });
|
||||
dsl_words!(|app| -> AppCommand {
|
||||
impl<'a> DslNs<'a, AppCommand> for App {}
|
||||
impl<'a> DslNsExprs<'a, AppCommand> for App {}
|
||||
impl<'a> DslNsWords<'a, AppCommand> for App {
|
||||
dsl_words!('a |app| -> AppCommand {
|
||||
"x/inc" => AppCommand::Inc { axis: Axis::X },
|
||||
"x/dec" => AppCommand::Dec { axis: Axis::X },
|
||||
"y/inc" => AppCommand::Inc { axis: Axis::Y },
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
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>> {
|
||||
impl<'a> DslNs<'a, Arc<str>> for App {
|
||||
fn from_literal (&self, dsl: impl Dsl) -> Perhaps<Arc<str>> {
|
||||
Ok(dsl.src()?.map(|x|x.into()))
|
||||
}
|
||||
}
|
||||
impl<'a> DslNsWords<'a, Arc<str>> for App {}
|
||||
impl<'a> DslNsExprs<'a, Arc<str>> for App {}
|
||||
|
||||
impl<'t> DslNs<'t, bool> for App {
|
||||
dsl_words!(|app| -> bool {
|
||||
impl<'a> DslNs<'a, bool> for App {}
|
||||
impl<'a> DslNsExprs<'a, bool> for App {}
|
||||
impl<'a> DslNsWords<'a, bool> for App {
|
||||
dsl_words!('a |app| -> bool {
|
||||
":mode/editor" => app.project.editor.is_some(),
|
||||
|
||||
":focused/dialog" => !matches!(app.dialog, Dialog::None),
|
||||
|
|
@ -29,15 +31,16 @@ impl<'t> DslNs<'t, bool> for App {
|
|||
":focused/mix" => !app.editor_focused() && matches!(app.selection(),
|
||||
Selection::Mix),
|
||||
});
|
||||
//fn from_literal <D: Dsl> (&self, dsl: &D) -> Perhaps<Arc<str>> {
|
||||
//TODO
|
||||
//}
|
||||
}
|
||||
|
||||
impl<'t> DslNs<'t, ItemTheme> for App {}
|
||||
impl<'a> DslNs<'a, ItemTheme> for App {}
|
||||
impl<'a> DslNsWords<'a, ItemTheme> for App {}
|
||||
impl<'a> DslNsExprs<'a, ItemTheme> for App {}
|
||||
|
||||
impl<'t> DslNs<'t, Dialog> for App {
|
||||
dsl_words!(|app| -> Dialog {
|
||||
impl<'a> DslNs<'a, Dialog> for App {}
|
||||
impl<'a> DslNsExprs<'a, Dialog> for App {}
|
||||
impl<'a> DslNsWords<'a, Dialog> for App {
|
||||
dsl_words!('a |app| -> Dialog {
|
||||
":dialog/none" => Dialog::None,
|
||||
":dialog/options" => Dialog::Options,
|
||||
":dialog/device" => Dialog::Device(0),
|
||||
|
|
@ -59,8 +62,10 @@ impl<'t> DslNs<'t, Dialog> for App {
|
|||
});
|
||||
}
|
||||
|
||||
impl<'t> DslNs<'t, Selection> for App {
|
||||
dsl_words!(|app| -> Selection {
|
||||
impl<'a> DslNs<'a, Selection> for App {}
|
||||
impl<'a> DslNsExprs<'a, Selection> for App {}
|
||||
impl<'a> DslNsWords<'a, Selection> for App {
|
||||
dsl_words!('a |app| -> Selection {
|
||||
":select/scene" => app.selection().select_scene(app.tracks().len()),
|
||||
":select/scene/next" => app.selection().select_scene_next(app.scenes().len()),
|
||||
":select/scene/prev" => app.selection().select_scene_prev(),
|
||||
|
|
@ -70,33 +75,42 @@ impl<'t> DslNs<'t, Selection> for App {
|
|||
});
|
||||
}
|
||||
|
||||
impl<'t> DslNs<'t, Color> for App {
|
||||
dsl_words!(|app| -> Color {
|
||||
impl<'a> DslNs<'a, Color> for App {}
|
||||
impl<'a> DslNsWords<'a, Color> for App {
|
||||
dsl_words!('a |app| -> Color {
|
||||
":color/bg" => Color::Rgb(28, 32, 36),
|
||||
});
|
||||
dsl_exprs!(|app| -> Color {
|
||||
"g" (n: u8) => Color::Rgb(n, n, n),
|
||||
}
|
||||
impl<'a> DslNsExprs<'a, Color> for App {
|
||||
dsl_exprs!('a |app| -> Color {
|
||||
"g" (n: u8) => Color::Rgb(n, n, n),
|
||||
"rgb" (r: u8, g: u8, b: u8) => Color::Rgb(r, g, b),
|
||||
});
|
||||
}
|
||||
|
||||
impl<'t> DslNs<'t, Option<u7>> for App {
|
||||
dsl_words!(|app| -> Option<u7> {
|
||||
impl<'a> DslNs<'a, Option<u7>> for App {}
|
||||
impl<'a> DslNsExprs<'a, Option<u7>> for App {}
|
||||
impl<'a> DslNsWords<'a, Option<u7>> for App {
|
||||
dsl_words!('a |app| -> Option<u7> {
|
||||
":editor/pitch" => Some(
|
||||
(app.editor().as_ref().map(|e|e.get_note_pos()).unwrap() as u8).into()
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
impl<'t> DslNs<'t, Option<usize>> for App {
|
||||
dsl_words!(|app| -> Option<usize> {
|
||||
impl<'a> DslNs<'a, Option<usize>> for App {}
|
||||
impl<'a> DslNsExprs<'a, Option<usize>> for App {}
|
||||
impl<'a> DslNsWords<'a, Option<usize>> for App {
|
||||
dsl_words!('a |app| -> Option<usize> {
|
||||
":selected/scene" => app.selection().scene(),
|
||||
":selected/track" => app.selection().track(),
|
||||
});
|
||||
}
|
||||
|
||||
impl<'t> DslNs<'t, Option<Arc<RwLock<MidiClip>>>> for App {
|
||||
dsl_words!(|app| -> Option<Arc<RwLock<MidiClip>>> {
|
||||
impl<'a> DslNs<'a, Option<Arc<RwLock<MidiClip>>>> for App {}
|
||||
impl<'a> DslNsExprs<'a, Option<Arc<RwLock<MidiClip>>>> for App {}
|
||||
impl<'a> DslNsWords<'a, Option<Arc<RwLock<MidiClip>>>> for App {
|
||||
dsl_words!('a |app| -> Option<Arc<RwLock<MidiClip>>> {
|
||||
":selected/clip" => if let Selection::TrackClip { track, scene } = app.selection() {
|
||||
app.scenes()[*scene].clips[*track].clone()
|
||||
} else {
|
||||
|
|
@ -105,18 +119,63 @@ impl<'t> DslNs<'t, Option<Arc<RwLock<MidiClip>>>> for App {
|
|||
});
|
||||
}
|
||||
|
||||
dsl_ns! { num |app: App|
|
||||
u8;
|
||||
u16 => {
|
||||
impl<'a> DslNs<'a, u8> for App {
|
||||
fn from_literal (&self, dsl: impl Dsl) -> Perhaps<u8> {
|
||||
Ok(if let Some(src) = dsl.src()? {
|
||||
Some(to_number(src)? as u8)
|
||||
} else {
|
||||
None
|
||||
})
|
||||
}
|
||||
}
|
||||
impl<'a> DslNsWords<'a, u8> for App {}
|
||||
impl<'a> DslNsExprs<'a, u8> for App {}
|
||||
|
||||
impl<'a> DslNs<'a, u16> for App {
|
||||
fn from_literal (&self, dsl: impl Dsl) -> Perhaps<u16> {
|
||||
Ok(if let Some(src) = dsl.src()? {
|
||||
Some(to_number(src)? as u16)
|
||||
} else {
|
||||
None
|
||||
})
|
||||
}
|
||||
}
|
||||
impl<'a> DslNsWords<'a, u16> for App {
|
||||
dsl_words!('a |app| -> u16 {
|
||||
":w/sidebar" => app.project.w_sidebar(app.editor().is_some()),
|
||||
":h/sample-detail" => 6.max(app.height() as u16 * 3 / 9),
|
||||
};
|
||||
usize => {
|
||||
});
|
||||
}
|
||||
impl<'a> DslNsExprs<'a, u16> for App {}
|
||||
|
||||
impl<'a> DslNs<'a, usize> for App {
|
||||
fn from_literal (&self, dsl: impl Dsl) -> Perhaps<usize> {
|
||||
Ok(if let Some(src) = dsl.src()? {
|
||||
Some(to_number(src)? as usize)
|
||||
} else {
|
||||
None
|
||||
})
|
||||
}
|
||||
}
|
||||
impl<'a> DslNsWords<'a, usize> for App {
|
||||
dsl_words!('a |app| -> usize {
|
||||
":scene-count" => app.scenes().len(),
|
||||
":track-count" => app.tracks().len(),
|
||||
":device-kind" => app.dialog.device_kind().unwrap_or(0),
|
||||
":device-kind/next" => app.dialog.device_kind_next().unwrap_or(0),
|
||||
":device-kind/prev" => app.dialog.device_kind_prev().unwrap_or(0),
|
||||
};
|
||||
isize;
|
||||
});
|
||||
}
|
||||
impl<'a> DslNsExprs<'a, usize> for App {}
|
||||
|
||||
impl<'a> DslNs<'a, isize> for App {
|
||||
fn from_literal (&self, dsl: impl Dsl) -> Perhaps<isize> {
|
||||
Ok(if let Some(src) = dsl.src()? {
|
||||
Some(to_number(src)? as isize)
|
||||
} else {
|
||||
None
|
||||
})
|
||||
}
|
||||
}
|
||||
impl<'a> DslNsWords<'a, isize> for App {}
|
||||
impl<'a> DslNsExprs<'a, isize> for App {}
|
||||
|
|
|
|||
|
|
@ -1,97 +1,103 @@
|
|||
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())));
|
||||
})
|
||||
impl Render<TuiOut> for App {
|
||||
fn render (&self, to: &mut TuiOut) {
|
||||
to.place(to.area(), &Stack::above(|add|for dsl in self.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 <'a> (&'a self, dsl: impl Dsl + 'a) -> TuiBox<'a> {
|
||||
self.from(dsl).unwrap().unwrap()
|
||||
}
|
||||
pub fn update_clock (&self) {
|
||||
ViewCache::update_clock(&self.project.clock.view_cache, self.clock(), self.size.w() > 80)
|
||||
}
|
||||
}
|
||||
|
||||
type TuiBox<'t> = Box<dyn Render<TuiOut> + 't>;
|
||||
type TuiBox<'a> = Box<dyn Render<TuiOut> + 'a>;
|
||||
|
||||
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 {
|
||||
dsl_exprs!(|app| -> TuiBox<'t> {
|
||||
"text" (tail: Arc<str>) => Box::new(tail),
|
||||
impl<'a> DslNs<'a, TuiBox<'a>> for App {}
|
||||
|
||||
"fg" (color: Color, x: TuiBox<'t>) => Box::new(Tui::fg(color, x)),
|
||||
"bg" (color: Color, x: TuiBox<'t>) => Box::new(Tui::bg(color, x)),
|
||||
"fg/bg" (fg: Color, bg: Color, x: TuiBox<'t>) => Box::new(Tui::fg_bg(fg, bg, x)),
|
||||
impl<'a> DslNsExprs<'a, TuiBox<'a>> for App {
|
||||
dsl_exprs!('a |app| -> TuiBox<'a> {
|
||||
"text" (tail: Arc<str>) => tail.boxed(),
|
||||
|
||||
"either" (cond: bool, a: TuiBox<'t>, b: TuiBox<'t>) =>
|
||||
"fg" (color: Color, x: TuiBox<'a>) => Tui::fg(color, x).boxed(),
|
||||
"bg" (color: Color, x: TuiBox<'a>) => Tui::bg(color, x).boxed(),
|
||||
"fg/bg" (fg: Color, bg: Color, x: TuiBox<'a>) => Box::new(Tui::fg_bg(fg, bg, x)),
|
||||
|
||||
"either" (cond: bool, a: TuiBox<'a>, b: TuiBox<'a>) =>
|
||||
Box::new(Either(cond, a, b)),
|
||||
|
||||
"bsp/n" (a: TuiBox<'t>, b: TuiBox<'t>) => Box::new(Bsp::n(a, b)),
|
||||
"bsp/s" (a: TuiBox<'t>, b: TuiBox<'t>) => Box::new(Bsp::s(a, b)),
|
||||
"bsp/e" (a: TuiBox<'t>, b: TuiBox<'t>) => Box::new(Bsp::e(a, b)),
|
||||
"bsp/w" (a: TuiBox<'t>, b: TuiBox<'t>) => Box::new(Bsp::w(a, b)),
|
||||
"bsp/a" (a: TuiBox<'t>, b: TuiBox<'t>) => Box::new(Bsp::a(a, b)),
|
||||
"bsp/b" (a: TuiBox<'t>, b: TuiBox<'t>) => Box::new(Bsp::b(a, b)),
|
||||
"bsp/n" (a: TuiBox<'a>, b: TuiBox<'a>) => Box::new(Bsp::n(a, b)),
|
||||
"bsp/s" (a: TuiBox<'a>, b: TuiBox<'a>) => Box::new(Bsp::s(a, b)),
|
||||
"bsp/e" (a: TuiBox<'a>, b: TuiBox<'a>) => Box::new(Bsp::e(a, b)),
|
||||
"bsp/w" (a: TuiBox<'a>, b: TuiBox<'a>) => Box::new(Bsp::w(a, b)),
|
||||
"bsp/a" (a: TuiBox<'a>, b: TuiBox<'a>) => Box::new(Bsp::a(a, b)),
|
||||
"bsp/b" (a: TuiBox<'a>, b: TuiBox<'a>) => Box::new(Bsp::b(a, b)),
|
||||
|
||||
"align/nw" (x: TuiBox<'t>) => Box::new(Align::nw(x)),
|
||||
"align/ne" (x: TuiBox<'t>) => Box::new(Align::ne(x)),
|
||||
"align/n" (x: TuiBox<'t>) => Box::new(Align::n(x)),
|
||||
"align/s" (x: TuiBox<'t>) => Box::new(Align::s(x)),
|
||||
"align/e" (x: TuiBox<'t>) => Box::new(Align::e(x)),
|
||||
"align/w" (x: TuiBox<'t>) => Box::new(Align::w(x)),
|
||||
"align/x" (x: TuiBox<'t>) => Box::new(Align::x(x)),
|
||||
"align/y" (x: TuiBox<'t>) => Box::new(Align::y(x)),
|
||||
"align/c" (x: TuiBox<'t>) => Box::new(Align::c(x)),
|
||||
"align/nw" (x: TuiBox<'a>) => Box::new(Align::nw(x)),
|
||||
"align/ne" (x: TuiBox<'a>) => Box::new(Align::ne(x)),
|
||||
"align/n" (x: TuiBox<'a>) => Box::new(Align::n(x)),
|
||||
"align/s" (x: TuiBox<'a>) => Box::new(Align::s(x)),
|
||||
"align/e" (x: TuiBox<'a>) => Box::new(Align::e(x)),
|
||||
"align/w" (x: TuiBox<'a>) => Box::new(Align::w(x)),
|
||||
"align/x" (x: TuiBox<'a>) => Box::new(Align::x(x)),
|
||||
"align/y" (x: TuiBox<'a>) => Box::new(Align::y(x)),
|
||||
"align/c" (x: TuiBox<'a>) => Box::new(Align::c(x)),
|
||||
|
||||
"fill/x" (x: TuiBox<'t>) => Box::new(Fill::x(x)),
|
||||
"fill/y" (x: TuiBox<'t>) => Box::new(Fill::y(x)),
|
||||
"fill/xy" (x: TuiBox<'t>) => Box::new(Fill::xy(x)),
|
||||
"fill/x" (x: TuiBox<'a>) => Box::new(Fill::x(x)),
|
||||
"fill/y" (x: TuiBox<'a>) => Box::new(Fill::y(x)),
|
||||
"fill/xy" (x: TuiBox<'a>) => Box::new(Fill::xy(x)),
|
||||
|
||||
"fixed/x" (x: u16, c: TuiBox<'t>) => Box::new(Fixed::x(x, c)),
|
||||
"fixed/y" (y: u16, c: TuiBox<'t>) => Box::new(Fixed::y(y, c)),
|
||||
"fixed/xy" (x: u16, y: u16, c: TuiBox<'t>) => Box::new(Fixed::xy(x, y, c)),
|
||||
"fixed/x" (x: u16, c: TuiBox<'a>) => Box::new(Fixed::x(x, c)),
|
||||
"fixed/y" (y: u16, c: TuiBox<'a>) => Box::new(Fixed::y(y, c)),
|
||||
"fixed/xy" (x: u16, y: u16, c: TuiBox<'a>) => Box::new(Fixed::xy(x, y, c)),
|
||||
|
||||
"min/x" (x: u16, c: TuiBox<'t>) => Box::new(Min::x(x, c)),
|
||||
"min/y" (y: u16, c: TuiBox<'t>) => Box::new(Min::y(y, c)),
|
||||
"min/xy" (x: u16, y: u16, c: TuiBox<'t>) => Box::new(Min::xy(x, y, c)),
|
||||
"min/x" (x: u16, c: TuiBox<'a>) => Box::new(Min::x(x, c)),
|
||||
"min/y" (y: u16, c: TuiBox<'a>) => Box::new(Min::y(y, c)),
|
||||
"min/xy" (x: u16, y: u16, c: TuiBox<'a>) => Box::new(Min::xy(x, y, c)),
|
||||
|
||||
"max/x" (x: u16, c: TuiBox<'t>) => Box::new(Max::x(x, c)),
|
||||
"max/y" (y: u16, c: TuiBox<'t>) => Box::new(Max::y(y, c)),
|
||||
"max/xy" (x: u16, y: u16, c: TuiBox<'t>) => Box::new(Max::xy(x, y, c)),
|
||||
"max/x" (x: u16, c: TuiBox<'a>) => Box::new(Max::x(x, c)),
|
||||
"max/y" (y: u16, c: TuiBox<'a>) => Box::new(Max::y(y, c)),
|
||||
"max/xy" (x: u16, y: u16, c: TuiBox<'a>) => Box::new(Max::xy(x, y, c)),
|
||||
});
|
||||
dsl_words!(|app| -> TuiBox<'t> {
|
||||
/// Resolve an expression if known.
|
||||
fn from_expr (&'a self, dsl: impl Dsl) -> Perhaps<TuiBox<'a>> {
|
||||
if let Some(head) = dsl.expr().head()? {
|
||||
for (key, value) in Self::EXPRS.iter() {
|
||||
if head == *key {
|
||||
return value(self, dsl.expr().tail()?.unwrap_or(""))
|
||||
}
|
||||
}
|
||||
}
|
||||
return Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> DslNsWords<'a, TuiBox<'a>> for App {
|
||||
dsl_words!('a |app| -> TuiBox<'a> {
|
||||
":logo" => Box::new(Fixed::xy(32, 7, Tui::bold(true, Tui::fg(Rgb(240,200,180), Stack::south(|add|{
|
||||
add(&Fixed::y(1, ""));
|
||||
add(&Fixed::y(1, ""));
|
||||
|
|
@ -168,27 +174,14 @@ impl<'t> DslNs<'t, TuiBox<'t>> for App {
|
|||
let rb = if i == selected { " ]" } else { " " };
|
||||
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>> {
|
||||
if let Some(head) = dsl.expr().head()? {
|
||||
for (key, value) in Self::EXPRS.0.iter() {
|
||||
if head == *key {
|
||||
return value(self, dsl.expr().tail()?.unwrap_or(""))
|
||||
}
|
||||
}
|
||||
}
|
||||
return Ok(None)
|
||||
}
|
||||
/// Resolve a symbol if known.
|
||||
fn from_word <D: Dsl> (&self, dsl: &D) -> Perhaps<TuiBox<'t>> {
|
||||
fn from_word (&'a self, dsl: impl Dsl) -> Perhaps<TuiBox<'a>> {
|
||||
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).boxed()))
|
||||
}
|
||||
for (word, get) in Self::WORDS.0 {
|
||||
for (word, get) in Self::WORDS {
|
||||
if dsl == *word {
|
||||
return get(self)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue