mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 03:36:41 +01:00
This commit is contained in:
parent
287983c140
commit
ed848c2669
3 changed files with 43 additions and 41 deletions
|
|
@ -327,16 +327,16 @@ pub struct Configuration {
|
|||
/// Description of configuration
|
||||
pub info: Option<Arc<str>>,
|
||||
/// View definition
|
||||
pub view: TokenIter<'static>,
|
||||
pub view: Cst,
|
||||
// Input keymap
|
||||
pub keys: InputMap<'static, App, AppCommand, TuiIn, TokenIter<'static>>,
|
||||
pub keys: InputMap<App, AppCommand, TuiIn, Cst>,
|
||||
}
|
||||
|
||||
impl Configuration {
|
||||
|
||||
pub fn new (path: &impl AsRef<Path>, _watch: bool) -> Usually<Self> {
|
||||
let text = read_and_leak(path.as_ref())?;
|
||||
let [name, info, view, keys] = Self::parse(TokenIter::from(text))?;
|
||||
let [name, info, view, keys] = Self::parse(Cst::from(text))?;
|
||||
Ok(Self {
|
||||
path: path.as_ref().into(),
|
||||
info: info.map(Self::parse_info).flatten(),
|
||||
|
|
@ -346,11 +346,11 @@ impl Configuration {
|
|||
})
|
||||
}
|
||||
|
||||
fn parse (iter: TokenIter) -> Usually<[Option<TokenIter>;4]> {
|
||||
let mut name: Option<TokenIter> = None;
|
||||
let mut info: Option<TokenIter> = None;
|
||||
let mut view: Option<TokenIter> = None;
|
||||
let mut keys: Option<TokenIter> = None;
|
||||
fn parse (iter: Cst) -> Usually<[Option<Cst>;4]> {
|
||||
let mut name: Option<Cst> = None;
|
||||
let mut info: Option<Cst> = None;
|
||||
let mut view: Option<Cst> = None;
|
||||
let mut keys: Option<Cst> = None;
|
||||
for token in iter {
|
||||
match token.value {
|
||||
Value::Exp(_, mut exp) => {
|
||||
|
|
@ -378,7 +378,7 @@ impl Configuration {
|
|||
Ok([name, info, view, keys])
|
||||
}
|
||||
|
||||
fn parse_info (mut iter: TokenIter) -> Option<Arc<str>> {
|
||||
fn parse_info (mut iter: Cst) -> Option<Arc<str>> {
|
||||
iter.next().and_then(|x|if let Value::Str(x) = x.value {
|
||||
Some(x.into())
|
||||
} else {
|
||||
|
|
@ -386,7 +386,7 @@ impl Configuration {
|
|||
})
|
||||
}
|
||||
|
||||
fn parse_name (mut iter: TokenIter) -> Option<Arc<str>> {
|
||||
fn parse_name (mut iter: Cst) -> Option<Arc<str>> {
|
||||
iter.next().and_then(|x|if let Value::Str(x) = x.value {
|
||||
Some(x.into())
|
||||
} else {
|
||||
|
|
@ -394,7 +394,7 @@ impl Configuration {
|
|||
})
|
||||
}
|
||||
|
||||
fn parse_view (iter: Option<TokenIter>) -> Usually<TokenIter> {
|
||||
fn parse_view (iter: Option<Cst>) -> Usually<Cst> {
|
||||
if let Some(view) = iter {
|
||||
Ok(view)
|
||||
} else {
|
||||
|
|
@ -402,8 +402,8 @@ impl Configuration {
|
|||
}
|
||||
}
|
||||
|
||||
fn parse_keys (base: &impl AsRef<Path>, iter: Option<TokenIter<'static>>)
|
||||
-> Usually<InputMap<'static, App, AppCommand, TuiIn, TokenIter<'static>>>
|
||||
fn parse_keys (base: &impl AsRef<Path>, iter: Option<Cst>)
|
||||
-> Usually<InputMap<App, AppCommand, TuiIn, Cst>>
|
||||
{
|
||||
if iter.is_none() {
|
||||
return Err(format!("missing keys definition").into())
|
||||
|
|
|
|||
|
|
@ -24,45 +24,47 @@ impl<T: Content<TuiOut>> Content<TuiOut> for ErrorBoundary<TuiOut, T> {
|
|||
|
||||
impl App {
|
||||
pub fn view (model: &Self) -> impl Content<TuiOut> + '_ {
|
||||
ErrorBoundary::new(Ok(Some(Tui::bg(Black, "give or take"))))
|
||||
ErrorBoundary::new(Ok(Some(Tui::bg(Black, model.view_nil()))))
|
||||
//ErrorBoundary::new(Take::take(model, &mut model.config.view.clone()))
|
||||
//ErrorBoundary::new(Give::give(model, &mut model.config.view.clone()))
|
||||
}
|
||||
}
|
||||
|
||||
content!(TuiOut: |self: App| ErrorBoundary::new(Ok(Some(Tui::bg(Black, self.view_nil())))));
|
||||
|
||||
#[tengri_proc::view(TuiOut)]
|
||||
impl App {
|
||||
//pub fn view_nil (model: &Self) -> impl Content<TuiOut> {
|
||||
//"nil"
|
||||
//}
|
||||
//pub fn view_dialog (model: &Self) -> impl Content<TuiOut> + use<'_> {
|
||||
//model.dialog.as_ref().map(|dialog|Bsp::b("",
|
||||
//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))))))
|
||||
//}
|
||||
//pub fn view_meters_input (model: &Self) -> impl Content<TuiOut> + use<'_> {
|
||||
//model.project.sampler().map(|s|
|
||||
pub fn view_nil (&self) -> impl Content<TuiOut> + '_ {
|
||||
"nil"
|
||||
}
|
||||
pub fn view_dialog (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
self.dialog.as_ref().map(|dialog|Bsp::b("",
|
||||
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))))))
|
||||
}
|
||||
//pub fn view_meters_input (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.sampler().map(|s|
|
||||
//s.view_meters_input())
|
||||
//}
|
||||
//pub fn view_meters_output (model: &Self) -> impl Content<TuiOut> + use<'_> {
|
||||
//model.project.sampler().map(|s|
|
||||
//pub fn view_meters_output (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
//self.project.sampler().map(|s|
|
||||
//s.view_meters_output())
|
||||
//}
|
||||
//pub fn view_history (model: &Self) -> impl Content<TuiOut> {
|
||||
//Fixed::y(1, Fill::x(Align::w(FieldH(model.color,
|
||||
//format!("History ({})", model.history.len()),
|
||||
//model.history.last().map(|last|Fill::x(Align::w(format!("{:?}", last.0))))))))
|
||||
//pub fn view_history (&self) -> impl Content<TuiOut> {
|
||||
//Fixed::y(1, Fill::x(Align::w(FieldH(self.color,
|
||||
//format!("History ({})", self.history.len()),
|
||||
//self.history.last().map(|last|Fill::x(Align::w(format!("{:?}", last.0))))))))
|
||||
//}
|
||||
//pub fn view_status_h2 (model: &Self) -> impl Content<TuiOut> {
|
||||
//model.update_clock();
|
||||
//let theme = model.color;
|
||||
//let clock = model.clock();
|
||||
//pub fn view_status_h2 (&self) -> impl Content<TuiOut> {
|
||||
//self.update_clock();
|
||||
//let theme = self.color;
|
||||
//let clock = self.clock();
|
||||
//let playing = clock.is_rolling();
|
||||
//let cache = clock.view_cache.clone();
|
||||
////let selection = model.selection().describe(model.tracks(), model.scenes());
|
||||
//let hist_len = model.history.len();
|
||||
//let hist_last = model.history.last();
|
||||
////let selection = self.selection().describe(self.tracks(), self.scenes());
|
||||
//let hist_len = self.history.len();
|
||||
//let hist_last = self.history.last();
|
||||
//Fixed::y(2, Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||
//add(&Fixed::x(5, Tui::bg(if playing { Rgb(0, 128, 0) } else { Rgb(128, 64, 0) },
|
||||
//Either::new(false, // TODO
|
||||
|
|
@ -97,8 +99,8 @@ impl App {
|
|||
////hist_last.map(|last|Fill::x(Align::w(format!("{:?}", last.0))))))),
|
||||
////""
|
||||
////));
|
||||
//////if let Some(last) = model.history.last() {
|
||||
//////add(&FieldV(theme, format!("History ({})", model.history.len()),
|
||||
//////if let Some(last) = self.history.last() {
|
||||
//////add(&FieldV(theme, format!("History ({})", self.history.len()),
|
||||
//////Fill::x(Align::w(format!("{:?}", last.0)))));
|
||||
//////}
|
||||
//}
|
||||
|
|
|
|||
2
deps/tengri
vendored
2
deps/tengri
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit 31e84bf5b3a44fb0b51f853f135109ea184ace84
|
||||
Subproject commit f1b24d436a890b75cf98aaa0f2d29d10ed660106
|
||||
Loading…
Add table
Add a link
Reference in a new issue