kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
24.11k stars 972 forks source link

paste chinese words as raw utf-8 code #5527

Closed cathaysia closed 2 years ago

cathaysia commented 2 years ago

Describe the bug

kitty paste chinese as utf-8 code

To Reproduce Steps to reproduce the behavior:

  1. copy some chinese words
  2. press ctrl + shift + v in kitty
  3. See error

https://user-images.githubusercontent.com/42114817/191962738-3e4101e8-cd2e-4292-94f1-28c595f302e8.mp4

Environment details

kitty 0.26.3 created by Kovid Goyal
Linux dragon 5.19.10-arch1-1 #1 SMP PREEMPT_DYNAMIC Tue, 20 Sep 2022 15:17:59 +0000 x86_64
Arch Linux 5.19.10-arch1-1 (/dev/tty)

DISTRIB_ID="Arch"
DISTRIB_RELEASE="rolling"
DISTRIB_DESCRIPTION="Arch Linux"
Running under: X11
Frozen: False
Paths:
  kitty: /usr/bin/kitty
  base dir: /usr/lib/kitty
  extensions dir: /usr/lib/kitty/kitty
  system shell: /usr/bin/zsh
Loaded config files:
  /home/tea/.config/kitty/kitty.conf

Config options different from defaults:
allow_remote_control yes
close_on_child_death True
disable_ligatures    1
editor               nvim
enable_audio_bell    False
enabled_layouts      ['splits']
font_family          FiraCode Nerd Font Mono
font_size            16.0
scrollback_lines     20000
tab_bar_edge         1
tab_bar_style        powerline
url_prefixes         ('http', 'https', 'file', 'ftp', 'gemini', 'irc', 'gopher', 'mailto', 'news', 'git')
Added shortcuts:
    kitty_mod+d →  scroll_line_down
    kitty_mod+tab →  next_tab
