kovidgoyal / kitty

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

Setting cursor's color, changes cursor's text color #5993

Closed knatsakis closed 1 year ago

knatsakis commented 1 year ago

Describe the bug Setting cursor's color via escape sequence resets cursor's text color

To Reproduce Steps to reproduce the behavior:

  1. Set cursor to #ffffff and cursor_text_color to #000000
  2. Change cursor's color to green with printf '\033]12;#00ff00\033\\'
  3. cursor's text color is no longer black

Environment details

kitty 0.24.1 (04807453ec) created by Kovid Goyal
Linux saturn 6.0.0-4-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.0.8-1 (2022-11-11) x86_64
Debian GNU/Linux bookworm/sid saturn /dev/tty

Running under:X11
Frozen: False
Paths:
  kitty: /usr/bin/kitty
  base dir: /usr/lib/kitty
  extensions dir: /usr/lib/kitty/kitty
  system shell: /bin/zsh
Loaded config files:
  /etc/xdg/kitty/kitty.conf

Config options different from defaults:
active_tab_font_style      (True, False)
background_opacity         0.8
bold_font                  Iosevka Term Bold
bold_italic_font           Iosevka Term Bold Oblique
box_drawing_scale          (0.01, 0.5, 1.0, 1.5)
clipboard_control          ('write-clipboard', 'write-primary', 'no-append')
cursor_stop_blinking_after 0
disable_ligatures          1
enable_audio_bell          False
font_family                Iosevka Term
font_size                  9.0
inactive_text_alpha        0.75
initial_window_height      (1080, 'px')
initial_window_width       (1920, 'px')
italic_font                Iosevka Term Oblique
kitty_mod                  16
mouse_hide_wait            0.0
remember_window_size       False
resize_in_steps            True
scrollback_lines           65535
shell_integration          frozenset({'no-cursor'})
tab_bar_style              powerline
tab_powerline_style        slanted
tab_separator               
tab_title_template         {sup.index}{title}
update_check_interval      0.0
url_style                  1
window_border_width        (1.0, 'px')
window_resize_step_cells   1
window_resize_step_lines   1
Added mouse actions:
     alt+b1 press ungrabbed mouse_selection rectangle
     alt+b1 triplepress ungrabbed mouse_selection line_from_point
     shift+alt+b1 press ungrabbed mouse_selection rectangle
     shift+alt+b1 press grabbed mouse_selection rectangle
     shift+alt+b1 triplepress ungrabbed mouse_selection line_from_point
     shift+alt+b1 triplepress grabbed mouse_selection line_from_point
Removed mouse actions:
     shift+ctrl+b1 repeat ungrabbed mouse_handle_click link
     shift+ctrl+b1 repeat grabbed mouse_handle_click link
     shift+ctrl+b1 press grabbed discard_event
     alt+ctrl+b1 press ungrabbed mouse_selection rectangle
     alt+ctrl+b1 triplepress ungrabbed mouse_selection line_from_point
     shift+alt+ctrl+b1 press ungrabbed mouse_selection rectangle
     shift+alt+ctrl+b1 press grabbed mouse_selection rectangle
     shift+alt+ctrl+b1 triplepress ungrabbed mouse_selection line_from_point
     shift+alt+ctrl+b1 triplepress grabbed mouse_selection line_from_point
     shift+ctrl+b2 press ungrabbed mouse_show_command_output
     shift+b3 press grabbed discard_event
Changed mouse actions:
     b1 -2 ungrabbed mouse_click_url_or_select
     shift+b1 -2 ungrabbed mouse_click_url_or_select
     shift+b1 -2 grabbed mouse_click_url_or_select
     shift+b3 repeat ungrabbed paste_from_selection
     shift+b3 repeat grabbed paste_from_selection
