cosmos72 / twin

Text mode window environment. A "retro" program for embedded or remote systems, that doubles as X11 terminal and text-mode equivalent of VNC server
Other
651 stars 38 forks source link

GPM support in Twin Term #89

Open RealSuperRyn opened 1 year ago

RealSuperRyn commented 1 year ago

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.

Mirppc commented 1 year ago

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

RealSuperRyn commented 1 year ago

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.

Mirppc commented 1 year ago

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.

cosmos72 commented 1 year ago

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.

RealSuperRyn commented 1 year ago

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.

Lassebq commented 1 year ago

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.

cosmos72 commented 1 year ago

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

Lassebq commented 1 year ago

Setting TERM does the trick, sorry for confusion