refactor(command): improve axis operation feedback

Improve feedback for axis operations:

- `CycleAxisAtCursor` : Now provides a status message if no category is at
  the cursor.
- `TileAxisOp` :
    - Now provides a status message showing the new axis (e.g., "Category →
      Row").
    - No longer automatically switches to `AppMode::Normal` , allowing for
      multiple consecutive adjustments.
    - Provides a status message if no category is at the cursor.

Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/gemma-4-26B-A4B-it-GGUF:UD-Q5_K_XL)
This commit is contained in:
Edward Langley
2026-04-08 22:27:37 -07:00
parent da076eadc8
commit a3d8adfb45

View File

@ -1288,7 +1288,9 @@ impl Cmd for CycleAxisAtCursor {
if let Some(cat_name) = ctx.cat_at_cursor() {
vec![Box::new(effect::CycleAxis(cat_name))]
} else {
vec![]
vec![effect::set_status(
"Move cursor to a category header to change axis".to_string(),
)]
}
}
}
@ -1552,12 +1554,23 @@ impl Cmd for MoveTileCursor {
}
}
/// Cycle or set the axis for the category at the tile cursor, then return to Normal.
/// Cycle or set the axis for the category at the tile cursor.
/// Stays in TileSelect mode so the user can adjust multiple tiles.
/// `axis: None` → cycle, `axis: Some(a)` → set to `a`.
#[derive(Debug)]
pub struct TileAxisOp {
pub axis: Option<Axis>,
}
fn axis_label(axis: Axis) -> &'static str {
match axis {
Axis::Row => "Row",
Axis::Column => "Col",
Axis::Page => "Page",
Axis::None => "None",
}
}
impl Cmd for TileAxisOp {
fn name(&self) -> &'static str {
if self.axis.is_some() {
@ -1569,6 +1582,18 @@ impl Cmd for TileAxisOp {
fn execute(&self, ctx: &CmdContext) -> Vec<Box<dyn Effect>> {
let cat_names = ctx.model.category_names();
if let Some(name) = cat_names.get(ctx.tile_cat_idx) {
let new_axis = match self.axis {
Some(axis) => axis,
None => {
let current = ctx.model.active_view().axis_of(name);
match current {
Axis::Row => Axis::Column,
Axis::Column => Axis::Page,
Axis::Page => Axis::None,
Axis::None => Axis::Row,
}
}
};
let axis_effect: Box<dyn Effect> = match self.axis {
Some(axis) => Box::new(effect::SetAxis {
category: name.to_string(),
@ -1576,13 +1601,10 @@ impl Cmd for TileAxisOp {
}),
None => Box::new(effect::CycleAxis(name.to_string())),
};
vec![
axis_effect,
effect::mark_dirty(),
effect::change_mode(AppMode::Normal),
]
let status = format!("{}{}", name, axis_label(new_axis));
vec![axis_effect, effect::mark_dirty(), effect::set_status(status)]
} else {
vec![effect::change_mode(AppMode::Normal)]
vec![]
}
}
}