Compare commits

...

4 commits

Author SHA1 Message Date
c954965ae1 measure: w -> h
Some checks are pending
/ build (push) Waiting to run
2025-05-14 22:37:43 +03:00
f7306de55f field: align west 2025-05-14 22:17:27 +03:00
4c039c999b output: add memory of Stack primitive 2025-05-14 22:17:07 +03:00
496a9202d5 input: better dsl error handling 2025-05-14 22:16:52 +03:00
5 changed files with 32 additions and 11 deletions

View file

@ -51,19 +51,19 @@ impl<'state, S, C: DslCommand<'state, S>, I: DslInput> KeyMap<'state, S, C, I> f
while let Some(next) = iter.next() {
match next {
Token { value: Value::Exp(0, exp_iter), .. } => {
let mut exp_iter = exp_iter.clone();
match exp_iter.next() {
let mut e = exp_iter.clone();
match e.next() {
Some(Token { value: Value::Sym(binding), .. }) => {
if input.matches_dsl(binding) {
if let Some(command) = C::try_from_expr(state, &mut exp_iter) {
if let Some(command) = C::try_from_expr(state, &mut e) {
return Some(command)
}
}
},
_ => panic!("invalid config (expected symbol)")
_ => panic!("invalid config (expected symbol, got: {exp_iter:?})")
}
},
_ => panic!("invalid config (expected expression)")
_ => panic!("invalid config (expected expression, got: {next:?})")
}
}
None

18
output/src/ops/stack.rs Normal file
View file

@ -0,0 +1,18 @@
/*Stack::down(|add|{
let mut i = 0;
for (_, name) in self.dirs.iter() {
if i >= self.scroll {
add(&Tui::bold(i == self.index, name.as_str()))?;
}
i += 1;
}
for (_, name) in self.files.iter() {
if i >= self.scroll {
add(&Tui::bold(i == self.index, name.as_str()))?;
}
i += 1;
}
add(&format!("{}/{i}", self.index))?;
Ok(())
}));*/

View file

@ -7,7 +7,7 @@ pub trait HasSize<E: Output> {
self.size().w()
}
fn height (&self) -> usize {
self.size().w()
self.size().h()
}
}

View file

@ -54,7 +54,7 @@ pub trait ViewContext<'state, E: Output + 'state>: Send + Sync
match value {
Value::Sym(_) => self.get_content_sym(value),
Value::Exp(_, _) => self.get_content_exp(value),
_ => panic!("only :symbols and (expressions) accepted here")
_ => panic!("only :symbols and (expressions) accepted here, got: {value:?}")
}
}
fn get_content_sym <'source: 'state> (&'state self, value: &Value<'source>)

View file

@ -17,10 +17,13 @@ pub struct FieldV<T, U>(pub ItemTheme, pub T, pub U);
impl<T: Content<TuiOut>, U: Content<TuiOut>> Content<TuiOut> for FieldV<T, U> {
fn content (&self) -> impl Render<TuiOut> {
let Self(ItemTheme { darkest, dark, lighter, lightest, .. }, title, value) = self;
let sep1 = Tui::bg(darkest.rgb, Tui::fg(dark.rgb, ""));
let sep2 = Tui::bg(darkest.rgb, Tui::fg(dark.rgb, ""));
let title = Tui::bg(dark.rgb, Tui::fg(lighter.rgb, Tui::bold(true, title)));
let sep1 = Tui::bg(darkest.rgb, Tui::fg(dark.rgb, ""));
let sep2 = Tui::bg(darkest.rgb, Tui::fg(dark.rgb, ""));
let title = Tui::bg(dark.rgb, Tui::fg(lighter.rgb, Tui::bold(true, title)));
let value = Tui::bg(darkest.rgb, Tui::fg(lightest.rgb, value));
Bsp::e(Bsp::s(row!(sep1, title, sep2), value), " ")
Bsp::n(
Align::w(value),
Fill::x(Align::w(row!(sep1, title, sep2)))
)
}
}