Skip to content
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

Support for decorations to change cell foreground and background #3775

Merged
merged 25 commits into from
May 11, 2022

Conversation

Tyriar
Copy link
Member

@Tyriar Tyriar commented May 10, 2022

Fixes #3770

This new feature works by swapping out the the background and foreground colors of the cell. This is slightly different depending on the renderer especially wrt getting the correct cache key to use which is why caching of decoration override glyphs isn't supported at all for the canvas renderer.

Notice how the text is white:

image

Current API shape:

export interface IDecorationOptions {
  readonly backgroundColor?: string;
  readonly foregroundColor?: string;
}

Note the API doesn't allow changing the colors currently as that's not actually a requirement for the search addon.

Remaining work:

  • Webgl renderer tests
  • Expose an interface on IDecorationService to get decorations at a cell to reduce code duplication
  • Maintain a sorted list of decorations (by line) in IDecorationService and utilize it to go from O(n) to O(log n) when iterating over decorations of a line
  • Review TODOs/clean up

Deferred from the PR:

  • Alpha support - can look into it if we need it
  • Allow the webgl renderer to draw decorations on top of the selection - this is required in order to get consistency in how VS Code's editor looks and works. My idea here is to bring selection rendering into the main glyph rendering part similar to how overrides work and then add another decoration option for whether it's above or below the selection. bg/fg decorations should be able to render on top of the selection #3778

Other issues fixed:

  • Minimum contrast ratio was using the wrong channel when determining luminance which would throw the resulting color off.
  • Decorations are now cleared on Terminal.reset()

Sorry, something went wrong.

Tyriar added 16 commits May 9, 2022 12:44

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms
Part of xtermjs#3770

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms
IColor is needed for the minimum contrast ratio function currently.

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms
@Tyriar Tyriar added this to the 4.19.0 milestone May 10, 2022
@Tyriar Tyriar self-assigned this May 10, 2022
Tyriar added 9 commits May 10, 2022 11:48

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms

Verified

This commit was signed with the committer’s verified signature.
Tyriar Daniel Imms
@Tyriar Tyriar requested a review from meganrogge May 11, 2022 16:55
@Tyriar Tyriar marked this pull request as ready for review May 11, 2022 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow decorations to change the background of a cell
1 participant