chore: clippy + fmt
This commit is contained in:
@ -424,7 +424,9 @@ impl Cmd for EnterEditMode {
|
||||
name: "edit".to_string(),
|
||||
value: current,
|
||||
}),
|
||||
effect::change_mode(AppMode::Editing { buffer: String::new() }),
|
||||
effect::change_mode(AppMode::Editing {
|
||||
buffer: String::new(),
|
||||
}),
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -1155,15 +1157,9 @@ impl Cmd for CommitCellEdit {
|
||||
if buf.is_empty() {
|
||||
effects.push(Box::new(effect::ClearCell(key)));
|
||||
} else if let Ok(n) = buf.parse::<f64>() {
|
||||
effects.push(Box::new(effect::SetCell(
|
||||
key,
|
||||
CellValue::Number(n),
|
||||
)));
|
||||
effects.push(Box::new(effect::SetCell(key, CellValue::Number(n))));
|
||||
} else {
|
||||
effects.push(Box::new(effect::SetCell(
|
||||
key,
|
||||
CellValue::Text(buf),
|
||||
)));
|
||||
effects.push(Box::new(effect::SetCell(key, CellValue::Text(buf))));
|
||||
}
|
||||
effects.push(effect::mark_dirty());
|
||||
}
|
||||
@ -1184,7 +1180,12 @@ impl Cmd for CommitFormula {
|
||||
}
|
||||
fn execute(&self, ctx: &CmdContext) -> Vec<Box<dyn Effect>> {
|
||||
let buf = ctx.buffers.get("formula").cloned().unwrap_or_default();
|
||||
let first_cat = ctx.model.category_names().into_iter().next().map(String::from);
|
||||
let first_cat = ctx
|
||||
.model
|
||||
.category_names()
|
||||
.into_iter()
|
||||
.next()
|
||||
.map(String::from);
|
||||
let mut effects: Vec<Box<dyn Effect>> = Vec::new();
|
||||
if let Some(cat) = first_cat {
|
||||
effects.push(Box::new(effect::AddFormula {
|
||||
|
||||
@ -348,22 +348,34 @@ impl KeymapSet {
|
||||
fp.bind_cmd(
|
||||
KeyCode::Up,
|
||||
none,
|
||||
cmd::MovePanelCursor { panel: crate::ui::effect::Panel::Formula, delta: -1 },
|
||||
cmd::MovePanelCursor {
|
||||
panel: crate::ui::effect::Panel::Formula,
|
||||
delta: -1,
|
||||
},
|
||||
);
|
||||
fp.bind_cmd(
|
||||
KeyCode::Char('k'),
|
||||
none,
|
||||
cmd::MovePanelCursor { panel: crate::ui::effect::Panel::Formula, delta: -1 },
|
||||
cmd::MovePanelCursor {
|
||||
panel: crate::ui::effect::Panel::Formula,
|
||||
delta: -1,
|
||||
},
|
||||
);
|
||||
fp.bind_cmd(
|
||||
KeyCode::Down,
|
||||
none,
|
||||
cmd::MovePanelCursor { panel: crate::ui::effect::Panel::Formula, delta: 1 },
|
||||
cmd::MovePanelCursor {
|
||||
panel: crate::ui::effect::Panel::Formula,
|
||||
delta: 1,
|
||||
},
|
||||
);
|
||||
fp.bind_cmd(
|
||||
KeyCode::Char('j'),
|
||||
none,
|
||||
cmd::MovePanelCursor { panel: crate::ui::effect::Panel::Formula, delta: 1 },
|
||||
cmd::MovePanelCursor {
|
||||
panel: crate::ui::effect::Panel::Formula,
|
||||
delta: 1,
|
||||
},
|
||||
);
|
||||
fp.bind_cmd(KeyCode::Char('a'), none, cmd::EnterFormulaEdit);
|
||||
fp.bind_cmd(KeyCode::Char('n'), none, cmd::EnterFormulaEdit);
|
||||
@ -379,29 +391,43 @@ impl KeymapSet {
|
||||
cp.bind_cmd(
|
||||
KeyCode::Up,
|
||||
none,
|
||||
cmd::MovePanelCursor { panel: crate::ui::effect::Panel::Category, delta: -1 },
|
||||
cmd::MovePanelCursor {
|
||||
panel: crate::ui::effect::Panel::Category,
|
||||
delta: -1,
|
||||
},
|
||||
);
|
||||
cp.bind_cmd(
|
||||
KeyCode::Char('k'),
|
||||
none,
|
||||
cmd::MovePanelCursor { panel: crate::ui::effect::Panel::Category, delta: -1 },
|
||||
cmd::MovePanelCursor {
|
||||
panel: crate::ui::effect::Panel::Category,
|
||||
delta: -1,
|
||||
},
|
||||
);
|
||||
cp.bind_cmd(
|
||||
KeyCode::Down,
|
||||
none,
|
||||
cmd::MovePanelCursor { panel: crate::ui::effect::Panel::Category, delta: 1 },
|
||||
cmd::MovePanelCursor {
|
||||
panel: crate::ui::effect::Panel::Category,
|
||||
delta: 1,
|
||||
},
|
||||
);
|
||||
cp.bind_cmd(
|
||||
KeyCode::Char('j'),
|
||||
none,
|
||||
cmd::MovePanelCursor { panel: crate::ui::effect::Panel::Category, delta: 1 },
|
||||
cmd::MovePanelCursor {
|
||||
panel: crate::ui::effect::Panel::Category,
|
||||
delta: 1,
|
||||
},
|
||||
);
|
||||
cp.bind_cmd(KeyCode::Enter, none, cmd::CycleAxisAtCursor);
|
||||
cp.bind_cmd(KeyCode::Char(' '), none, cmd::CycleAxisAtCursor);
|
||||
cp.bind_cmd(
|
||||
KeyCode::Char('n'),
|
||||
none,
|
||||
cmd::EnterMode(AppMode::CategoryAdd { buffer: String::new() }),
|
||||
cmd::EnterMode(AppMode::CategoryAdd {
|
||||
buffer: String::new(),
|
||||
}),
|
||||
);
|
||||
cp.bind_cmd(KeyCode::Char('a'), none, cmd::OpenItemAddAtCursor);
|
||||
cp.bind_cmd(KeyCode::Char('o'), none, cmd::OpenItemAddAtCursor);
|
||||
@ -414,22 +440,34 @@ impl KeymapSet {
|
||||
vp.bind_cmd(
|
||||
KeyCode::Up,
|
||||
none,
|
||||
cmd::MovePanelCursor { panel: crate::ui::effect::Panel::View, delta: -1 },
|
||||
cmd::MovePanelCursor {
|
||||
panel: crate::ui::effect::Panel::View,
|
||||
delta: -1,
|
||||
},
|
||||
);
|
||||
vp.bind_cmd(
|
||||
KeyCode::Char('k'),
|
||||
none,
|
||||
cmd::MovePanelCursor { panel: crate::ui::effect::Panel::View, delta: -1 },
|
||||
cmd::MovePanelCursor {
|
||||
panel: crate::ui::effect::Panel::View,
|
||||
delta: -1,
|
||||
},
|
||||
);
|
||||
vp.bind_cmd(
|
||||
KeyCode::Down,
|
||||
none,
|
||||
cmd::MovePanelCursor { panel: crate::ui::effect::Panel::View, delta: 1 },
|
||||
cmd::MovePanelCursor {
|
||||
panel: crate::ui::effect::Panel::View,
|
||||
delta: 1,
|
||||
},
|
||||
);
|
||||
vp.bind_cmd(
|
||||
KeyCode::Char('j'),
|
||||
none,
|
||||
cmd::MovePanelCursor { panel: crate::ui::effect::Panel::View, delta: 1 },
|
||||
cmd::MovePanelCursor {
|
||||
panel: crate::ui::effect::Panel::View,
|
||||
delta: 1,
|
||||
},
|
||||
);
|
||||
vp.bind_cmd(KeyCode::Enter, none, cmd::SwitchViewAtCursor);
|
||||
vp.bind_cmd(KeyCode::Char('n'), none, cmd::CreateAndSwitchView);
|
||||
@ -461,9 +499,13 @@ impl KeymapSet {
|
||||
ed.bind_cmd(
|
||||
KeyCode::Backspace,
|
||||
none,
|
||||
cmd::PopChar { buffer: "edit".to_string() },
|
||||
cmd::PopChar {
|
||||
buffer: "edit".to_string(),
|
||||
},
|
||||
);
|
||||
ed.bind_any_char(cmd::AppendChar { buffer: "edit".to_string() });
|
||||
ed.bind_any_char(cmd::AppendChar {
|
||||
buffer: "edit".to_string(),
|
||||
});
|
||||
set.insert(ModeKey::Editing, Arc::new(ed));
|
||||
|
||||
// ── Formula edit mode ────────────────────────────────────────────
|
||||
@ -473,9 +515,13 @@ impl KeymapSet {
|
||||
fe.bind_cmd(
|
||||
KeyCode::Backspace,
|
||||
none,
|
||||
cmd::PopChar { buffer: "formula".to_string() },
|
||||
cmd::PopChar {
|
||||
buffer: "formula".to_string(),
|
||||
},
|
||||
);
|
||||
fe.bind_any_char(cmd::AppendChar { buffer: "formula".to_string() });
|
||||
fe.bind_any_char(cmd::AppendChar {
|
||||
buffer: "formula".to_string(),
|
||||
});
|
||||
set.insert(ModeKey::FormulaEdit, Arc::new(fe));
|
||||
|
||||
// ── Category add mode ────────────────────────────────────────────
|
||||
@ -486,9 +532,13 @@ impl KeymapSet {
|
||||
ca.bind_cmd(
|
||||
KeyCode::Backspace,
|
||||
none,
|
||||
cmd::PopChar { buffer: "category".to_string() },
|
||||
cmd::PopChar {
|
||||
buffer: "category".to_string(),
|
||||
},
|
||||
);
|
||||
ca.bind_any_char(cmd::AppendChar { buffer: "category".to_string() });
|
||||
ca.bind_any_char(cmd::AppendChar {
|
||||
buffer: "category".to_string(),
|
||||
});
|
||||
set.insert(ModeKey::CategoryAdd, Arc::new(ca));
|
||||
|
||||
// ── Item add mode ────────────────────────────────────────────────
|
||||
@ -499,9 +549,13 @@ impl KeymapSet {
|
||||
ia.bind_cmd(
|
||||
KeyCode::Backspace,
|
||||
none,
|
||||
cmd::PopChar { buffer: "item".to_string() },
|
||||
cmd::PopChar {
|
||||
buffer: "item".to_string(),
|
||||
},
|
||||
);
|
||||
ia.bind_any_char(cmd::AppendChar { buffer: "item".to_string() });
|
||||
ia.bind_any_char(cmd::AppendChar {
|
||||
buffer: "item".to_string(),
|
||||
});
|
||||
set.insert(ModeKey::ItemAdd, Arc::new(ia));
|
||||
|
||||
// ── Export prompt mode ───────────────────────────────────────────
|
||||
@ -511,9 +565,13 @@ impl KeymapSet {
|
||||
ep.bind_cmd(
|
||||
KeyCode::Backspace,
|
||||
none,
|
||||
cmd::PopChar { buffer: "export".to_string() },
|
||||
cmd::PopChar {
|
||||
buffer: "export".to_string(),
|
||||
},
|
||||
);
|
||||
ep.bind_any_char(cmd::AppendChar { buffer: "export".to_string() });
|
||||
ep.bind_any_char(cmd::AppendChar {
|
||||
buffer: "export".to_string(),
|
||||
});
|
||||
set.insert(ModeKey::ExportPrompt, Arc::new(ep));
|
||||
|
||||
// ── Command mode ─────────────────────────────────────────────────
|
||||
@ -522,7 +580,9 @@ impl KeymapSet {
|
||||
// Enter → execute_command (still handled by old handler for now —
|
||||
// the complex execute_command logic isn't easily a single Cmd)
|
||||
cm.bind_cmd(KeyCode::Backspace, none, cmd::CommandModeBackspace);
|
||||
cm.bind_any_char(cmd::AppendChar { buffer: "command".to_string() });
|
||||
cm.bind_any_char(cmd::AppendChar {
|
||||
buffer: "command".to_string(),
|
||||
});
|
||||
set.insert(ModeKey::CommandMode, Arc::new(cm));
|
||||
|
||||
// ── Search mode ──────────────────────────────────────────────────
|
||||
|
||||
@ -116,7 +116,7 @@ fn mode_name(mode: &AppMode) -> &'static str {
|
||||
AppMode::CategoryAdd { .. } => "NEW CATEGORY",
|
||||
AppMode::ItemAdd { .. } => "ADD ITEMS",
|
||||
AppMode::ViewPanel => "VIEWS",
|
||||
AppMode::TileSelect { .. } => "TILES",
|
||||
AppMode::TileSelect => "TILES",
|
||||
AppMode::ImportWizard => "IMPORT",
|
||||
AppMode::ExportPrompt { .. } => "EXPORT",
|
||||
AppMode::CommandMode { .. } => "COMMAND",
|
||||
@ -129,7 +129,7 @@ fn mode_style(mode: &AppMode) -> Style {
|
||||
match mode {
|
||||
AppMode::Editing { .. } => Style::default().fg(Color::Black).bg(Color::Green),
|
||||
AppMode::CommandMode { .. } => Style::default().fg(Color::Black).bg(Color::Yellow),
|
||||
AppMode::TileSelect { .. } => Style::default().fg(Color::Black).bg(Color::Magenta),
|
||||
AppMode::TileSelect => Style::default().fg(Color::Black).bg(Color::Magenta),
|
||||
_ => Style::default().fg(Color::Black).bg(Color::DarkGray),
|
||||
}
|
||||
}
|
||||
|
||||
@ -385,7 +385,6 @@ impl App {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
fn handle_wizard_key(&mut self, key: KeyEvent) -> Result<()> {
|
||||
if let Some(wizard) = &mut self.wizard {
|
||||
match &wizard.step.clone() {
|
||||
@ -536,7 +535,7 @@ impl App {
|
||||
AppMode::CategoryAdd { .. } => "Enter:add & continue Tab:same Esc:done — type a category name",
|
||||
AppMode::ItemAdd { .. } => "Enter:add & continue Tab:same Esc:done — type an item name",
|
||||
AppMode::ViewPanel => "jk:nav Enter:switch n:new d:delete Esc:back",
|
||||
AppMode::TileSelect { .. } => "hl:select Enter:cycle r/c/p/n:set-axis Esc:back",
|
||||
AppMode::TileSelect => "hl:select Enter:cycle r/c/p/n:set-axis Esc:back",
|
||||
AppMode::CommandMode { .. } => ":q quit :w save :import :add-cat :formula :show-item :help",
|
||||
AppMode::ImportWizard => "Space:toggle c:cycle Enter:next Esc:cancel",
|
||||
_ => "",
|
||||
|
||||
@ -26,7 +26,11 @@ pub struct TileBar<'a> {
|
||||
|
||||
impl<'a> TileBar<'a> {
|
||||
pub fn new(model: &'a Model, mode: &'a AppMode, tile_cat_idx: usize) -> Self {
|
||||
Self { model, mode, tile_cat_idx }
|
||||
Self {
|
||||
model,
|
||||
mode,
|
||||
tile_cat_idx,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,7 +71,7 @@ impl<'a> Widget for TileBar<'a> {
|
||||
}
|
||||
|
||||
// Hint
|
||||
if matches!(self.mode, AppMode::TileSelect { .. }) {
|
||||
if matches!(self.mode, AppMode::TileSelect) {
|
||||
let hint = " [Enter] cycle axis [r/c/p] set axis [←→] select [Esc] cancel";
|
||||
if x + hint.len() as u16 <= area.x + area.width {
|
||||
buf.set_string(x, area.y, hint, Style::default().fg(Color::DarkGray));
|
||||
|
||||
Reference in New Issue
Block a user