update CmdContext and imports
- Updated imports to include Panel and Axis. - Added new fields to CmdContext: formula_panel_open, category_panel_open, view_panel_open. - Reformatted effect vectors for consistency. - Minor formatting changes to improve readability. Co-Authored-By: fiddlerwoaroof/git-smart-commit (gpt-oss:20b)
This commit is contained in:
@ -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<CellValue>,
|
||||
pub pending_key: Option<char>,
|
||||
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<Box<dyn Effect>> {
|
||||
let layout = GridLayout::new(ctx.model, ctx.model.active_view());
|
||||
let last = layout.row_count().saturating_sub(1);
|
||||
let mut effects: Vec<Box<dyn Effect>> = vec![
|
||||
Box::new(effect::SetSelected(last, ctx.selected.1)),
|
||||
];
|
||||
let mut effects: Vec<Box<dyn Effect>> =
|
||||
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<Box<dyn Effect>> {
|
||||
let layout = GridLayout::new(ctx.model, ctx.model.active_view());
|
||||
let last = layout.col_count().saturating_sub(1);
|
||||
let mut effects: Vec<Box<dyn Effect>> = vec![
|
||||
Box::new(effect::SetSelected(ctx.selected.0, last)),
|
||||
];
|
||||
let mut effects: Vec<Box<dyn Effect>> =
|
||||
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<Box<dyn Effect>> = vec![
|
||||
Box::new(effect::SetSelected(nr, ctx.selected.1)),
|
||||
];
|
||||
let mut effects: Vec<Box<dyn Effect>> =
|
||||
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<Box<dyn Effect>> {
|
||||
vec![
|
||||
Box::new(effect::Save),
|
||||
effect::change_mode(AppMode::Quit),
|
||||
]
|
||||
vec![Box::new(effect::Save), effect::change_mode(AppMode::Quit)]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user