jtdaugherty / vty

A high-level ncurses alternative written in Haskell
BSD 3-Clause "New" or "Revised" License
319 stars 57 forks source link

Mouse movement events #259

Closed Thecentury closed 1 year ago

Thecentury commented 1 year ago

It looks like vty doesn't support sending notifications about mouse movements when no mouse button is pressed or released. Is it an intentional decision? Or are there some difficulties with supporting this? For example, the .net Terminal.Gui package seems to support such events: https://github.com/gui-cs/Terminal.Gui/blob/develop/Terminal.Gui/Core/EscSeqUtils/EscSeqUtils.cs#L557 and it works not only on Windows but on macOS as well.

jtdaugherty commented 1 year ago

Hi @Thecentury - it’s been a while since I implemented the mouse support that is there now. I don’t remember whether I looked into mouse movement events at the time.

Thinking about it now, I suppose it could be supported, but I’d want to add a note of caution when using it; mouse events are likely to arrive quickly enough that the application could get behind in handling them if its rendering latency was too high. That is likely in more UI-intensive terminal applications like some I’ve worked on, so I don’t think it’s a purely theoretical possibility. In fact, I think my recommendation would be for applications to turn on position reporting only when the application is in a mode that particularly needs it, and then turn it off otherwise. Keep in mind that every single mouse movement event that arrives will likely trigger an application UI redraw, which could be a problem in some applications.

In any case, to support mouse events I’d want to know which sequences are going to reliably report them on the same terminal emulators that already work with Vty’s mouse event reporting. If I recall, my reference for the current support was based on some old Xterm documentation. I’d want to know whether that same set of terminal features includes mouse event reporting.

If it happens that you’re interested in investigating or working on this, please let me know!

Thecentury commented 1 year ago

Hi @jtdaugherty, thank you for the detailed response. I don't feel my current Haskell knowledge is enough to add mouse movement events support, but I'll let you know if I start thinking about implementing it.