-
Notifications
You must be signed in to change notification settings - Fork 421
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
feat: support mouse event #1038
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 |
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
MouseEvent
in the terminal and spawn it to theApp
struct, thenApp
will try to dispatch this event and route this event to themouse
method in different components (Header
,Manager
, andStatus
), based on coordination comparison between mouse event andRect
fromLayout
. TheManager
is a special case. Because inLAYOUT
,Manager
is divided intoCurrent
,Parent
andPreview
. So I create a newenum ManagerComponent
to indicate which specific component in Manager this MouseEvent belongs to and pass it as an argument. Themouse
method will finally encapsulate theMouseEvent
as lua object and invoke the correspondingmouse
method in lua field.In the lua field, I create a new type named
MouseEvent
, which contains the following attributes:nil
for events that are notDown
,Up
, andDrag
u8
valueThe different
kind
andbutton
are indicated as different numbers, specifically:For
kind
:For
button
button
will benil
for 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, onlyCurrent
window supports item-based scrolling. Scrolling inPreview
will invoke theseek
in the preview window.Here are some potential things that people may like to see:
ranger
Preview
andParent
windowAFAIK, both of them need a new API for
ya.manager_emit
to 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.