From b067a84b360d26a2b90eb2ca24af05597b7098c5 Mon Sep 17 00:00:00 2001 From: Johan Walles Date: Sat, 16 Dec 2023 18:59:58 +0100 Subject: [PATCH] Auto configure mouse settings in more terminals Tested all the Linux ones in Virtualbox. Yay Virtualbox! --- MOUSE.md | 1 + README.md | 2 ++ twin/screen.go | 35 +++++++++++++++++++++++++++++------ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/MOUSE.md b/MOUSE.md index a6aff62..675afc8 100644 --- a/MOUSE.md +++ b/MOUSE.md @@ -22,6 +22,7 @@ other terminals will send nothing, making scrolling not work. ## Text Marking Workarounds in `scroll` Mode - **Alacritty**: Use use shift + mouse selection to make it work. Cred to @chrisgrieser for this tip. +- **Foot**: Use use shift + mouse selection to make it work. Cred to @postsolar for this tip. - **Hyper** on macOS: Set `macOptionSelectionMode: 'force'` in your config file, then hold the Option Key while marking - **iTerm**: Preferences / Profiles / Default / Terminal / uncheck "Report mouse clicks & drags" - macOS **Terminal** on a laptop: Hold down the fn key while marking with the mouse diff --git a/README.md b/README.md index aca6749..9fb8a94 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,8 @@ Doing the right thing includes: - Renders [terminal hyperlinks](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda) properly +- **Mouse Scrolling** works out of the box (but + [look here for tradeoffs](https://github.com/walles/moar/blob/master/MOUSE.md)) [For compatibility reasons](https://github.com/walles/moar/issues/14), `moar` uses the formats declared in these environment variables if present: diff --git a/twin/screen.go b/twin/screen.go index 47c6acd..4899187 100644 --- a/twin/screen.go +++ b/twin/screen.go @@ -204,15 +204,11 @@ func (screen *UnixScreen) hideCursor(hide bool) { // See also: https://github.com/walles/moar/issues/53 func terminalHasArrowKeysEmulation() bool { // Untested: - // * https://codeberg.org/dnkl/foot - // * Konsole - // * https://github.com/gnome-terminator/terminator - // * https://gnunn1.github.io/tilix-web/ // * The Windows terminal // Better off with mouse tracking: - // * iTerm2 - // * Terminal.app + // * iTerm2 (macOS) + // * Terminal.app (macOS) // Hyper, tested on macOS, December 14th 2023 if os.Getenv("TERM_PROGRAM") == "Hyper" { @@ -234,6 +230,33 @@ func terminalHasArrowKeysEmulation() bool { return true } + // GNOME Terminal, tested on Ubuntu 22.04, December 16th 2023 + if os.Getenv("GNOME_TERMINAL_SCREEN") != "" { + return true + } + + // Tilix, tested on Ubuntu 22.04, December 16th 2023 + if os.Getenv("TILIX_ID") != "" { + return true + } + + // Konsole, tested on Ubuntu 22.04, December 16th 2023 + if os.Getenv("KONSOLE_VERSION") != "" { + return true + } + + // Terminator, tested on Ubuntu 22.04, December 16th 2023 + if os.Getenv("TERMINATOR_UUID") != "" { + return true + } + + // Foot, tested on Ubuntu 22.04, December 16th 2023 + if os.Getenv("TERM") == "foot" { + // Note that this test isn't very good, somebody could be running Foot + // with some other TERM setting. Other suggestions welcome. + return true + } + return false }