Micro: Right click copy doesn't work

Created on 30 May 2017  路  11Comments  路  Source: zyedidia/micro

Description of the problem or steps to reproduce

Specifications

Version: 1.2.0
Commit hash: be81241
Compiled on May 27, 2017
Terminal: Mate Terminal 1.18.0

Right click copy doesn't work, when selecting something and wanting to copy the right mouse button doesn't work and is grayed out.

Most helpful comment

Yes, to expand on what @DanielPower said:

since micro runs inside the terminal, each program (the terminal emulator and micro) has its own handling of copy and paste. When you press Ctrl-V, the terminal sends this key event to micro and micro then interfaces with the system clipboard (if you have xclip or xsel installed -- or a local clipboard otherwise) and pastes. If you press Ctrl-Shift-V (or whatever the keybinding is to paste using through the terminal emulator) then the terminal emulator accesses the system clipboard and sends the string of characters to micro as a "paste event." The same works for copy and paste but since a selection is required to copy, mouse support must be disabled in micro (atm this is not possible) to use the terminal emulator's copy so that a selection can be made using the terminal emulator's method of selection instead of selecting through micro (in that case, line numbers might become selected because the terminal emulator only knows about the characters being displayed).

Generally it doesn't matter if you use the terminal's copy/paste or micro's copy/paste.

However, when using micro over ssh, it is important. Since micro runs on the remote server, when copying and pasting it accesses the server's clipboard (in fact, I believe most servers do not even have system clipboards), so it is not possible to copy from your local computer and paste using Ctrl-V (micro's paste). However, if you use the terminal emulator's paste (Ctrl-Shift-V), since it is running on your local computer, it will access your system clipboard and send the paste event across ssh to micro on the server and everything will work.

I think the reason you see nano working over ssh is because nano's mouse support is disabled (even if mouse support is possible I think it is disabled by default), so mouse events like middle click aren't being captured by the editor. I think adding an option to disable mouse support in micro would fix these issues, provided people understand what is going on and when to have mouse support enabled or disabled.

All 11 comments

Is right mouse button to copy something enabled by your terminal? Micro has no bindings for the right mouse button. I'm also not sure how the right mouse button can be "grayed out."

@zyedidia I don't believe he's trying to just right click to copy, but is rather referring to the right click menu. Most terminals include a right click menu which include a copy function.

On Xfce4-terminal, the right click menu does not open when running Micro. I guess it detects that Micro is capturing mouse clicks, and decides to drop its own right click menu functionality.

I've just installed Mate-terminal to test @themotu 's issue, and have found that the right click menu does open, with the copy option greyed out.

My recommendation @themotu would be to use use Ctrl + C to copy, and Ctrl + V to paste. I don't know much about how terminals work, so I don't really know how big of a change it would take to make the right click -> copy work, but my uneducated guess would be that it's not feasible. Perhaps @zyedidia will correct me on this.

EDIT: For reference, right click -> copy works on anything that prints to standard output without taking over the screen. It also works on nano. Not sure if it works on vim, since I've never used vim with mouse support.

Unfortunately I don't think this is possible to fix. I'm guessing it only works on Nano because Nano doesn't use mouse support (please correct me if I'm wrong).

The core of this issue has to do with the question of who gets mouse events. If micro gets the mouse events, then the terminal can't copy/open a menu on right click. If the terminal gets the mouse events then micro can't respond to the mouse.

This basically means I can't copy and paste across terminals

Yeah, it keeps me from using micro on my servers.

Maybe I'll look into implementing a way of disabling and enabling mouse support so that you could temporarily disable mouse support to paste using right click and then re-enable it.

@zyedidia As far as I know, nano has some basic mouse support...

Yes but I don't believe that you can open the terminal menu with right click while nano's mouse support is enabled. Please correct me if I'm wrong.

If you just want to copy or paste with right click (not open the menu) then you can bind that:

In ~/.config/micro/bindings.json:

{
    "MouseRight": "Paste"
}

or

{
    "MouseRight": "Copy"
}

Note that this won't work over ssh because servers don't have a clipboard that micro can interface with (although the copying and pasting will still work withing micro).

I use ctrl+shift+C/V and middle click all the time in nano over ssh. Just want the same functionality in micro. Copy and paste is too unreliable as is.

@themotu do you have xclip installed? If you have xclip installed, Micro's Ctrl+C and Ctrl+X should copy to your system's clipboard, so you can paste in another terminal with Ctrl+Shift+V. And the other way around as well, you'll be able to copy in other programs and paste into micro as expected.

Without xclip installed, micro just uses its own local clipboard, and cannot copy from or paste to other applications.

Yes, to expand on what @DanielPower said:

since micro runs inside the terminal, each program (the terminal emulator and micro) has its own handling of copy and paste. When you press Ctrl-V, the terminal sends this key event to micro and micro then interfaces with the system clipboard (if you have xclip or xsel installed -- or a local clipboard otherwise) and pastes. If you press Ctrl-Shift-V (or whatever the keybinding is to paste using through the terminal emulator) then the terminal emulator accesses the system clipboard and sends the string of characters to micro as a "paste event." The same works for copy and paste but since a selection is required to copy, mouse support must be disabled in micro (atm this is not possible) to use the terminal emulator's copy so that a selection can be made using the terminal emulator's method of selection instead of selecting through micro (in that case, line numbers might become selected because the terminal emulator only knows about the characters being displayed).

Generally it doesn't matter if you use the terminal's copy/paste or micro's copy/paste.

However, when using micro over ssh, it is important. Since micro runs on the remote server, when copying and pasting it accesses the server's clipboard (in fact, I believe most servers do not even have system clipboards), so it is not possible to copy from your local computer and paste using Ctrl-V (micro's paste). However, if you use the terminal emulator's paste (Ctrl-Shift-V), since it is running on your local computer, it will access your system clipboard and send the paste event across ssh to micro on the server and everything will work.

I think the reason you see nano working over ssh is because nano's mouse support is disabled (even if mouse support is possible I think it is disabled by default), so mouse events like middle click aren't being captured by the editor. I think adding an option to disable mouse support in micro would fix these issues, provided people understand what is going on and when to have mouse support enabled or disabled.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rishabh96b picture rishabh96b  路  3Comments

KhodeN picture KhodeN  路  3Comments

AndreyTheHacker picture AndreyTheHacker  路  3Comments

Rbagman picture Rbagman  路  4Comments

ns-cweber picture ns-cweber  路  4Comments