view* -> understand*

This commit is contained in:
stop screaming 2026-02-21 18:21:56 +02:00
parent 4aef21f60d
commit 236ee6b810
4 changed files with 16 additions and 16 deletions

View file

@ -1,16 +1,14 @@
#![allow(clippy::unit_arg)]
#![feature(adt_const_params,
associated_type_defaults,
closure_lifetime_binder,
if_let_guard,
impl_trait_in_assoc_type,
trait_alias,
type_alias_impl_trait,
type_changing_struct_update)]
#![feature(
adt_const_params, associated_type_defaults, closure_lifetime_binder,
impl_trait_in_assoc_type, trait_alias, type_alias_impl_trait, type_changing_struct_update
)]
mod tek_struct; pub use self::tek_struct::*;
mod tek_trait; pub use self::tek_trait::*;
mod tek_type; pub use self::tek_type::*;
mod tek_impls;
extern crate xdg;
pub(crate) use ::xdg::BaseDirectories;
pub extern crate atomic_float;
@ -133,12 +131,14 @@ pub(crate) fn load_view (views: &Views, name: &impl AsRef<str>, body: &impl Lang
views.write().unwrap().insert(name.as_ref().into(), body.src()?.unwrap_or_default().into());
Ok(())
}
pub(crate) fn load_mode (modes: &Modes, name: &impl AsRef<str>, body: &impl Language) -> Usually<()> {
let mut mode = Mode::default();
body.each(|item|mode.add(item))?;
modes.write().unwrap().insert(name.as_ref().into(), Arc::new(mode));
Ok(())
}
pub(crate) fn load_bind (binds: &Binds, name: &impl AsRef<str>, body: &impl Language) -> Usually<()> {
binds.write().unwrap().insert(name.as_ref().into(), Bind::load(body)?);
Ok(())

View file

@ -3362,16 +3362,16 @@ impl<T: MaybeHas<Track>> HasTrack for T {
impl Understand<TuiOut, ()> for App {
fn view_expr <'a> (&'a self, to: &mut TuiOut, expr: &'a impl Expression) -> Usually<()> {
fn understand_expr <'a> (&'a self, to: &mut TuiOut, expr: &'a impl Expression) -> Usually<()> {
if evaluate_output_expression(self, to, expr)?
|| evaluate_output_expression_tui(self, to, expr)? {
Ok(())
} else {
Err(format!("App::view_expr: unexpected: {expr:?}").into())
Err(format!("App::understand_expr: unexpected: {expr:?}").into())
}
}
fn view_word <'a> (&'a self, to: &mut TuiOut, dsl: &'a impl Expression) -> Usually<()> {
fn understand_word <'a> (&'a self, to: &mut TuiOut, dsl: &'a impl Expression) -> Usually<()> {
let mut frags = dsl.src()?.unwrap().split("/");
match frags.next() {
Some(":logo") => to.place(&view_logo()),
@ -3412,7 +3412,7 @@ impl Understand<TuiOut, ()> for App {
} else {
None
}),
_ => unimplemented!("App::view_word: {dsl:?} ({frags:?})"),
_ => unimplemented!("App::understand_word: {dsl:?} ({frags:?})"),
},
Some(":templates") => to.place(&{
let modes = self.config.modes.clone();
@ -3466,7 +3466,7 @@ impl Understand<TuiOut, ()> for App {
if let Some(dsl) = views.get(dsl.src()?.unwrap()) {
let dsl = dsl.clone();
std::mem::drop(views);
self.view(to, &dsl)?
self.understand(to, &dsl)?
} else {
unimplemented!("{dsl:?}");
}
@ -3815,7 +3815,7 @@ mod draw {
to.place_at(to.area(), e);
}
for (_index, dsl) in self.mode.view.iter().enumerate() {
if let Err(e) = self.view(to, dsl) {
if let Err(e) = self.understand(to, dsl) {
*self.error.write().unwrap() = Some(format!("{e}").into());
break;
}