Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce performable: prefix for keybind triggers to passthrough if they would do nothing #4328

Closed
mitchellh opened this issue Jan 1, 2025 · 2 comments · Fixed by #4345
Closed
Milestone

Comments

@mitchellh
Copy link
Contributor

mitchellh commented Jan 1, 2025

Discussion: #2811

The discussion was focused on copy but this could apply to many different actions so I think we should generalize it. Ghostty already has a mechanism in performBindingAction to determine if a binding action was performed or not. We can use that.

The new prefix performable: (similar to other prefixes like unconsumed:, all:, global:) would be a new modifier with the following effect:

Details

performable:-prefixed triggers will only apply at all if they can be performed. If they can't be performed, they act as if the keybinding doesn't exist. For example, this can be used with copy to copy or send an interrupt signal:

keybind = performable:ctrl+c=copy_to_clipboard

This trigger interacts with the other prefixes in the following way:

  • global: - No effect. Global actions are always considered performed.
  • all: - No effect. All actions are always considered performed.
  • unconsumed: - Only applies if the action is performable. These two sort of cancel each other out so it's odd to use them both, but it doesn't cause problems.
mitchellh added a commit that referenced this issue Jan 3, 2025
closes #4328
closes #3970

makes this possible now
```
keybind = performable:ctrl+c=copy_to_clipboard # copy if theres a selection else send sigint
keybind = ctrl+v=paste_from_clipboard
```
@github-actions github-actions bot added this to the 1.0.2 milestone Jan 3, 2025
@rinormaloku
Copy link

This is not working as intended, on the latest commit, when there is nothing to copy it is not passing through to termination.

Screenshare.-.2025-01-07.3_16_55.PM.mp4

@mitchellh
Copy link
Contributor Author

This is not working as intended, on the latest commit, when there is nothing to copy it is not passing through to termination.

#4522 is the problem. Fixed for macOS, unsure yet how to fix for GTK.

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 a pull request may close this issue.

2 participants