twin icon indicating copy to clipboard operation
twin copied to clipboard

GPM support in Twin Term

Open RealSuperRyn opened this issue 1 year ago • 8 comments

It would be amazing for productivity in Twin if the terminals inside it had mouse support. You could use Midnight Commander as if it were a GUI file manager in a graphical environment, without having to remember tons of keybinds.

If this is already possible in a TTY, please let me know.

RealSuperRyn avatar Jul 29 '23 02:07 RealSuperRyn

it is already possible. gpm is one of the dependencies. most distros disabled the sevice.

Mirppc avatar Jul 29 '23 02:07 Mirppc

it is already possible. gpm is one of the dependencies. most distros disabled the sevice.

I already have GPM enabled on my system. The issue is that my mouse inputs aren't detected by the applications in the terminals. If i open Midnight commander in my TTY, I can click, say for example a folder, and it'll select it, but if I open Twin, open an instance of Twin Term, and open Midnight commander in there, that functionality is lost.

RealSuperRyn avatar Jul 29 '23 03:07 RealSuperRyn

This was an issue with YAST on my Opensuse machines where if i opened YAST via a TTY/SSH session running twin i would lose GPM. Right now i seem to be having more issues building the latest version so i will have to get back to you after i get a build going and do some testing.

Mirppc avatar Jul 29 '23 03:07 Mirppc

GPM is needed for mouse support when running mouse-aware programs (including twin) directly on the Linux console - it's not needed in other cases.

Twin terminals emulate a Linux console (plus some extra features), thus set $TERM=linux. An actual Linux console does not "natively" support mouse: when running inside it, programs need to manually connect to a dedicated GPM daemon to receive mouse events. Instead Twin terminals natively support mouse, i.e. they also provide xterm-style mouse events - if a program enables them by sending the appropriate escape sequences.

The problem is lots of mouse-aware programs, including Midnight Commander, check the environment variable $TERM to decide whether the terminal supports mouse or not: for $TERM=linux they do not even try to enable xterm-style mouse events.

You can try to cheat a little and manually run TERM=xterm; export TERM before running Midnight Commander - let me know if it helps.

cosmos72 avatar Jul 29 '23 08:07 cosmos72

You can try to cheat a little and manually run TERM=xterm; export TERM before running Midnight Commander - let me know if it helps.

~~While it did "work", it ended up causing garbled output.~~ I just remembered that the mouse drivers on the latest version aren't working, this text is from me executing htop earlier on the ubuntu release, which screwed up the top panel whar This hack doesn't do anything.

RealSuperRyn avatar Jul 29 '23 16:07 RealSuperRyn

Can confirm. Only applications which use xterm way of handling mouse inputs seem to work. vim and midnight commander (the only ones I know which use GPM directly) are broken and ignore mouse clicks in twin.

Lassebq avatar Sep 12 '23 18:09 Lassebq

Yes, because vim and midnight commander see the environment variable TERM=linux (twin terminals emulate a Linux console) and they immediately assume to be running directly inside an actual Linux console, thus they try to use GPM for mouse support.

As I wrote above, a possible workaround (which may not work, as xterm and linux terminals are not fully compatible), is to slightly cheat and set TERM=xterm before launching vim, midnight commander or other GPM-aware programs.

The better solution would be to search in vim and midnight commander's documentation for how to enable xterm-compatibile mouse support also when TERM is different from xterm

cosmos72 avatar Sep 12 '23 20:09 cosmos72

Setting TERM does the trick, sorry for confusion

Lassebq avatar Sep 13 '23 06:09 Lassebq