Optional sections
This commit is contained in:
parent
054a72e4a6
commit
8c1e72b1ef
3 changed files with 128 additions and 60 deletions
43
src/app.rs
43
src/app.rs
|
|
@ -87,9 +87,24 @@ impl App {
|
|||
}
|
||||
|
||||
pub fn new() -> anyhow::Result<Self> {
|
||||
let config = Config::load()?;
|
||||
let mut state = AppState::load()?;
|
||||
|
||||
// Initialize current_pane to first enabled section
|
||||
let enabled = [
|
||||
config.show_permanent,
|
||||
config.show_recurring,
|
||||
config.show_recent,
|
||||
];
|
||||
|
||||
// Find first enabled pane
|
||||
if let Some(first_enabled) = enabled.iter().position(|&x| x) {
|
||||
state.current_pane = first_enabled;
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
state: AppState::load()?,
|
||||
config: Config::load()?,
|
||||
state,
|
||||
config,
|
||||
current_screen: Screen::Main,
|
||||
needs_clear: false,
|
||||
new_entry_buffer: String::new(),
|
||||
|
|
@ -1213,7 +1228,29 @@ impl App {
|
|||
}
|
||||
|
||||
fn change_pane(&mut self, delta: i32) {
|
||||
self.state.current_pane = ((self.state.current_pane as i32 + delta).rem_euclid(3)) as usize;
|
||||
// Find next enabled pane
|
||||
let mut next_pane = self.state.current_pane;
|
||||
let enabled = [
|
||||
self.config.show_permanent,
|
||||
self.config.show_recurring,
|
||||
self.config.show_recent,
|
||||
];
|
||||
|
||||
// Count enabled panes
|
||||
let enabled_count = enabled.iter().filter(|&&x| x).count();
|
||||
if enabled_count == 0 {
|
||||
return; // No panes to switch to
|
||||
}
|
||||
|
||||
// Find next enabled pane
|
||||
for _ in 0..3 {
|
||||
next_pane = ((next_pane as i32 + delta).rem_euclid(3)) as usize;
|
||||
if enabled[next_pane] {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
self.state.current_pane = next_pane;
|
||||
self.state.current_column = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue