Skip to content

Commit

Permalink
Auto configure mouse settings in more terminals
Browse files Browse the repository at this point in the history
Tested all the Linux ones in Virtualbox. Yay Virtualbox!
  • Loading branch information
walles committed Dec 16, 2023
1 parent 1d1454a commit b067a84
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
1 change: 1 addition & 0 deletions MOUSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ other terminals will send nothing, making scrolling not work.
## Text Marking Workarounds in `scroll` Mode

- **Alacritty**: Use use <kbd>shift</kbd> + mouse selection to make it work. Cred to @chrisgrieser for this tip.
- **Foot**: Use use <kbd>shift</kbd> + 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 <kbd>⌥</kbd> while marking
- **iTerm**: Preferences / Profiles / Default / Terminal / uncheck "Report mouse clicks & drags"
- macOS **Terminal** on a laptop: Hold down the <kbd>fn</kbd> key while marking with the mouse
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
35 changes: 29 additions & 6 deletions twin/screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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.

This comment has been minimized.

Copy link
@postsolar

postsolar Dec 18, 2023

Contributor

@walles foot-extra is common, I myself use this. Also foot-direct and foot-extra-direct. Reference: https://codeberg.org/dnkl/foot/wiki#user-content-foot-s-terminfo-vs-ncurses-terminfo. I don't think there are any environment vars to query.

This comment has been minimized.

Copy link
@walles

walles Dec 18, 2023

Author Owner

ccc5350 should improve on this at least a bit.

Best thing would be if foot could start identifying itself by setting TERM_PROGRAM=foot or something, at least Warp and Hyper use that variable.

return true
}

return false
}

Expand Down

0 comments on commit b067a84

Please sign in to comment.