-
Notifications
You must be signed in to change notification settings - Fork 331
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
Add mouse support for selecting and opening files #963
Conversation
518bdca
to
f5b536c
Compare
for i := 0; i < wins; i++ { | ||
if dir := ui.dirOfWin(nav, i); dir != nil { | ||
ui.wins[i].printDir(ui.screen, dir, nav.selections, nav.saves, nav.tags, ui.styles, ui.icons) | ||
} |
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.
No functional change here, just refactored to use dirOfWin.
} | ||
|
||
var file *file | ||
ind := dir.ind - dir.pos + y - w.y |
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.
I saw max(dir.ind-dir.pos, 0)
elsewhere, but I'm pretty sure dir.pos
will never be greater than dir.ind
.
@p-ouellette Can you update this patch to resolve conflicts? |
@p-ouellette I tried this out, and it's really nice, but there seem to either be some bug or this triggers some tcell/tmux bug. I get problems if I either click or scroll the mouse wheel while the mouse is over the This is in tmux with If you can't reproduce this, I can look in more details to either send you my config or find the problem. |
I think I narrowed down the bug I described above and figured out why you didn't catch it, @p-ouellette. It has to do with the interaction of your code and the mouse support in The config necessary to reproduce it is (in lf) To reproduce the bug, start I still don't know the exact problem, but it feels like maybe |
f5b536c
to
d7e789e
Compare
ui.go
Outdated
@@ -932,8 +951,8 @@ func (ui *ui) draw(nav *nav) { | |||
preview := ui.wins[len(ui.wins)-1] | |||
|
|||
if curr.IsDir() { | |||
preview.printDir(ui.screen, ui.dirPrev, &context, | |||
&dirStyle{colors: ui.styles, icons: ui.icons, previewing: true}) | |||
style.previewing = true |
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.
Minor nit: I'm not a fan of this refactoring. I prefer as many variables as possible to be immutable, so that the reader doesn't have to pay careful attention to how it might change on them. This makes it seem that there's some important and confusing logic that will use the value of style
below.
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.
If you don't like the original version, I would prefer:
previewStyle := dirStyle{colors: style.colors, icons: style.icons, previewing: true}
preview.printDir(..., previewStyle)
I'm unsure if Go provides a shorter way to write that.
Left click to select, right click to open, similar to ranger. Closes gokcehan#919.
d7e789e
to
aa4bd9c
Compare
Rebased and updated for dirpreviews option. @ilyagr thanks for testing. I can reproduce the bug. tcell is sending a button click event instead of a scroll event. The problem seems to be here: https://github.com/gdamore/tcell/blob/b9dc8a651aa1e7e564025ceb6bfa9a0f8fbceee4/tscreen.go#L1225. After clicking to open |
@p-ouellette Naively, maybe it would help to make Update: Another potential, naive, workaround: after |
Commit d3cbfcf fixes a bug where mouse wheel events were misdelivered as button events.
The tcell bug is fixed: gdamore/tcell@d3cbfcf. I updated the dependency in lf to that commit. |
@p-ouellette Thanks for the patch. |
Nice! It works great for me so far. We should probably update to an official release of |
Left click to select, right click to open, similar to ranger. Closes #919.
Mouse mappings work as before and override the default behavior.
Mouse is disabled in command-line mode.