Removed shortcuts:
    ctrl+shift+tab →  previous_tab
    ctrl+tab →  next_tab
    kitty_mod++ →  change_font_size all +2.0
    kitty_mod+, →  move_tab_backward
    kitty_mod+- →  change_font_size all -2.0
    kitty_mod+. →  move_tab_forward
    kitty_mod+0 →  tenth_window
    kitty_mod+= →  change_font_size all +2.0
    kitty_mod+[ →  previous_window
    kitty_mod+] →  next_window
    kitty_mod+` →  move_window_to_top
    kitty_mod+a > 1 →  set_background_opacity 1
    kitty_mod+a > d →  set_background_opacity default
    kitty_mod+a > l →  set_background_opacity -0.1
    kitty_mod+a > m →  set_background_opacity +0.1
    kitty_mod+alt+t →  set_tab_title
    kitty_mod+backspace →  change_font_size all 0
    kitty_mod+delete →  clear_terminal reset active
    kitty_mod+e →  open_url_with_hints
    kitty_mod+end →  scroll_end
    kitty_mod+escape →  kitty_shell window
    kitty_mod+f1 →  show_kitty_doc overview
    kitty_mod+f11 →  toggle_fullscreen
    kitty_mod+f2 →  edit_config_file
    kitty_mod+f5 →  load_config_file
    kitty_mod+f7 →  focus_visible_window
    kitty_mod+f8 →  swap_with_window
    kitty_mod+g →  show_last_command_output
    kitty_mod+h →  show_scrollback
    kitty_mod+home →  scroll_home
    kitty_mod+j →  scroll_line_down
    kitty_mod+k →  scroll_line_up
    kitty_mod+kp_add →  change_font_size all +2.0
    kitty_mod+kp_subtract →  change_font_size all -2.0
    kitty_mod+l →  next_layout
    kitty_mod+o →  pass_selection_to_program
    kitty_mod+p > f →  kitten hints --type path --program -
    kitty_mod+p > h →  kitten hints --type hash --program -
    kitty_mod+p > l →  kitten hints --type line --program -
    kitty_mod+p > n →  kitten hints --type linenum
    kitty_mod+p > shift+f →  kitten hints --type path
    kitty_mod+p > w →  kitten hints --type word --program -
    kitty_mod+p > y →  kitten hints --type hyperlink
    kitty_mod+page_down →  scroll_page_down
    kitty_mod+page_up →  scroll_page_up
    kitty_mod+q →  close_tab
    kitty_mod+r →  start_resizing_window
    kitty_mod+s →  paste_from_selection
    kitty_mod+x →  scroll_to_prompt 1
    kitty_mod+z →  scroll_to_prompt -1
    shift+insert →  paste_from_selection
Changed shortcuts:
    kitty_mod+1 →  goto_tab 1
    kitty_mod+2 →  goto_tab 2
    kitty_mod+3 →  goto_tab 3
    kitty_mod+4 →  goto_tab 4
    kitty_mod+5 →  goto_tab 5
    kitty_mod+6 →  goto_tab 6
    kitty_mod+7 →  goto_tab 7
    kitty_mod+8 →  goto_tab 8
    kitty_mod+9 →  goto_tab 9
    kitty_mod+b →  scroll_page_up
    kitty_mod+down →  move_window down
    kitty_mod+enter →  launch --cwd=current --location=vsplit
    kitty_mod+f →  scroll_page_down
    kitty_mod+f10 →  clear_terminal scrollback active
    kitty_mod+left →  move_window left
    kitty_mod+n →  launch --cwd=current --location=hsplit
    kitty_mod+right →  move_window right
    kitty_mod+u →  open_url_with_hints
    kitty_mod+up →  move_window up
    kitty_mod+w →  next_window
Colors:
    background           #282c34   
    color0               #282c34   
    color1               #e06c75   
    color10              #56b6c2   
    color11              #e5c07b   
    color12              #61afef   
    color13              #be5046   
    color14              #56b6c2   
    color15              #abb2bf   
    color2               #98c379   
    color3               #e5c07b   
    color4               #61afef   
    color5               #be5046   
    color6               #56b6c2   
    color7               #979eab   
    color8               #393e48   
    color9               #d19a66   
    foreground           #979eab   
    selection_background #979eab   
    selection_foreground #282c34   

Important environment variables seen by the kitty process:
    PATH                                /usr/lib/ccache/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/cuda/bin:/opt/cuda/nsight_compute:/opt/cuda/nsight_systems/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
    LANG                                zh_CN.UTF-8
    SHELL                               /usr/bin/zsh
    GLFW_IM_MODULE                      ibus
    DISPLAY                             :0
    USER                                tea
    XCURSOR_SIZE                        24
    XDG_RUNTIME_DIR                     /run/user/1000
    LC_MEASUREMENT                      zh_CN.UTF-8
    LC_MONETARY                         zh_CN.UTF-8
    LC_NUMERIC                          zh_CN.UTF-8
    LC_TIME                             zh_CN.UTF-8
    XDG_CONFIG_DIRS                     /home/tea/.config/kdedefaults:/etc/xdg
    XDG_CURRENT_DESKTOP                 KDE
    XDG_SEAT                            seat0
    XDG_SEAT_PATH                       /org/freedesktop/DisplayManager/Seat0
    XDG_SESSION_CLASS                   user
    XDG_SESSION_DESKTOP                 KDE
    XDG_SESSION_ID                      2
    XDG_SESSION_PATH                    /org/freedesktop/DisplayManager/Session1
    XDG_SESSION_TYPE                    x11
    XDG_VTNR                            1
kovidgoyal commented 2 years ago

That is an error from your shell not kitty. Run cat first then paste and you will see kitty is pasting correctly.

cutalion commented 2 years ago

I have the same issue with russian characters. Screenshot-2022-10-03T11-53-22

I copied a word from gedit into default gnome term and into the kitty term with Ctrl+Shift+V.

But when I write something in kitty term in russian and copy-paste this back it looks good, not escaped. And when I run vim inside kitty and paste in insert mode with Ctrl+Shift+V, then pasted text is escaped. But if I paste from register in normal mode ("+p), then everything is good.

Do not know where to dig.

emi2k01 commented 2 years ago

This is not from the shell. The issue most likely comes from Firefox or Gnome/GTK.

If you copy from Firefox, it stores the actual unicode character under the clipboard targets UTF8_STRING and text/plain;charset=utf-8. The other targets (TEXT, STRING, etc) get its unicode escape, which is where kitty is reading the clipboard content from.

Battle420 commented 2 years ago

@emi2k01 Indeed, when I copy from Firefox to Kitty, it only gives the utf-8 codes, but when I copy from Kitty and paste into Kitty, I have the correct characters. The weird thing is that it used to work before, so I wonder what changed that made pasting from Firefox to Kitty not possible...

kovidgoyal commented 2 years ago

See #5528