This is a bit of an odd one.
Is it possible to disable mouse support when click-dragging or using the 'copy' hotkey? I would like my terminal/system clipboard to handle all clipboard stuff, but still retain the ability to use my mouse to select lines in Micro. This doesn't seem to affect pasting, oddly.
Currently, these are the scenarios that happen:
mouse: false, I can copy from Micro or my system, and paste into Micro as expected. However, this obviously disables Mouse support.mouse: true and default keybinds, if I attempt to copy I get Copied selection (install xclip for external clipboard) in the status bar.mouse: true, and "Ctrl-C": "", "Ctrl-V": "" in keybinds, then pasting from the system clipboard works, but copying from Micro does nothing.It seems that when Micro has mouse support enabled, Windows Terminal passes through all mouse highlighting to Micro, so you can no longer highlight something to copy it using terminal hotkeys, as as far as the terminal is concerned, nothing is selected. I can confirm this in raw mode, as when mouse support is enabled, ctrl+c is passed through as \x03, whereas ctrl+v is the block of text in my system clipboard.
Does anybody have any suggestions on how to fix this? :) This may be considered a Windows Terminal issue, if so, please let me know and I'll go open an issue over there.
Commit hash: 60846f5, Version 2.0.6
OS: Ubuntu 20.04.1 LTS running in WSL2 on Windows 10
Terminal: Microsoft Terminal (I have no idea which version, not entirely sure how to find out)
One suggestion I can make and one option I have been looking for is a way bind a single key to manually toggle the mouse on and off. Eg. "Ctrl-m": "toggleMouse". Is there a way to do that?
Yous can only write a lua script and bind a lua function to a key. See the short discussion here too: #1806.
I should have mentioned that was the first thing I tried. However, aside from having no effect for the mouse, the following output a carriage return.
Edited to fix typo and change binding from Ctrl-m to Ctrl-o.
~/.config/micro/bindings.json:
"Ctrl-o": "lua:initlua.toggleMouse",
~/.config/micro/init.lua:
function toggleMouse(bp)
bp.Buf.Settings["mouse"] = not bp.Buf.Settings["mouse"]
end
I believe you have to bind "lua:toggleMouse" (possibly "lua:toggleMouse()"). Aside from that, yes, unfortunately (at least on >90% of terminals, and as per standard) Ctrl-m is transmitted as '\r'. What you can try (if it doesn't mess up your ability to enter normal newlines in the editor) is binding "\r": "lua:whatever", which will bind to the specific sequence (this time just one byte).
The \r part might not be necessary, but I'm not sure atm.
Sorry, I made a typo in my earlier post. The ticket you referenced in regards to the softwrap toggle was actually submitted by me so I tried the same technique to toggle the mouse but to no avail. It seems the mouse option is handled differently.
haha! ok i didn't notice that, anyway, idk how the mouse option works, sorry :)
The mouse is a global option so you cannot simply edit the local value in the buffer's settings to change it. Try
local config = import("micro/config")
function toggleMouse(bp)
config.SetGlobalOptionNative("mouse", not bp.Buf.Settings["mouse"])
end
And to bind it use
"Alt-m": "lua:initlua.toggleMouse",
Unfortunately, as MasFlam points out, Ctrl-m always sends \r which is the same as what Enter sends, making Ctrl-m unbindable (unless you also want to rebind Enter). I recommend using a different key such as Alt-m.