Kitty: Use background color for character below cursor

Created on 15 Sep 2017  路  20Comments  路  Source: kovidgoyal/kitty

As per the title; it would be nice to be able to have kitty draw the character currently below the block cursor in the same color as the background color.

I did not find any way in the current setting to allow for this, and it would go really well with having full cursor opacity.

Do you think this would be hard to implement, and if not, would you consider adding this?

Thanks.

Most helpful comment

Ok, I get your point, it's true that it has downsides. However, I think that ultimately, if the user really wants to have inversion, it should have priority over terminal applications.
Besides, cursor color inversion is also the best way (that I know of) to make the cursor clearly visible at all times. For example, I use a dark colorscheme in the terminal, but a light colorscheme in neovim. Any cursor bg color choice will fail to make it visible at some point. The proof that it's so useful is that it is implemented in most other terminals (which unfortunately lack the features of Kitty, thus why I'm being insistent on having it in Kitty :)
I understand that you're not a fan of using it yourself and thus have no interest in implementing it, but if you can tolerate it being implemented in Kitty I can do it myself. Let me know what you think.

All 20 comments

Implementing it is probably not difficult, but why background color? Shouldn't it be a dedicated color contrasting with the cursor color? After all the background color changes depnding on the application.

I suppose that would indeed be more appropriate.

Hmm I'm not convinced this is a good idea. With a blinking cursor it would look pretty bad to have the foreground color changing both when cursor moves and on blink. But maybe I am imagining it. Do you know of any other terminal that have this feature, so Ican try it out and see how it looks, before spending the time to implement it?

iTerm2 for macOS does this. I don't know of any terminal applications on Linux that does this, but I'm sure there has to be some. I've attached a short gif demonstrating the behaviour with the effect I'd like.

cursor

Implemented in the fast branch.

Works great, thanks!

Is there any way to use a constant color for the text under the cursor? The current approach causes a visibility problem if the cursor is light and it is currently over some text with a light background.

I'm imagining two separate settings: cursor_foreground for the text under the cursor and cursor_background for the cursor itself.

If cursor_foreground is unspecified, then kitty can fallback to the current behaviour. What do you think?

Thanks for an incredible terminal!

There are three possible approaches:
1) Use a defined foreground and background color
2) Use a defined background color and the foreground color from the current terminal background
3) Use a full reverse video effect (invert the colors in the terminal for the cursor)

Different terminals typically support one of these three approaches. And different kitty users have requested all three at different times. I am fine with (1) and (2). The problem with (3) is that it breaks the terminal escape codes used to change cursor colors.

That said I also dont much see the point of (1). You should set your cursor color to have good contrast with the background color. If you do that and you still have poor contrast with text , then that means the text already has poor contrast with the background, and is hard to see regardless of whether the cursor is over it or not.

Thanks for the quick reply! The problem for me is that my colorscheme in Vim has a dark background under normal circumstances, but search matches have a light background (yellow) with a dark foreground. Please see this gif:

test

Yeah, the easiest thing to do is change either the search highlight color to be a bit darker, or your cursor color to be a bit darker. Although, given that the cursor blinks, it isn't that hard to see the text under it :)

Thank you, I'll give it a try!

EDIT: It works great!

@kovidgoyal is cursor color invertion supported? (as showed in https://github.com/kovidgoyal/kitty/issues/126#issuecomment-329957873) I've tried the background cursor text color, but it's not quite what I want. Color invertion ensures the cursor is visible at all times, as explained in https://github.com/kovidgoyal/kitty/issues/126#issuecomment-404356384.
I'd be happy to open a PR if it's not supported yet and you're ok with including it.

As I said above, I am not a fan of inversion because it breaks the terminal escape codes used to set cursor colors. It means that it is no longer possible for terminal applications to control cursor colors, as needed.

Ok, I get your point, it's true that it has downsides. However, I think that ultimately, if the user really wants to have inversion, it should have priority over terminal applications.
Besides, cursor color inversion is also the best way (that I know of) to make the cursor clearly visible at all times. For example, I use a dark colorscheme in the terminal, but a light colorscheme in neovim. Any cursor bg color choice will fail to make it visible at some point. The proof that it's so useful is that it is implemented in most other terminals (which unfortunately lack the features of Kitty, thus why I'm being insistent on having it in Kitty :)
I understand that you're not a fan of using it yourself and thus have no interest in implementing it, but if you can tolerate it being implemented in Kitty I can do it myself. Let me know what you think.

Simply have neovim change the cursor color as part of changing the color scheme. That's the whole point of having application controllable cursor colors in the first place. If you dont know how to get neovim to do that, make a shell script wrapper for it that changes the cursor color and then launches it. It would be a five line script.

The problem with having inverted colors is that it means the entire ecosystem can no longer rely on being able to change cursor colors, so that feature becomes unusable for everybody.

The problem with having inverted colors is that it means the entire ecosystem can no longer rely on being able to change cursor colors

@kovidgoyal @romgrk
Isn't it possible to set _inverted cursor_ as a kind of default? I mean, I imagine an option, which when set to true, will cause kitty to render inverted cursor by default unless the terminal application (neovim in this case) explicitly mentions something else. Isn't it possible?

it is implemented in most other terminals (which unfortunately lack the features of Kitty, thus why I'm being insistent on having it in Kitty :)

Exactly. :)
I perfectly understand that @kovidgoyal doesn't want to implement it himself. But if this feature is possible to implement, and if someone can submit a PR, then I think there should not be any problem....

I'm not using kitty at the moment so I don't plan to submit a PR.

@romgrk What are you using now?

tilix

Was this page helpful?
0 / 5 - 0 ratings

Related issues

skosch picture skosch  路  3Comments

bewzaalex picture bewzaalex  路  3Comments

wavexx picture wavexx  路  3Comments

Jomik picture Jomik  路  4Comments

Ulrar picture Ulrar  路  3Comments