Skip to content

feat: add Undo action variant and actions-on-double-click#482

Open
clansty wants to merge 1 commit intoSatty-org:mainfrom
clansty:feat/undo-action-and-double-click
Open

feat: add Undo action variant and actions-on-double-click#482
clansty wants to merge 1 commit intoSatty-org:mainfrom
clansty:feat/undo-action-and-double-click

Conversation

@clansty
Copy link
Copy Markdown

@clansty clansty commented Apr 11, 2026

Summary

Closes #481

  • 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
  • Add --actions-on-double-click as a configurable action list triggered by primary button double-click, falling back to actions-on-enter when not set
  • Move right-click handling into update() where handle_undo() is accessible

Undo semantics

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. This enables patterns like:

--actions-on-right-click undo,exit

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 == 2RedrawAndStopPropagation) is unaffected.

- 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
Copilot AI review requested due to automatic review settings April 11, 2026 14:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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::Undo and plumb it through configuration + CLI parsing.
  • Add --actions-on-double-click (with fallback to actions-on-enter when unset).
  • Move right-click handling into SketchBoard::update() and add process_actions() so undo can 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.

Comment on lines 275 to +301
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)
}
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add Undo as an Action variant + double-click to trigger actions-on-enter

2 participants