control transport values

This commit is contained in:
🪞👃🪞 2024-07-12 16:56:19 +03:00
parent 33e5f47526
commit 45021bc77a
10 changed files with 168 additions and 86 deletions

32
src/control/focus.rs Normal file
View file

@ -0,0 +1,32 @@
use crate::{core::*, model::{App, AppSection}};
pub const KEYMAP_FOCUS: &'static [KeyBinding<App>] = keymap!(App {
[Char(';'), NONE, "command", "open command palette", |app: &mut App| {
app.modal = Some(Box::new(crate::view::HelpModal::new()));
Ok(true)
}],
[Tab, NONE, "focus_next", "focus next area", focus_next],
[Tab, SHIFT, "focus_prev", "focus previous area", focus_prev],
[Esc, NONE, "focus_exit", "unfocus", |app: &mut App|{
app.entered = false;
Ok(true)
}],
[Enter, NONE, "focus_enter", "activate item at cursor", |app: &mut App|{
app.entered = true;
Ok(true)
}],
});
pub fn focus_next (app: &mut App) -> Usually<bool> {
app.section.next();
app.transport.focused = app.section == AppSection::Transport;
app.transport.entered = app.entered;
Ok(true)
}
pub fn focus_prev (app: &mut App) -> Usually<bool> {
app.section.prev();
app.transport.focused = app.section == AppSection::Transport;
app.transport.entered = app.entered;
Ok(true)
}