Implemented a full keyboard navigation system with directional commands (C-h/j/k/l) for moving between views, vim-style navigation (j/k for rows, h/l for columns), and TAB cycling. Added table header navigation mode where users can move between columns and change sort order with keyboard shortcuts. The navigation follows visual position: left sidebar, table, and filter bar can all be reached with directional keys. Created a keymap system with context-aware bindings that resolve commands based on current focus (Table, TableHeaders, FilterBar, Sidebar). Commands are dispatched through a centralized handler that manages focus transitions and view state. Added helper methods to cycle through column headers with proper wrapping. Auto-select first task on load when tasks exist, and set initial window focus so keyboard shortcuts work immediately without requiring a mouse click.
33 lines
739 B
Rust
33 lines
739 B
Rust
use super::ContextId;
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
pub enum FocusTarget {
|
|
App,
|
|
Table,
|
|
TableHeaders,
|
|
SidebarProjects,
|
|
SidebarTags,
|
|
}
|
|
|
|
impl FocusTarget {
|
|
pub fn to_context(&self) -> ContextId {
|
|
match self {
|
|
Self::App => ContextId::Global,
|
|
Self::Table => ContextId::Table,
|
|
Self::TableHeaders => ContextId::TableHeaders,
|
|
Self::SidebarProjects => ContextId::SidebarProjects,
|
|
Self::SidebarTags => ContextId::SidebarTags,
|
|
}
|
|
}
|
|
|
|
pub fn is_sidebar(&self) -> bool {
|
|
matches!(self, Self::SidebarProjects | Self::SidebarTags)
|
|
}
|
|
}
|
|
|
|
impl Default for FocusTarget {
|
|
fn default() -> Self {
|
|
Self::App
|
|
}
|
|
}
|