termux / termux-app

Termux - a terminal emulator application for Android OS extendible by variety of packages.
https://f-droid.org/en/packages/com.termux
Other
34.69k stars 3.65k forks source link

chromeos: better support for using terminal mouse events AND selection/copy? #725

Open robolange opened 6 years ago

robolange commented 6 years ago

I use Termux (latest available in Play Store) on ChromeOS (66.0.3359.203 on an Asus C301S) and run a number of console programs that can accept terminal mouse input (emacs, weechat, tmux). When a console program accepts mouse input, Termux passes the mouse events through and it works nicely, but at the same time, it disables the long-press to open the selection menu. Thus, my choice is to use terminal mouse events XOR to be able to copy text from Termux to ChromeOS. (Note: paste from ChromeOS to Termux is unaffected, b/c the hardware keyboard Ctrl+Alt+V allows it to work.)

I have currently handled this by explicitly disabling terminal mouse events in my Termux dotfiles. However, this is suboptimal because it represents a (currently the only) difference between my regular Linux dotfiles and Termux dotfiles, and using the mouse in console programs is occasionally useful. If I can get a way of using terminal mouse events AND copying text from Termux to ChromeOS, then I can use a single set of dotfiles for both environments.

I'm thinking of two alternative ways to solve this:

  1. A new hardware keyboard shortcut to activate the selection menu. This would probably be the easiest, but I'd rather avoid making more Termux shortcuts that might conflict with peoples' existing keybindings.

  2. Provide a way to switch from the regular popup menu (activated by keyboard shortcut Ctrl+Alt+M) to the selection menu. You can currently switch from the selection menu to the regular popup menu by clicking the "More..." button; perhaps there could be a "Selection..." button to switch from the regular popup menu to the selection menu?

Another alternative that I'm guessing would be more complex to implement:

  1. Gnome Terminal has a similar issue that terminal apps accepting mouse events disables its built-in mouse actions. With Gnome Terminal, when you hold the Shift key, mouse events are handled directly by Gnome Terminal and not passed through to the app running in the terminal.

Any thoughts or ideas?

gsf commented 6 years ago

Hi @robolange!

I've had termux on my phone for a while, but I've just started using it on my Chromebook. It's great! I even ponied up for "Termux:Styling". I was pretty thrown off by the mouse handling, though. Copying and pasting with the Android context menu and those blue selection handles is wack. After cribbing from this issue and #366, I think I've arrived at a solution that works for me.

I'm on neovim, so I tried set mouse=a to turn on mouse input. No more blue handles! Window resizing and Visual selection! As you noted, however, I could no longer copy text. But I got around that by switching vim to the system clipboard with set clipboard=unnamed, and now anything I yank is available to paste. The popup menu is even accessible still with a right click. Wunderbar!

You mentioned emacs and weechat, but if you're using both in tmux, the pbcopy suggestion in #366 might work for you.

PS Along the way I also installed "Termux:API" and ran pkg install termux-api, but I don't know if that was necessary.