Closed Kavantix closed 2 years ago
I suspect this has something to do with the move over from termbox to tcell for the terminal rendering library
I was trying to look into this a bit and only found this issue which kinda correspond in tcell
:
https://github.com/gdamore/tcell/issues/480
However, when I tried to upgrade tcell
to the latest version, it didn't really help :/.
Was testing it in neovim and in vim (the same problem). But actually when I was trying _examples/mouse.go
application it didn't really get the mouse event even if any key press happen.
Not sure if this is because of the specific of mouse.go
demo app, or anything else. All the other examples worked well, so the mouse is the only affected.
I will try to debug it later.
@dankox anything I can specifically test?
@Kavantix I'm sorry, I kinda forgot about this issue. However, I was doing some tests and I'm not really sure if this works at all in any case anywhere.
What I was using initialy was vim
with :term
command. But I couldn't make it work even with original gocui which uses termbox
, so I tried it also in nvim
and the result is the same.
Mouse doesn't work for me in vim
or nvim
either using termbox-go
or tcell
.
jroimartin/gocui
(latest which is May 9th) using _examples/mouse.go
termbox-go
using _demos/keyboard.go
and _demos/paint.go
tcell
using _demos/mouse.go
My environment is:
Can you please provide a source code or example of application using original gocui
which uses mouse and works as you described? I want to try to know if it is just my environment or something else. Thanks...
@dankox you probably don’t have mouse mode enabled in vim then (it’s off by default)
You can enable it using set mouse=a
Just tried what you said and my mouse input has no delay:
nvim
set mouse=a
:term
Envourment:
May i ask what terminal emulator you are using?
Weird, I have tried on several terminal emulators (iTerm, kitty, alacritty, macos terminal) and all behave the same on my system. I am using neovim nightly though.
Lazygit is indeed fast but that is still using the termbox version right?
Just tried out the same thing using Neovim nightly (v0.6.0-dev+551-ged2573b7e from aur/neovim-nightly-bin) but it's still as fast.
Lazygit is indeed fast but that is still using the termbox version right?
I think so, this was a tui program i knew has mouse support so i tested it also. tough now looking at it back it was a bit pointless.
Beside gnome-terminal also just tested Alacritty and Tilix but no difference both seem to be as responsive as running directly in the terminal, (this was with neovim v0.6.0)
Ooooooooooh... now I feel stupid 🤦♀️ my bad :)
So I've tried it with set mouse=a
, and I see the difference.
But I have to say, this is a bit weird, because for vim
it works ok... no delay whatsoever. For nvim
however, I can see the delay by one event mentioned in the issue.
If I try the original gocui
from jroimartin, there is no delay. So it's definitely tcell
.
Looking at it more precisely, I think there is something "wrong" with nvim
. I have a guess on what is the main difference (keep it mind this is from top of my head, didn't have time to look into code and debug, will do later).
tcell
register two events, mouse press and mouse release (from what I remember). And I can see in vim
when I try tcell
demo app _demos/mouse.go
the Button1
test appears just shortly and disapear right away after the mouse release.
However in nvim
, this text appears and does not disapear until next event (if next is again mouse click, it will stay).
From this I can guess that nvim
just doesn't propagate mouse release event to terminal (or does it later with next event). Why it works for original gocui is because termbox-go
does not have mouse release. gocui
does not have mouse release either, this is just implementation of tcell
mouse events made to be as similar to original gocui as possible.
What we can do:
nvim
that the event is not send (however, this has to be debugged first to be sure)Anyway, regardless of next action, I want to do some more debugging on this in nvim
because now I have at least an idea what might go wrong.
The first option shouldn't be that hard to implement, as we are in charge of what to do with mouse events, but I'm not sure if it's the best.
@mjarkk can you try tcell
demo application from _demos/mouse.go if it has similar behaviour on linux as I desribed in the post above? This could also narrow down a problem that maybe only macOS version of nvim
has this problem, or maybe it's general.
@dankox thanks for the extensive explanation! Let me know if I can help in any way
Btw, my preference would be adding the mouse release, a drag feature is something I'm planning on adding to one of my projects so would be very welcome
@dankox Just tried out the _demos/mouse.go and now i see the problem the issue describes also on linux with neovim v0.6.0
@Kavantix if you want, you can try to debug it in tcell_driver.go
program (in polling function) to see what events are provided and at what time. That's kinda what I want to do (to see when the mouse release is passed from nvim
).
I want to look at it later this day when I will get the time to get better idea of what is going on.
@dankox @mjarkk I finally go around to testing this. It seems neovim is simply not sending mouse release events
However, the old driver that didnt use tcell seems to handle click events on mouse down not mouse release which is why it's not really a problem with the older version.
I opened neovim/neovim#16371 at their side
@Kavantix thanks for letting us know. I can see that in neovim they are fixing propagation of that event to terminal so that's cool.
I didn't have much time recently to look more into this, but I think we definitely should add the MouseRelease event and implement it properly. Keeping this issue open until it's done.
It should be done correctly so other apps are not affected by it and want to be sure to be compatible with original gocui implementation. So it might take some time, but will try to get to it as soon as possible.
Describe the bug Mouse clicks inside neovim terminal are delayed until the next system event. Mouse handling works fine with
jroimartin/gocui
To Reproduce Steps to reproduce the behavior:
:term
MouseLeft
keybindingExpected behavior The mouse click should be detected immediately
Environment (please complete the following information):
Context
g.Update
does not helpMouseRelease
is trigged (although not on release)`