mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
display some keybinds in help window
This commit is contained in:
parent
38fb348d19
commit
a0cc88ff26
2 changed files with 36 additions and 9 deletions
|
|
@ -161,7 +161,15 @@ defcom! { |self, app: Tek|
|
||||||
TekCommand {
|
TekCommand {
|
||||||
|
|
||||||
ToggleHelp => {
|
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
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ view!(TuiOut: |self: Tek| {
|
||||||
":modal" =>
|
":modal" =>
|
||||||
When::new(self.modal.is_some(), Bsp::b(
|
When::new(self.modal.is_some(), Bsp::b(
|
||||||
Fill::xy(Tui::fg_bg(Color::Rgb(64,64,64), Color::Rgb(32,32,32), "")),
|
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)))
|
Outer(true, Style::default().fg(Tui::g(96))).enclose(self.modal)))
|
||||||
)).boxed(),
|
)).boxed(),
|
||||||
":transport" =>
|
":transport" =>
|
||||||
|
|
@ -870,10 +870,13 @@ impl ViewCache {
|
||||||
|
|
||||||
impl Content<TuiOut> for Modal {
|
impl Content<TuiOut> for Modal {
|
||||||
fn content (&self) -> impl Render<TuiOut> {
|
fn content (&self) -> impl Render<TuiOut> {
|
||||||
match self {
|
Bsp::b(
|
||||||
Self::Menu => self.view_menu().boxed(),
|
Repeat(" "),
|
||||||
Self::Help => self.view_help().boxed(),
|
match self {
|
||||||
}
|
Self::Menu => self.view_menu().boxed(),
|
||||||
|
Self::Help => self.view_help().boxed(),
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -882,8 +885,24 @@ impl Modal {
|
||||||
"menu"
|
"menu"
|
||||||
}
|
}
|
||||||
fn view_help (&self) -> impl Content<TuiOut> {
|
fn view_help (&self) -> impl Content<TuiOut> {
|
||||||
Bsp::s(Tui::bold(true, "Help"), Bsp::s("", Map::south(1,
|
let bindings = ||TokenIter::new(include_str!("../edn/groovebox_keys.edn"))
|
||||||
||0..5,
|
.filter_map(|x|if let Value::Exp(_, iter)=x.value{
|
||||||
|binding, _|Bsp::e(" key ", " command "))))
|
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)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue