moar
moar copied to clipboard
Mouse copying
This text is now maintained here: https://github.com/walles/moar/blob/master/MOUSE.md
--
At least on my Mac, if I want to copy something using the mouse i need to hold alt while marking for the mark to work.
The reason is that moar
requests mouse events from the terminal, and that makes the terminal not accept mark / copy any more.
less --mouse
has the same problems, see comments.
Workarounds
- Alacritty: Use use shift + mouse selection to make it work. Cred to @chrisgrieser for this tip.
- Contour: Use shift + mouse selection to mark text. Cred to @postsolar 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
- kitty on macOS: Holding shift or fn while marking. Cred to @PrayagS for this tip.
- Konsole Use use shift + mouse selection. Cred to @cig0 for this tip.
- Terminator: Use use shift + mouse selection to make it work. Cred to @felix-seifert for this tip.
- Tilix: Use use shift + mouse selection. Cred to @Macr0Nerd for this tip.
- Warp: Preferences / Settings / Features / Terminal / uncheck "Enable Mouse Reporting"
- Windows: Use Shift to make a selection. If you click the wrong initial spot, you can clear the selection with Esc. Just be careful, if you hit Esc without a selection, the pager will exit. Cred to @89z for this one.
less
' screen initialization sequence
Recorded using iTerm's Automatically log session input to files feature.
less
is version 487 that comes with macOS 11.3 Big Sur.
All linebreaks are mine, added for readability. The ^M
s are not.
less /etc/passwd
^G<ESC>[30m<ESC>(B<ESC>[m^M
<ESC>[?1049h
<ESC>[?1h
<ESC>=^M
##
moar
's screen initialization sequence
moar /etc/passwd /Users/johan/src/moar
^G<ESC>[30m<ESC>(B<ESC>[m^M
<ESC>[?1049h
<ESC>[?1006;1000h
<ESC>[?25l
<ESC>[1;1H
<ESC>[m<ESC>[2m 1 <ESC>[22m##
Analysis of less
The line starting with ^G
is probably from from fish
since it's the same for both less
and moar
.
<ESC>[?1049h
switches to the Alternate Screen Buffer, search here for 1 0 4 9
for info.
Then less
does [?1h
, which apparently is DECCKM Cursor Keys Mode, send ESC O A for cursor up, followed by =
, meaning DECKPAM - Set keypad to applications mode (ESCape instead of digits).
NOTE that this means that less
version 487 that comes with macOS 11.3 Big Sur doesn't even try to enable any mouse reporting, but relies on the terminal to convert scroll wheel events into arrow keypresses.
Analysis of moar
Same as less
up until the Alternate Screen Buffer is enabled.
<ESC>[?1006;1000h
enables SGR Mouse Mode and the X11 xterm mouse protocol (search for 1 0 0 0
).
<ESC>[?25l
hides the cursor. NOTE Maybe we don't need this? It might be implicit when we enable the Alternate Screen Buffer.
<ESC>[1;1H
moves the cursor to the top left corner.
Then it's the first line with its line number in faint type.
Apparently less
got its mouse support in February 2019: https://www.greenwoodsoftware.com/less/news.548.html
I should try that and see what it does to marking text.
less --mouse
has the same mark-text-with-the-mouse problems as moar
does.
Yay for being able to run the latest Ubuntu in Docker!
These are the options I can come up with around the mouse experience:
- Do nothing. Mouse scroll works well, copying can be done by holding alt (not great) and no work is involved.
- Do what
less
does. Mouse scroll might work depending on terminal settings, but at least we won't be worse thanless
, copying works great, not much work. - Implement our own marking / copying based on the click / move mouse events we get. Good experience if it can be made to work, lots of work.
Mouse scroll | Mouse mark | Cost | |
---|---|---|---|
Do nothing | π’ | π€·πΎ | π’ |
Do what less does |
π€·πΎ | π’ | π’ |
Make our own marking | π’ | π’ | β οΈ |
Another workaround: in iTerm2, if you disable "Report mouse clicks & drags" in the preferences, under Profiles / Terminal, copying will work well.
I figured it out for Windows.
You can use Shift to make a selection. If you click the wrong initial spot, you can clear the selection with Esc. Just be careful, if you hit Esc without a selection, the pager will exit.
Just an FYI, none of these workarounds do anything in MacOS's Terminal.app
Just added this text, does this help @thepeoplesbourgeois?
- macOS Terminal on a laptop: Hold down the fn key while marking with the mouse
I am using Hyper on mac, and neither holding alt nor holding fn works here :(
Try setting macOptionSelectionMode: 'force'
in your config file and hold Option while marking, does that work?
// choose either `'vertical'`, if you want the column mode when Option key is hold during selection (Default)
// or `'force'`, if you want to force selection regardless of whether the terminal is in mouse events mode
// (inside tmux or vim with mouse mode enabled for example).
macOptionSelectionMode: 'vertical',
ah yes, that works, thanks a lot! βΊοΈ
just to add to the list of workarounds: in Alacritty, you have to use use shift
+ mouse selection to make it work.
With Wezterm, on macOS, I could not find a workaround to select text, or open URLs with the mouse. I have tried the ones listed above.
I think the relevant configuration for this issue is this: https://wezfurlong.org/wezterm/config/lua/config/bypass_mouse_reporting_modifiers.html#bypass_mouse_reporting_modifiers--shift .
@brunoroque06 the reason it didn't work for you was likely https://github.com/wez/wezterm/issues/2389.
Can you find a wezterm build that isn't affected by that issue and try again?
@walles ah nice, it works on the nightly build. Thanks.
One has to press bypass_mouse_reporting_modifiers
(shift
by default), and then it is possible to select text, and open URLs. Thank you.
I also experience the issue that I cannot mark anything with my mouse on Ubuntu. I use the terminal emulator Terminator. As a workaround, I can hold the shift button to actually mark text.
For anyone else wondering, on kitty, shift
or fn
seem to do the trick on macOS.
shift
works for Tilix
Same thing for Konsole :heart:
shift
works for Tilix
yes but why do we need shift and not just click??
shift
works for Tilixyes but why do we need shift and not just click??
Maybe you should ask the Tilix authors? They could probably shed further light on this.
Basically moar
tells the terminal it wants mouse scroll events, and in most terminals (like Tilix), this has the side effect of disabling mouse copying.
Don't know why a lot of terminals disable mouse copying when reporting scroll events. In iTerm this is configurable so that you can copy without holding down any special button.
Comparing to less
, less defaults to broken mouse scrolling but working copying. moar
defaults to working mouse scrolling but broken copying.
In foot
, it's this configuration setting which enables selection in applications that grab the mouse:
[mouse-bindings]
selection-override-modifiers=Mod1
By default it's Shift, in my example it's set to Alt
In Contour it's Shift by default. Using moar
with --mousemode mark
disables scrolling (no scrolling emulation as of now).