Added shortcuts:
    hyper++ change_font_size current +1.0
    hyper+, load_config_file
    hyper+- change_font_size current -1.0
    hyper+. debug_config
    hyper+0 tenth_window
    hyper+1 first_window
    hyper+2 second_window
    hyper+3 third_window
    hyper+4 fourth_window
    hyper+5 fifth_window
    hyper+6 sixth_window
    hyper+7 seventh_window
    hyper+8 eighth_window
    hyper+9 ninth_window
    hyper+= change_font_size current 0
    hyper+[ previous_window
    hyper+] next_window
    hyper+` move_window_to_top
    hyper+a > 1 set_background_opacity 1
    hyper+a > d set_background_opacity default
    hyper+a > l set_background_opacity -0.1
    hyper+a > m set_background_opacity +0.1
    hyper+b move_window_backward
    hyper+c copy_to_clipboard
    hyper+e kitten hints --type url
    hyper+f move_window_forward
    hyper+h show_scrollback
    hyper+l next_layout
    hyper+n new_os_window
    hyper+o pass_selection_to_program
    hyper+p > f kitten hints --type path --program -
    hyper+p > h kitten hints --type hash --program -
    hyper+p > l kitten hints --type line --program -
    hyper+p > n kitten hints --type linenum
    hyper+p > w kitten hints --type word --program -
    hyper+p > y kitten hints --type hyperlink
    hyper+p > shift+f kitten hints --type path
    hyper+p > ctrl+f kitten hints --type path --program - --multiple
    hyper+p > ctrl+h kitten hints --type hash --program - --multiple
    hyper+p > ctrl+l kitten hints --type line --program - --multiple
    hyper+p > ctrl+n kitten hints --type linenum --multiple
    hyper+p > ctrl+w kitten hints --type word --program - --multiple
    hyper+p > ctrl+y kitten hints --type hyperlink --multiple
    hyper+p > shift+ctrl+f kitten hints --type path --multiple
    hyper+q close_tab
    hyper+r start_resizing_window
    hyper+s paste_from_selection
    hyper+t new_tab
    hyper+u kitten unicode_input
    hyper+v paste_from_clipboard
    hyper+w close_window
    hyper+escape kitty_shell window
    hyper+enter new_window
    hyper+delete clear_terminal reset active
    hyper+left previous_tab
    hyper+right next_tab
    hyper+up scroll_line_up
    hyper+down scroll_line_down
    hyper+page_up scroll_page_up
    hyper+page_down scroll_page_down
    hyper+home scroll_home
    hyper+end scroll_end
    hyper+f2 edit_config_file
    hyper+f6 debug_config
    hyper+f10 toggle_maximized
    hyper+f11 toggle_fullscreen
    alt+hyper++ change_font_size all +1.0
    alt+hyper+- change_font_size all -1.0
    alt+hyper+= change_font_size all 0
    alt+hyper+t set_tab_title
    ctrl+hyper+e kitten hints --type url --multiple
Removed shortcuts:
    shift+insert paste_from_selection
    ctrl+tab next_tab
    shift+ctrl++ change_font_size all +2.0
    shift+ctrl+, move_tab_backward
    shift+ctrl+- change_font_size all -2.0
    shift+ctrl+. move_tab_forward
    shift+ctrl+0 tenth_window
    shift+ctrl+1 first_window
    shift+ctrl+2 second_window
    shift+ctrl+3 third_window
    shift+ctrl+4 fourth_window
    shift+ctrl+5 fifth_window
    shift+ctrl+6 sixth_window
    shift+ctrl+7 seventh_window
    shift+ctrl+8 eighth_window
    shift+ctrl+9 ninth_window
    shift+ctrl+= change_font_size all +2.0
    shift+ctrl+[ previous_window
    shift+ctrl+] next_window
    shift+ctrl+` move_window_to_top
    shift+ctrl+a > 1 set_background_opacity 1
    shift+ctrl+a > d set_background_opacity default
    shift+ctrl+a > l set_background_opacity -0.1
    shift+ctrl+a > m set_background_opacity +0.1
    shift+ctrl+b move_window_backward
    shift+ctrl+c copy_to_clipboard
    shift+ctrl+e open_url_with_hints
    shift+ctrl+f move_window_forward
    shift+ctrl+g show_last_command_output
    shift+ctrl+h show_scrollback
    shift+ctrl+j scroll_line_down
    shift+ctrl+k scroll_line_up
    shift+ctrl+l next_layout
    shift+ctrl+n new_os_window
    shift+ctrl+o pass_selection_to_program
    shift+ctrl+p > f kitten hints --type path --program -
    shift+ctrl+p > h kitten hints --type hash --program -
    shift+ctrl+p > l kitten hints --type line --program -
    shift+ctrl+p > n kitten hints --type linenum
    shift+ctrl+p > w kitten hints --type word --program -
    shift+ctrl+p > y kitten hints --type hyperlink
    shift+ctrl+p > shift+f kitten hints --type path
    shift+ctrl+q close_tab
    shift+ctrl+r start_resizing_window
    shift+ctrl+s paste_from_selection
    shift+ctrl+t new_tab
    shift+ctrl+u kitten unicode_input
    shift+ctrl+v paste_from_clipboard
    shift+ctrl+w close_window
    shift+ctrl+x scroll_to_prompt 1
    shift+ctrl+z scroll_to_prompt -1
    shift+ctrl+escape kitty_shell window
    shift+ctrl+enter new_window
    shift+ctrl+tab previous_tab
    shift+ctrl+backspace change_font_size all 0
    shift+ctrl+delete clear_terminal reset active
    shift+ctrl+left previous_tab
    shift+ctrl+right next_tab
    shift+ctrl+up scroll_line_up
    shift+ctrl+down scroll_line_down
    shift+ctrl+page_up scroll_page_up
    shift+ctrl+page_down scroll_page_down
    shift+ctrl+home scroll_home
    shift+ctrl+end scroll_end
    shift+ctrl+f2 edit_config_file
    shift+ctrl+f5 load_config_file
    shift+ctrl+f6 debug_config
    shift+ctrl+f7 focus_visible_window
    shift+ctrl+f8 swap_with_window
    shift+ctrl+f10 toggle_maximized
    shift+ctrl+f11 toggle_fullscreen
    shift+ctrl+kp_subtract change_font_size all -2.0
    shift+ctrl+kp_add change_font_size all +2.0
    shift+alt+ctrl+t set_tab_title
