microsoft / microsoft/terminal

Add cursorTextColor attribute to colour schemes

Open
#15,766 4 comments 7 reactions 0 assignees View on GitHub
Area-Rendering Area-Settings Issue-Feature Product-Terminal
Dominant language
C++
Stars
105k
Forks
9.6k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

# 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:

![unnamed](https://github.com/microsoft/terminal/assets/2396208/d7a9741c-efe1-43b5-90d7-ba8da960b078)

Considerations:

- This applies only to the _Filled Box_ cursor type. For the other cursor types, it's not necessary to change the colour of the character under the cursor.
- Thus, the attribute could maybe be named `cursorFilledBoxTextColor` to make this clear.

Related:

- #1203 addressed a similar issue, however, it only solved printing the character on top of the cursor instead of below it. It does not change the colour of the character, and thus the problem of illegible colour combinations remains.

Contributor guide

Open the contributing guide

Research direction

No implementation files or tests are named. Start by tracing colour-scheme handling and cursor rendering in the terminal, then review issue #1203 for related behavior. Done means a colour-scheme attribute controls the text under a Filled Box cursor without changing the other cursor types.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.