refactor: update TogglePanelAndFocus to use open/focused flags
Update TogglePanelAndFocus and related components to use open/focused flags. Changed TogglePanelAndFocus from currently_open to open+focused flags. Parser accepts optional [open] [focused] arguments. Interactive mode toggles between open+focus and closed/unfocused. Keymap updates: F/C/V in panel modes close panels when focused. Model initialization: Virtual categories _Index/_Dim default to None axis, regular categories auto-assign Row/Column/Page. App test context updated with visible_rows/visible_cols. Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/Qwen3.5-35B-A3B-GGUF:Q5_K_M)
This commit is contained in:
@ -576,25 +576,28 @@ impl Cmd for EnterSearchMode {
|
||||
#[derive(Debug)]
|
||||
pub struct TogglePanelAndFocus {
|
||||
pub panel: Panel,
|
||||
pub currently_open: bool,
|
||||
pub open: bool,
|
||||
pub focused: bool,
|
||||
}
|
||||
impl Cmd for TogglePanelAndFocus {
|
||||
fn name(&self) -> &'static str {
|
||||
"toggle-panel-and-focus"
|
||||
}
|
||||
fn execute(&self, _ctx: &CmdContext) -> Vec<Box<dyn Effect>> {
|
||||
let new_open = !self.currently_open;
|
||||
let mut effects: Vec<Box<dyn Effect>> = vec![Box::new(effect::SetPanelOpen {
|
||||
let mut effects: Vec<Box<dyn Effect>> = Vec::new();
|
||||
effects.push(Box::new(effect::SetPanelOpen {
|
||||
panel: self.panel,
|
||||
open: new_open,
|
||||
})];
|
||||
if new_open {
|
||||
open: self.open,
|
||||
}));
|
||||
if self.focused {
|
||||
let mode = match self.panel {
|
||||
Panel::Formula => AppMode::FormulaPanel,
|
||||
Panel::Category => AppMode::CategoryPanel,
|
||||
Panel::View => AppMode::ViewPanel,
|
||||
};
|
||||
effects.push(effect::change_mode(mode));
|
||||
} else {
|
||||
effects.push(effect::change_mode(AppMode::Normal));
|
||||
}
|
||||
effects
|
||||
}
|
||||
|
||||
@ -422,6 +422,9 @@ impl KeymapSet {
|
||||
fp.bind(KeyCode::Char('o'), none, "enter-formula-edit");
|
||||
fp.bind(KeyCode::Char('d'), none, "delete-formula-at-cursor");
|
||||
fp.bind(KeyCode::Delete, none, "delete-formula-at-cursor");
|
||||
fp.bind_args(KeyCode::Char('F'), none, "toggle-panel-and-focus", vec!["formula".into()]);
|
||||
fp.bind_args(KeyCode::Char('C'), none, "toggle-panel-and-focus", vec!["category".into()]);
|
||||
fp.bind_args(KeyCode::Char('V'), none, "toggle-panel-and-focus", vec!["view".into()]);
|
||||
set.insert(ModeKey::FormulaPanel, Arc::new(fp));
|
||||
|
||||
// ── Category panel ───────────────────────────────────────────────
|
||||
@ -444,7 +447,7 @@ impl KeymapSet {
|
||||
vec!["category".into(), "1".into()],
|
||||
);
|
||||
}
|
||||
cp.bind(KeyCode::Enter, none, "cycle-axis-at-cursor");
|
||||
cp.bind(KeyCode::Enter, none, "filter-to-item");
|
||||
cp.bind(KeyCode::Char(' '), none, "cycle-axis-at-cursor");
|
||||
cp.bind_args(
|
||||
KeyCode::Char('n'),
|
||||
@ -502,6 +505,9 @@ impl KeymapSet {
|
||||
vp.bind(KeyCode::Char('o'), none, "create-and-switch-view");
|
||||
vp.bind(KeyCode::Char('d'), none, "delete-view-at-cursor");
|
||||
vp.bind(KeyCode::Delete, none, "delete-view-at-cursor");
|
||||
vp.bind_args(KeyCode::Char('V'), none, "toggle-panel-and-focus", vec!["view".into()]);
|
||||
vp.bind_args(KeyCode::Char('C'), none, "toggle-panel-and-focus", vec!["category".into()]);
|
||||
vp.bind_args(KeyCode::Char('F'), none, "toggle-panel-and-focus", vec!["formula".into()]);
|
||||
set.insert(ModeKey::ViewPanel, Arc::new(vp));
|
||||
|
||||
// ── Tile select ──────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user