display some keybinds in help window

This commit is contained in:
🪞👃🪞 2025-04-26 17:31:18 +03:00
parent 38fb348d19
commit a0cc88ff26
2 changed files with 36 additions and 9 deletions

View file

@ -161,7 +161,15 @@ defcom! { |self, app: Tek|
TekCommand {
ToggleHelp => {
app.modal = Some(Modal::Help);
app.modal = match app.modal {
Some(Modal::Help) => None,
_ => Some(Modal::Help)
};
None
}
ToggleMenu => {
app.modal = Some(Modal::Menu);
None
}

View file

@ -10,7 +10,7 @@ view!(TuiOut: |self: Tek| {
":modal" =>
When::new(self.modal.is_some(), Bsp::b(
Fill::xy(Tui::fg_bg(Color::Rgb(64,64,64), Color::Rgb(32,32,32), "")),
Fixed::xy(20, 10, Tui::fg_bg(Color::Rgb(255,255,255), Color::Rgb(16,16,16),
Fixed::xy(30, 15, Tui::fg_bg(Color::Rgb(255,255,255), Color::Rgb(16,16,16),
Outer(true, Style::default().fg(Tui::g(96))).enclose(self.modal)))
)).boxed(),
":transport" =>
@ -870,10 +870,13 @@ impl ViewCache {
impl Content<TuiOut> for Modal {
fn content (&self) -> impl Render<TuiOut> {
Bsp::b(
Repeat(" "),
match self {
Self::Menu => self.view_menu().boxed(),
Self::Help => self.view_help().boxed(),
}
)
}
}
@ -882,8 +885,24 @@ impl Modal {
"menu"
}
fn view_help (&self) -> impl Content<TuiOut> {
Bsp::s(Tui::bold(true, "Help"), Bsp::s("", Map::south(1,
||0..5,
|binding, _|Bsp::e(" key ", " command "))))
let bindings = ||TokenIter::new(include_str!("../edn/groovebox_keys.edn"))
.filter_map(|x|if let Value::Exp(_, iter)=x.value{
Some(iter)
} else {
None
});
let binding = |mut binding: TokenIter, _|Bsp::e(
Tui::bold(true, Tui::fg(Color::Rgb(255,192,0), if let Some(Token { value: Value::Sym(key), .. }) = binding.next() {
Some(key.to_string())
} else {
None
})),
Bsp::e(" ", Tui::fg(Color::Rgb(255,255,255), if let Some(Token { value: Value::Key(command), .. }) = binding.next() {
Some(command.to_string())
} else {
None
})),
);
Bsp::s(Tui::bold(true, "Help"), Bsp::s("", Map::south(1, bindings, binding)))
}
}