zyedidia / micro

A modern and intuitive terminal-based text editor
https://micro-editor.github.io
MIT License
25.01k stars 1.17k forks source link

Ctrl-c (copy) does not work #2516

Open Itookmyprozac opened 2 years ago

Itookmyprozac commented 2 years ago

The keybinding Ctrl-c works fine in my terminal but does not work on micro even if it's set on bindings.json. The copy function works ok if I press Ctrl-Shift-c. Ctrl-v (paste) also works ok.

Ctrl-c works out of the box on Linux Mint (i3wm) and MX-Linux (i3wm), both using Xfce4 terminal.

xclip is installed.

Commit hash: Micro 2.0.10 (comit hash b9763856). OS: Arco Linux with 3wm. Terminal: Xfce4-terminal

Content of my bindings.json file:

{
    "Alt-/": "lua:comment.comment",
    "Alt-a": "lua:snippets.Accept",
    "Alt-d": "lua:snippets.Cancel",
    "Alt-s": "lua:snippets.Insert",
    "Alt-w": "lua:snippets.Next",
    "CtrlUnderscore": "lua:comment.comment",
    "Ctrl-c": "Copy",
    "Ctrl-v": "Paste",
    "Ctrl-x": "Cut",
    "Ctrl-y": "Redo",
    "Ctrl-z": "Undo"
}

My settings file:

{
    "colorscheme": "nord-16"
}

Plugins installed: detectindent, micro-snippets-plugin, nordcolors. If I delete all of them there's no change on this problem.

Thanks for your help.

tomodachi94 commented 2 years ago

@Itookmyprozac can you try opening Micro, pressing Ctrl+e, and typing set clipboard external?

Itookmyprozac commented 2 years ago

Done but no changes unfortunately. Only Ctrl+Shift+c works. It's not a big deal but I always lose a couple of seconds using Ctrl+c and then Ctrl+Shift+c because I'm used to use micro on every device with the first one. Edit: I've discovered that Ctrl+c works ok using Alacritty so this problem only shows up when using Xfce4-terminal even the key binding (gtk_accel_path "<Actions>/terminal-window/copy" "<Primary>c") is set as usual in the accels.scm file.

tobip commented 1 year ago

I'm on Manjaro / sway / wayland / alacritty, and pressing Ctrl+e and typing set clipboard terminal solved the problem for me.

hikkidev commented 1 year ago

I found next: if your terminal emulator consumes the clipboard-copy action by Ctrl+Shift+C then micro will have Copy : Ctrl+C. Otherwise, if your terminal emulator consumes theclipboard-copy by Ctrl+C then micro will have Copy : Ctrl+Shift+C.

Env: Sway + foot.

Itookmyprozac commented 1 year ago

I found next: if your terminal emulator consumes the clipboard-copy action by Ctrl+Shift+C then micro will have Copy : Ctrl+C. Otherwise, if your terminal emulator consumes theclipboard-copy by Ctrl+C then micro will have Copy : Ctrl+Shift+C.

Env: Sway + foot.

You're right. Now it works.

I had to disable the keybinding Ctrl+c on Xfce-terminal (and also the autocopy selection) in order to allow micro to use that keybinding.

It's odd since I use this terminal and editor in other distros with the same WM. Well, in Arco Linux I'll have to use this workaround.

Thanks.

wizdoux commented 1 year ago

so, problem solved? can this issue be closed then?

Itookmyprozac commented 1 year ago

No. I though it was working, but it's not.

The content of my bindings.json:

   {
       "Alt-/": "lua:comment.comment",
       "Alt-a": "lua:snippets.Accept",
       "Alt-d": "lua:snippets.Cancel",
       "Alt-s": "lua:snippets.Insert",
       "Alt-w": "lua:snippets.Next",
       "CtrlUnderscore": "lua:comment.comment",
       "Ctrl-c": "Copy",
       "Ctrl-v": "Paste",
       "Ctrl-x": "Cut",
       "Ctrl-y": "Redo",
       "Ctrl-z": "Undo"
  }

Ctrl+X does not work either.

It's a weird problem since I can paste text that it's copied from terminal into micro but I can't do the same if I try to copy & paste in micro. It happens the same also using Alacritty.

The copy action shows the message "Copied selection" but if I try to paste micro shows the message "no clipboard received from terminal".

makesnosense commented 2 months ago

micro version: 2.0.13 kitty 0.35.2 i3 (X11)

I have the same issue. My goal is to be able to use Ctrl+c for copying everywhere.

Ctrl+C does not work inside micro, only Ctrl+Shift+C. Ctrl+X (Cut), Ctrl+V (Paste) do work without problems.

As mentioned above by hikkidev, when I unset "map ctrl+c copy_to_clipboard" in kitty, Ctrl+C starts working in micro. Any way to make it work both in kitty and micro?

Setting "set clipboard external" or "set clipboard terminal" did nothing for me.

micro keybindings:

{
    "Alt-/": "lua:comment.comment",
    "CtrlUnderscore": "lua:comment.comment",
    "Ctrl-c": "Copy",
    "Ctrl-V": "Paste",
    "Ctrl-x": "Cut"
}

I also have kitty.conf mapping:

map ctrl+c copy_to_clipboard
map ctrl+v paste_from_clipboard
map ctrl+shift+c send_text all \x03
map ctrl+shift+v send_text all \x16
niten94 commented 2 months ago

As mentioned above by hikkidev, when I unset "map ctrl+c copy_to_clipboard" in kitty, Ctrl+C starts working in micro. Any way to make it work both in kitty and micro?

Sorry, can you specify what you mean by "make it work both in kitty and micro"?

Setting "set clipboard external" or "set clipboard terminal" did nothing for me.

Settings in kitty has to be changed when accessing clipboard through terminal in micro. Terminal emulator settings will have to be changed if using terminal clipboard, so it may be more easier using external clipboard. External programs are used when installed and using external clipboard, but is xclip installed?

I also have kitty.conf mapping:

map ctrl+c copy_to_clipboard
map ctrl+v paste_from_clipboard
map ctrl+shift+c send_text all \x03
map ctrl+shift+v send_text all \x16

Ctrl+C does not have to be binded in terminal emulator settings when trying to use the clipboard function in micro. Copying text on terminal screen is different with the clipboard function in micro.

makesnosense commented 2 months ago

Sorry, can you specify what you mean by "make it work both in kitty and micro"?

So Ctrl+C shortcut works to copy selected text to clipboard both in micro and in kitty.

Ctrl+C does not have to be binded in terminal emulator settings when trying to use the clipboard function in micro.

That is what I would also assume, but as I mentioned above, somehow setting "map ctrl+c copy_to_clipboard" in kitty.conf interferes with the ability to use this keyboard shortcut in micro.