Colors:
    active_border_color        #ffffff   
    active_tab_background      #409fff   
    bell_border_color          #ff0000   
    color0                     #202020   
    color1                     #bf0000   
    color10                    #a6ff4d   
    color11                    #ffcf40   
    color12                    #409fff   
    color13                    #ff4dff   
    color14                    #4dffff   
    color2                     #59b300   
    color3                     #bf8f00   
    color4                     #0060bf   
    color5                     #b300b3   
    color6                     #00b3b3   
    color7                     #cccccc   
    color8                     #535353   
    color9                     #ff4040   
    cursor                     #ffffff   
    cursor_text_color          #000000   
    foreground                 #ffffff   
    inactive_border_color      #000000   
    inactive_tab_background    #000000   
    inactive_tab_foreground    #409fff   
    selection_background       #ffffff   
    url_color                  #409fff   

Additional context I think this stopped working since https://github.com/kovidgoyal/kitty/commit/0fdafd83986d46ea5eecdd6174617bd71eafe728

kovidgoyal commented 1 year ago

IIRC this is by design. If the application is setting cursor colors, then kitty assumes it picks a color that works well with the text, since it has no way to know the value of cursor_text_color so its reset to none which allows the underlying text colors to shine through. There isnt really a good solution for this, since there is no escape code to change cursor_text_color.

knatsakis commented 1 year ago

Does it make sense to keep the old behaviour with cursor_text_color = #xxxxxx and the new behaviour with something like cursor_text_color = auto ?

kovidgoyal commented 1 year ago

I suggest rather than using escape codes use kitty @ set-colors that way you can set both in a co-ordinated fashion.

knatsakis commented 1 year ago

I suggest rather than using escape codes use kitty @ set-colors that way you can set both in a co-ordinated fashion.

This sounds like a reasonable approach but

kitty @ set-colors 'cursor=#00ff00' 'cursor_text_color=#000000'

seems to change only the cursor's color and doesn't seem to affect the cursor's text color at all.

(I tried with latest released version as well)

kovidgoyal commented 1 year ago

that would be a bug open a separate issue for it and I'll look at it when I have a moment

kovidgoyal commented 1 year ago

Actually looking at the code, its currently implemented as tracking only if the cursor color is set to an actual color, regardless of mechanism, when it is, cursor_text_color is ignored. Changing this would require also tracking how the cursor color was set escape code vs remote control.

knatsakis commented 1 year ago

that would be a bug open a separate issue for it and I'll look at it when I have a moment

5994