kevinhwang91 / rnvimr

Make Ranger running in a floating window to communicate with Neovim via RPC
BSD 3-Clause "New" or "Revised" License
800 stars 17 forks source link

mouse click not working #151

Closed litoj closed 1 year ago

litoj commented 1 year ago

After last commit, scrolling works beautifully, but clicking unfortunately still does nothing.

tried with neovim 0.9

Zeioth commented 1 year ago

Good point, I didn't noticed. I'm not 100% sure if this is a limitation of neovim. I will test the patch with different options. Let's research the available options in :help mouse

kevinhwang91 commented 1 year ago

I think it's hart to fix. Need capture current cursor and fire click action manually.

Zeioth commented 1 year ago

I've found a better solution. But it is something that might not work for all users, as it depends on their term codes: https://github.com/neovim/neovim/issues/21106#issuecomment-1323511826

  # This will only work if mouse=a is setted.
  printf "\x1b[?1000h" # On the term, set term code before launching rnvimr

That implementation gives 100% mouse support (left click, right cllick, mid click, and scroll) on xterm-256color terminals and tmux. I propose this over the current implementation, but as an opt-out option so users using terminals that doesn't use xterm-256color can still implement their own solution by setting the option to false.

At very least it should work on all modern terminals using xterm-256color. I'll prepare a PR later so we can test it.

kevinhwang91 commented 1 year ago

I review the thread from core you mention and it inspires me a lot. We can just write \x1b[?1000h to stderr of ranger terminal. However, we can't get the stderr file handle from the vimscript API, using a Lua luv API can write the code sequence to stderr file handle. We can also send sequence inside ranger that use python code after ranger is stable, but it looks like a bad solution.

Why don't we send the code sequence before running ranger? Here is the related answer https://github.com/kevinhwang91/rnvimr/pull/114.

kevinhwang91 commented 1 year ago

Found nvim_get_chan_info API get dev handle.

litoj commented 1 year ago

Works beautifully on foot, thanks a lot!

Zeioth commented 1 year ago

This is so awesome. Thank you for implementing it @kevinhwang91. I was struggling. Everything works now.