diff --git a/crates/app/src/api.rs b/crates/app/src/api.rs index fc0d3a96..32c69b16 100644 --- a/crates/app/src/api.rs +++ b/crates/app/src/api.rs @@ -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 } diff --git a/crates/app/src/view.rs b/crates/app/src/view.rs index 0863db69..87ca3d42 100644 --- a/crates/app/src/view.rs +++ b/crates/app/src/view.rs @@ -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 for Modal { fn content (&self) -> impl Render { - match self { - Self::Menu => self.view_menu().boxed(), - Self::Help => self.view_help().boxed(), - } + 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 { - 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))) } }