-
Notifications
You must be signed in to change notification settings - Fork 658
feat: support mouse event #1038
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
Conversation
|
Thank you for the awesome work! Mouse support is a feature I've been wanting to add for a while, and I'm very happy to see it implemented now! It definitely deserves a separate version to be released ;) |
|
Here are some change requests:
And the
When the event type is |
How to deal with |
|
I've updated the comment |
|
I've finished the requested change, could you have a look at it? |
yazi-fm/src/components/manager.rs
Outdated
| cx: &crate::context::Ctx, | ||
| ) { | ||
| let position = Position { x: event.column, y: event.row }; | ||
| let comp = if layout.preview.contains(position) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Manager component should only include the logic for Moved and Drag(MouseButton), all others should be dispatched to specific components (Parent, Current, Preview). There are no parent.rs and current.rs currently, please create them.
|
Finished the review requests as described (if I understand correctly). |
|
Thanks for the change! I will review it in the next 1 or 2 days |
sxyazi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good now, let me merge it then.
Thank you so much for contributing this awesome feature!
|
Does click and drag work for selecting items? Like spacebar selection |
I didn't implement these in this PR. This PR only has built-in support for scroll and click. However I think it should be easy to implement through the current Lua API. |
screenshot-000232.mp4
Hi. Thanks for this amazing project! This is an attempt to add mouse support to yazi. I make it as a draft PR because I think it still needs tasks to be done before it can be merged. But I would appreciate it if I could get some early feedback from reviewing and help me to know what is the next step.
This PR tries to enable capturing
MouseEventin the terminal and spawn it to theAppstruct, thenAppwill try to dispatch this event and route this event to themousemethod in different components (Header,Manager, andStatus), based on coordination comparison between mouse event andRectfromLayout. TheManageris a special case. Because inLAYOUT,Manageris divided intoCurrent,ParentandPreview. So I create a newenum ManagerComponentto indicate which specific component in Manager this MouseEvent belongs to and pass it as an argument. Themousemethod will finally encapsulate theMouseEventas lua object and invoke the correspondingmousemethod in lua field.In the lua field, I create a new type named
MouseEvent, which contains the following attributes:nilfor events that are notDown,Up, andDragu8valueThe different
kindandbuttonare indicated as different numbers, specifically:For
kind:For
buttonbuttonwill benilfor events other thanDown,Up, andDrag.Currently, only "left click to jump" is fully supported by lua script, which is implemented by
ya.manager_emit("reveal", { f.url }). For scrolling, onlyCurrentwindow supports item-based scrolling. Scrolling inPreviewwill invoke theseekin the preview window.Here are some potential things that people may like to see:
rangerPreviewandParentwindowAFAIK, both of them need a new API for
ya.manager_emitto invoke. If you think that's a good idea, I will try to implement these. Before that, it would be great if you could review the current implementation and provide some feedback.