diff --git a/src/command/cmd.rs b/src/command/cmd.rs index 12bc677..7b9d18a 100644 --- a/src/command/cmd.rs +++ b/src/command/cmd.rs @@ -3,8 +3,8 @@ use std::fmt::Debug; use crate::model::cell::CellValue; use crate::model::Model; use crate::ui::app::AppMode; -use crate::ui::effect::{self, Effect}; -use crate::view::GridLayout; +use crate::ui::effect::{self, Effect, Panel}; +use crate::view::{Axis, AxisEntry, GridLayout}; /// Read-only context available to commands for decision-making. pub struct CmdContext<'a> { @@ -15,9 +15,11 @@ pub struct CmdContext<'a> { pub col_offset: usize, pub search_query: &'a str, pub yanked: &'a Option, - pub pending_key: Option, pub dirty: bool, pub file_path_set: bool, + pub formula_panel_open: bool, + pub category_panel_open: bool, + pub view_panel_open: bool, } /// A command that reads state and produces effects. @@ -97,9 +99,8 @@ impl Cmd for JumpToLastRow { fn execute(&self, ctx: &CmdContext) -> Vec> { let layout = GridLayout::new(ctx.model, ctx.model.active_view()); let last = layout.row_count().saturating_sub(1); - let mut effects: Vec> = vec![ - Box::new(effect::SetSelected(last, ctx.selected.1)), - ]; + let mut effects: Vec> = + vec![Box::new(effect::SetSelected(last, ctx.selected.1))]; if last >= ctx.row_offset + 20 { effects.push(Box::new(effect::SetRowOffset(last.saturating_sub(19)))); } @@ -130,9 +131,8 @@ impl Cmd for JumpToLastCol { fn execute(&self, ctx: &CmdContext) -> Vec> { let layout = GridLayout::new(ctx.model, ctx.model.active_view()); let last = layout.col_count().saturating_sub(1); - let mut effects: Vec> = vec![ - Box::new(effect::SetSelected(ctx.selected.0, last)), - ]; + let mut effects: Vec> = + vec![Box::new(effect::SetSelected(ctx.selected.0, last))]; if last >= ctx.col_offset + 8 { effects.push(Box::new(effect::SetColOffset(last.saturating_sub(7)))); } @@ -150,9 +150,8 @@ impl Cmd for ScrollRows { let layout = GridLayout::new(ctx.model, ctx.model.active_view()); let row_max = layout.row_count().saturating_sub(1) as i32; let nr = (ctx.selected.0 as i32 + self.0).clamp(0, row_max) as usize; - let mut effects: Vec> = vec![ - Box::new(effect::SetSelected(nr, ctx.selected.1)), - ]; + let mut effects: Vec> = + vec![Box::new(effect::SetSelected(nr, ctx.selected.1))]; let mut row_offset = ctx.row_offset; if nr < row_offset { row_offset = nr; @@ -215,10 +214,7 @@ impl Cmd for SaveAndQuit { "save-and-quit" } fn execute(&self, _ctx: &CmdContext) -> Vec> { - vec![ - Box::new(effect::Save), - effect::change_mode(AppMode::Quit), - ] + vec![Box::new(effect::Save), effect::change_mode(AppMode::Quit)] } }