Skip to content

Pass mouse info to {on,pre}MouseXXX callbacks #3779

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

dmaluka
Copy link
Collaborator

@dmaluka dmaluka commented Jun 21, 2025

Pass *tcell.EventMouse to action callbacks for "mouse actions", i.e. to onMousePress, preMouseDrag and so on, similarly to how we pass it to lua functions bound to mouse events.

dmaluka added 3 commits June 21, 2025 03:04
So that we can pass extra arguments to bufpane callbacks easily, by
passing them directly to PluginCB().
Pass *tcell.EventMouse to action callbacks for "mouse actions", i.e. to
onMousePress, preMouseDrag and so on, similarly to how we pass it to lua
functions bound to mouse events.
Now that we can pass extra args directly to PluginCB(), we can remove
PluginCBRune() for simplicity.
@cutelisp
Copy link
Contributor

Thanks for this! I tested and it seems to be working fine.

@@ -570,7 +568,7 @@ func (h *BufPane) execAction(action BufAction, name string, te *tcell.EventMouse
case BufMouseAction:
success = a(h, te)
}
success = success && h.PluginCB("on"+name)
success = success && h.PluginCB("on"+name, te)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We add this now also for BufKeyAction too, right?
Furthermore...is this optional argument really backward compatible? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We add this now also for BufKeyAction too, right?

Yes, but it is nil in that case.

Furthermore...is this optional argument really backward compatible? 🤔

Non-intuitively yes. You can try it. A lua function is free to receive less arguments than we pass to it, or more arguments than we pass to it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, ok. Then it is legit. 👍

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