feat: add Undo action variant and actions-on-double-click#482
feat: add Undo action variant and actions-on-double-click#482clansty wants to merge 1 commit intoSatty-org:mainfrom
Conversation
- Add `undo` as a new Action variant usable in `actions-on-right-click`, `actions-on-enter`, `actions-on-escape`, and the new `actions-on-double-click`. Undo is a fallible action: if it succeeds, further actions in the list are skipped; if nothing to undo, processing continues to the next action. - Add `--actions-on-double-click` as a configurable action list triggered by primary button double-click. Falls back to `actions-on-enter` when not set. Only fires when the active tool does not stop propagation (text tool word selection is unaffected). - Move right-click handling from InputEvent::handle_mouse_event() into the update() method where SketchBoard state (handle_undo) is accessible. Closes Satty-org#481
There was a problem hiding this comment.
Pull request overview
Adds a new undo action variant and introduces a configurable double-click action list, expanding Satty’s configurable “action list” input triggers beyond Enter/Escape/Right-click.
Changes:
- Add
Action::Undoand plumb it through configuration + CLI parsing. - Add
--actions-on-double-click(with fallback toactions-on-enterwhen unset). - Move right-click handling into
SketchBoard::update()and addprocess_actions()soundocan be executed from mouse-triggered action lists.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/sketch_board.rs |
Adds process_actions() and handles right-click + double-click action triggering in update() so Undo can run with full board state. |
src/configuration.rs |
Adds Undo action variant and a new actions_on_double_click configuration field with merge/default/getter wiring. |
cli/src/command_line.rs |
Adds --actions-on-double-click CLI option and exposes undo in the CLI Action enum. |
README.md |
Documents undo as a possible action value and documents the new double-click actions option. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| fn handle_action(&mut self, actions: &[Action]) -> ToolUpdateResult { | ||
| let rv = if self.deactivate_active_tool() { | ||
| ToolUpdateResult::Redraw | ||
| } else { | ||
| ToolUpdateResult::Unmodified | ||
| }; | ||
| self.renderer.request_render(actions); | ||
| rv | ||
| } | ||
|
|
||
| fn process_actions(&mut self, actions: &[Action]) -> ToolUpdateResult { | ||
| let mut render_actions = Vec::new(); | ||
| for action in actions { | ||
| match action { | ||
| Action::Undo => { | ||
| if !matches!(self.handle_undo(), ToolUpdateResult::Unmodified) { | ||
| return ToolUpdateResult::Redraw; | ||
| } | ||
| } | ||
| other => render_actions.push(*other), | ||
| } | ||
| } | ||
| if render_actions.is_empty() { | ||
| ToolUpdateResult::Unmodified | ||
| } else { | ||
| self.handle_action(&render_actions) | ||
| } |
There was a problem hiding this comment.
Action::Undo is only executed when action lists go through process_actions(). The Enter/Escape keypath still calls renderer.request_render(&actions) directly, so undo in actions_on_enter/actions_on_escape will be ignored (and e.g. undo,exit will always exit). Route those key-triggered action lists through process_actions() (or otherwise handle Undo before calling request_render) so the README/PR semantics hold for all supported triggers.
Summary
Closes #481
undoas a newActionvariant, usable inactions-on-right-click,actions-on-enter,actions-on-escape, and the newactions-on-double-click--actions-on-double-clickas a configurable action list triggered by primary button double-click, falling back toactions-on-enterwhen not setupdate()wherehandle_undo()is accessibleUndo semantics
undois a fallible action: if it succeeds, further actions in the list are skipped; if nothing to undo, processing continues to the next action. This enables patterns like:Which means: "undo one step; if nothing left to undo, exit (cancel)".
Double-click
Only fires when the active tool does not stop propagation — text tool word selection (
n_pressed == 2→RedrawAndStopPropagation) is unaffected.