Skip to content

Add "Run Command" window#5393

Merged
dacap merged 1 commit into
aseprite:betafrom
ckaiser:command-runner
Sep 19, 2025
Merged

Add "Run Command" window#5393
dacap merged 1 commit into
aseprite:betafrom
ckaiser:command-runner

Conversation

@ckaiser

@ckaiser ckaiser commented Aug 28, 2025

Copy link
Copy Markdown
Member

Adds a command runner/"command palette" with the following features:

  • Search through all of the Aseprite Commands, including variations with parameters declared as keyboard shortcuts.
  • Math expressions
  • Inline Lua script evaluation.

An (outdated now) video showcase of everything it has to offer:

runner_demo.mp4

Some things needed in order to finish this:

  • Noticed a duplicate on the layer properties command, might be because of duplicated shortcuts?
  • Decide on the shortcut, right now it's Ctrl+Shift+R Ctrl+Space
  • The sorting order tries to be smart but that might be more confusing than straight up matching
  • Decide how many results we want to include, and if we want pagination/scrolling
  • When writing and deleting a word, we show the very first available commands in the sort order (and also it can sometimes show two highlighted commands when using kbm navigation)
  • Code TODOs

@aseprite-bot aseprite-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

Comment thread src/app/app_menus.h
Comment thread src/app/commands/cmd_run_command.cpp Outdated
Comment thread src/app/commands/cmd_run_command.cpp Outdated
Comment thread src/app/commands/cmd_run_command.cpp
Comment thread src/app/commands/cmd_run_command.cpp
Comment thread src/app/commands/cmd_run_command.cpp
Comment thread src/app/commands/cmd_run_command.cpp
Comment thread src/app/commands/cmd_run_command.cpp Outdated
Comment thread src/app/commands/cmd_run_command.cpp Outdated
Comment thread src/ui/widget.cpp

@aseprite-bot aseprite-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

Comment thread src/app/commands/cmd_run_command.cpp
Comment thread src/app/commands/cmd_run_command.cpp
Comment thread src/app/match_words.h
Comment thread src/app/match_words.h
@ckaiser ckaiser force-pushed the command-runner branch 3 times, most recently from ac4ea05 to 5d9fb36 Compare September 2, 2025 08:33
@ckaiser

ckaiser commented Sep 2, 2025

Copy link
Copy Markdown
Member Author

Added fuzzy string matching, we now check for duplicates and commands with isChecked(...) == true show up with a little checkbox.

@dacap AFAIK there's no way to check if a command is functions like a "toggle", you can call isChecked to know if it's checked, but there's nothing you can call to see if we should show an empty checkbox or maybe do the toggle inside the runner without leaving, might be worth seeing if we wanna add something like Command::isToggleable() to distinguish them?

image image

@dacap

dacap commented Sep 3, 2025

Copy link
Copy Markdown
Member

This looks great 🚀

Added fuzzy string matching, we now check for duplicates
and commands with isChecked(...) == true show up with a little checkbox.

Nice!

@dacap AFAIK there's no way to check if a command is functions like a "toggle", you can call isChecked to know if it's checked, but there's nothing you can call to see if we should show an empty checkbox or maybe do the toggle inside the runner without leaving, might be worth seeing if we wanna add something like Command::isToggleable() to distinguish them?

We could change the isChecked() return value to std::optional<bool> probably, but I'm not sure if we should show an unchecked box for these togglable commands (as I think an empty box will be confusing for these cases). At the moment I'd avoid this.

Some notes:

  1. probably the =... syntax is not needed, we can just evaluate the expression and if the expression works and is different to what is written, we show the result (+search for commands, just like google works).
  2. We can set Ctrl+Space as the default shortcut for this.
  3. Should we order things by menu order? For example, if we search for open
    image
    "Open sprite" is a good first candidate and "open browser" isn't (as it requires parameters too).

@ckaiser ckaiser force-pushed the command-runner branch 2 times, most recently from 2651a64 to cf3f061 Compare September 7, 2025 04:56
@ckaiser

ckaiser commented Sep 7, 2025

Copy link
Copy Markdown
Member Author

Adjusted things to avoid listing commands that need parameters to function (added a few missing onNeedParams() implementations), tweaked the search score a bit so it prioritizes commands of similar length to what you're typing to mitigate your case, although at this point I might rethink the whole thing cuz it's getting a bit arbitrary maybe?

probably the =... syntax is not needed, we can just evaluate the expression and if the expression works and is different to what is written, we show the result (+search for commands, just like google works).

Personally I like it better with the prefix because it clearly delineates things as separate "mode", like the Lua expression editor and more importantly makes the code simpler and more readable IMO, it's already a bit complicated as it is. We're also already doing a bunch of things on every Entry::Change so I'd like to avoid doing more, I picked "=" since it's what you to use to do math in Excel formulas so it might be familiar to some.

@ckaiser ckaiser assigned dacap and unassigned ckaiser Sep 7, 2025
@dacap

dacap commented Sep 17, 2025

Copy link
Copy Markdown
Member

I think it's working great 👍 we can merge it as it is (you can move this to "ready for review") and I'll merge it just in case something is missing.

After this is merged I'll make some little changes to the window title bar to reduce a little the translation/i18n work.

@dacap dacap assigned ckaiser and unassigned dacap Sep 17, 2025
@ckaiser ckaiser marked this pull request as ready for review September 17, 2025 17:15
@ckaiser ckaiser requested a review from dacap as a code owner September 17, 2025 17:15
@ckaiser

ckaiser commented Sep 17, 2025

Copy link
Copy Markdown
Member Author

Great! I've marked it ready for review and I'll get to writing the documentation so the "?" button doesn't link to a 404 page

@dacap dacap added this to the v1.3.16-beta1 milestone Sep 19, 2025
@dacap dacap merged commit 6f1870c into aseprite:beta Sep 19, 2025
12 checks passed
@dacap dacap mentioned this pull request Nov 25, 2025
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.

3 participants