-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cursorTextColor attribute to colour schemes #15766
Comments
After some discussion, I think we did end up losing this over the course of #1203 and #9610. Rather than resurrect one of those, we thought it best to use this fresh thread to track this again. That way we won't have any of the old legacy notes about DxEngine-specific implementation details. 🚧 This space to be updated 🚧 I too have not paged this back in yet, but IIRC there was a collection of related issues:
again, long since paged this out 😕 notes:
@DHowett proposal
@zadjii-msft proposal from #6151 We'll introduce
|
The easiest and most user-friendly option is to let the user choose. Guessing/auto-computing the 'right" color is not trivial and may completely miss some needs of the user, e.g. vision impairment, or output-device-specific constraints. On the other bugs, a lot of time was spent on finding the perfect algorithm to determine the right color, to the point of exasperation of several users that just wanted to set the color themselves for their own needs. Please just implement user choice. It's the right thing to do. |
The preview version of Windows Terminal v1.18 fixes the issue of illegible text under the cursor by somehow automatically determining the colour of the character under the cursor. The colour of the character under the cursor is not constant, it changes depending on the native colour of the character (and probably the colour of the cursor). However, the contrast is acceptable in most cases. See more information about this feature in [1]. Setting the cursor text colour explicitly as part of the colour scheme (arguably a better solution than the current implementation) is still separately discussed in [2]. [1] microsoft/terminal#7118 [2] microsoft/terminal#15766
I also support the proposition by @klausman. There's nothing more needed than a As mentioned, this is exactly how it's done in iTerm2, and in fact after many years of using iTerm2, I never even noticed that the separate cursor text colour is a thing until I noticed the absence of it in Windows Terminal. Actually, the v1.18 preview version implements a separate colour for the character under the cursor (also discussed in #7118), however, the colour is automatically determined and it changes based on the native colour of the text. It seems to be sometimes the inverse of the text colour (e.g. blue becomes red, purple becomes green, etc.), in other cases it's just a colour that contrasts well with the cursor. This actually almost solves the problem, however, contrast could sometimes still be better and the changing of the colour might be more distracting than helpful. So, in summary, the added complexity of determining the colour automatically doesn't really provide any benefit, and the much simpler solution of just setting the cursor text colour explicitly would most probably provide the better result, including being more transparent and deterministic. |
Except for cases where the block cursor background color can change (are there such cases?) this might be the most bullet-proof solution. It might require some user input in choosing that color, but it guarantees fit for purpose for this user. However, it does have one disadvantage: the original fg color is lost completely. For some it might be still fine, while others might prefer to show the original color (or some variant of it) where possible.
This would probably be a good simple solution if the user doesn't have control over it. It would fit with the theme, and, assuming the chosen cursor bg color has reasonable contrast with the terminal bg (which might not be true), would result in useful contrast.
This might sound reasonable, but actually, IMHO this never worked as a general solution in practice. For instance, red is never a good contrast to cyan (blue+green), etc. Also, obviously, 127,127,127 might not be the best contrast to 128,128,128...
As history shows in the other bugs, this is much much tricker than it seems at first. The biggest contrast is when the chosen color is either exactly white or exactly black. These are the luminance extremes, and one of them would have the greatest distance from the luminance value of the BG color. However, at these extremes, it could feel out of place with the theme. For instance, with a muted theme, a full white or full black could be jarring (but might also be exactly what the user prefers, who knows?!) But if we stick to this approach, then it might be best to allow some configuration of the desired minimum contrast to the FG text. As such, the final FG color is probably someplace between the original FG color and white or black (whichever has the biggest contrast to the BG). But, it's important to keep in mind that the luminance value is not (R+G+B)/3. That's because the channels don't have the same brightness. For instance, green is about 6 times brighter than blue. A simplified formula to get the brightness is: (I'm not a colorspace expert, so this formula should be taken with a grain of salt) And so, the best contrast for full-green might be black, while the best contrast to full-blue might be white. So a solution based on such approach might "push" the original FG color towards either white or black until it reaches some desirable luminance distance from the configured BG color. This would both keep the original FG color where it already has enough contrast, and might also keep the general fg color even when it's modified to increase the contrast. So bottom line, the best solution is probably to allow two modes of FG color:
|
Description of the new feature/enhancement
Colour schemes allow setting the cursor colour (
cursorColor
), however, they don't allow setting the text colour of the character under the cursor. The character under the cursor just keeps its native colour. This is a problem for the Filled Box cursor type because the character under the cursor may become very illegible if the cursor colour and character colour don't happen to naturally contrast.This problem is exacerbated in applications like Vim where the text that the cursor moves over comes in many different colours. Thus, the problem can't be generally solved by changing the cursor colour because there might always be some combination of cursor and text colour that remain illegible.
The best solution to this problem would be to always change the colour of the character under the cursor to a colour that contrasts well with the cursor colour. In this way, it's guaranteed that the character under the cursor is always legible.
This could be implemented by adding a cursor text colour attribute to the colour scheme (e.g.
cursorTextColor
attribute), so that colour scheme designers can choose a good combination.That's also exactly how it is done in iTerm2:
Considerations:
cursorFilledBoxTextColor
to make this clear.Related:
The text was updated successfully, but these errors were encountered: